001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2006-2008 Sun Microsystems, Inc. 025 * Portions Copyright 2014-2015 ForgeRock AS 026 */ 027package org.opends.server.types; 028 029import static org.opends.server.protocols.ldap.LDAPConstants.*; 030 031 032 033/** 034 * This enumeration defines the set of possible filter types that may 035 * be used for search filters. This is based on the LDAP 036 * specification defined in RFC 2251. 037 */ 038@org.opends.server.types.PublicAPI( 039 stability=org.opends.server.types.StabilityLevel.UNCOMMITTED, 040 mayInstantiate=false, 041 mayExtend=false, 042 mayInvoke=true) 043public enum FilterType 044{ 045 /** 046 * The filter type for AND filters. 047 */ 048 AND(TYPE_FILTER_AND), 049 050 051 052 /** 053 * The filter type for OR filters. 054 */ 055 OR(TYPE_FILTER_OR), 056 057 058 059 /** 060 * The filter type for NOT filters. 061 */ 062 NOT(TYPE_FILTER_NOT), 063 064 065 066 /** 067 * The filter type for equality filters. 068 */ 069 EQUALITY(TYPE_FILTER_EQUALITY), 070 071 072 073 /** 074 * The filter type for substring filters. 075 */ 076 SUBSTRING(TYPE_FILTER_SUBSTRING), 077 078 079 080 /** 081 * The filter type for greater or equal filters. 082 */ 083 GREATER_OR_EQUAL(TYPE_FILTER_GREATER_OR_EQUAL), 084 085 086 087 /** 088 * The filter type for less or equal filters. 089 */ 090 LESS_OR_EQUAL(TYPE_FILTER_LESS_OR_EQUAL), 091 092 093 094 /** 095 * The filter type for presence filters. 096 */ 097 PRESENT(TYPE_FILTER_PRESENCE), 098 099 100 101 /** 102 * The filter type for approximate filters. 103 */ 104 APPROXIMATE_MATCH(TYPE_FILTER_APPROXIMATE), 105 106 107 108 /** 109 * The filter type for extensible matching filters. 110 */ 111 EXTENSIBLE_MATCH(TYPE_FILTER_EXTENSIBLE_MATCH); 112 113 114 115 /** The LDAP BER type for this filter type. */ 116 private byte berType; 117 118 119 120 /** 121 * Creates a new filter type with the provided BER type. 122 * 123 * @param berType The LDAP BER type for this filter type. 124 */ 125 private FilterType(byte berType) 126 { 127 this.berType = berType; 128 } 129 130 131 132 /** 133 * Retrieves the LDAP BER type for this filter type. 134 * 135 * @return The LDAP BER type for this filter type. 136 */ 137 public byte getBERType() 138 { 139 return berType; 140 } 141 142 143 144 /** 145 * Retrieves a string representation of this filter type. 146 * 147 * @return A string representation of this filter type. 148 */ 149 public String toString() 150 { 151 switch (berType) 152 { 153 case TYPE_FILTER_AND: 154 return "and"; 155 case TYPE_FILTER_OR: 156 return "or"; 157 case TYPE_FILTER_NOT: 158 return "not"; 159 case TYPE_FILTER_EQUALITY: 160 return "equalityMatch"; 161 case TYPE_FILTER_SUBSTRING: 162 return "substrings"; 163 case TYPE_FILTER_GREATER_OR_EQUAL: 164 return "greaterOrEqual"; 165 case TYPE_FILTER_LESS_OR_EQUAL: 166 return "lessOrEqual"; 167 case TYPE_FILTER_PRESENCE: 168 return "present"; 169 case TYPE_FILTER_APPROXIMATE: 170 return "approxMatch"; 171 case TYPE_FILTER_EXTENSIBLE_MATCH: 172 return "extensibleMatch"; 173 default: 174 return "Unknown"; 175 } 176 } 177} 178