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