001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2006-2008 Sun Microsystems, Inc. 015 * Portions Copyright 2014-2016 ForgeRock AS. 016 */ 017package org.opends.server.types; 018 019import static org.opends.server.protocols.ldap.LDAPConstants.*; 020 021/** 022 * This enumeration defines the set of possible filter types that may 023 * be used for search filters. This is based on the LDAP 024 * specification defined in RFC 2251. 025 */ 026@org.opends.server.types.PublicAPI( 027 stability=org.opends.server.types.StabilityLevel.UNCOMMITTED, 028 mayInstantiate=false, 029 mayExtend=false, 030 mayInvoke=true) 031public enum FilterType 032{ 033 /** The filter type for AND filters. */ 034 AND(TYPE_FILTER_AND), 035 /** The filter type for OR filters. */ 036 OR(TYPE_FILTER_OR), 037 /** The filter type for NOT filters. */ 038 NOT(TYPE_FILTER_NOT), 039 /** The filter type for equality filters. */ 040 EQUALITY(TYPE_FILTER_EQUALITY), 041 /** The filter type for substring filters. */ 042 SUBSTRING(TYPE_FILTER_SUBSTRING), 043 /** The filter type for greater or equal filters. */ 044 GREATER_OR_EQUAL(TYPE_FILTER_GREATER_OR_EQUAL), 045 /** The filter type for less or equal filters. */ 046 LESS_OR_EQUAL(TYPE_FILTER_LESS_OR_EQUAL), 047 /** The filter type for presence filters. */ 048 PRESENT(TYPE_FILTER_PRESENCE), 049 /** The filter type for approximate filters. */ 050 APPROXIMATE_MATCH(TYPE_FILTER_APPROXIMATE), 051 /** The filter type for extensible matching filters. */ 052 EXTENSIBLE_MATCH(TYPE_FILTER_EXTENSIBLE_MATCH); 053 054 /** The LDAP BER type for this filter type. */ 055 private byte berType; 056 057 /** 058 * Creates a new filter type with the provided BER type. 059 * 060 * @param berType The LDAP BER type for this filter type. 061 */ 062 private FilterType(byte berType) 063 { 064 this.berType = berType; 065 } 066 067 /** 068 * Retrieves the LDAP BER type for this filter type. 069 * 070 * @return The LDAP BER type for this filter type. 071 */ 072 public byte getBERType() 073 { 074 return berType; 075 } 076 077 /** 078 * Retrieves a string representation of this filter type. 079 * 080 * @return A string representation of this filter type. 081 */ 082 @Override 083 public String toString() 084 { 085 switch (berType) 086 { 087 case TYPE_FILTER_AND: 088 return "and"; 089 case TYPE_FILTER_OR: 090 return "or"; 091 case TYPE_FILTER_NOT: 092 return "not"; 093 case TYPE_FILTER_EQUALITY: 094 return "equalityMatch"; 095 case TYPE_FILTER_SUBSTRING: 096 return "substrings"; 097 case TYPE_FILTER_GREATER_OR_EQUAL: 098 return "greaterOrEqual"; 099 case TYPE_FILTER_LESS_OR_EQUAL: 100 return "lessOrEqual"; 101 case TYPE_FILTER_PRESENCE: 102 return "present"; 103 case TYPE_FILTER_APPROXIMATE: 104 return "approxMatch"; 105 case TYPE_FILTER_EXTENSIBLE_MATCH: 106 return "extensibleMatch"; 107 default: 108 return "Unknown"; 109 } 110 } 111}