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-2015 ForgeRock AS.
016 */
017package org.opends.server.types;
018
019import static org.opends.server.protocols.ldap.LDAPConstants.*;
020
021
022
023/**
024 * This enumeration defines the set of possible filter types that may
025 * be used for search filters.  This is based on the LDAP
026 * specification defined in RFC 2251.
027 */
028@org.opends.server.types.PublicAPI(
029     stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
030     mayInstantiate=false,
031     mayExtend=false,
032     mayInvoke=true)
033public enum FilterType
034{
035  /**
036   * The filter type for AND filters.
037   */
038  AND(TYPE_FILTER_AND),
039
040
041
042  /**
043   * The filter type for OR filters.
044   */
045  OR(TYPE_FILTER_OR),
046
047
048
049  /**
050   * The filter type for NOT filters.
051   */
052  NOT(TYPE_FILTER_NOT),
053
054
055
056  /**
057   * The filter type for equality filters.
058   */
059  EQUALITY(TYPE_FILTER_EQUALITY),
060
061
062
063  /**
064   * The filter type for substring filters.
065   */
066  SUBSTRING(TYPE_FILTER_SUBSTRING),
067
068
069
070  /**
071   * The filter type for greater or equal filters.
072   */
073  GREATER_OR_EQUAL(TYPE_FILTER_GREATER_OR_EQUAL),
074
075
076
077  /**
078   * The filter type for less or equal filters.
079   */
080  LESS_OR_EQUAL(TYPE_FILTER_LESS_OR_EQUAL),
081
082
083
084  /**
085   * The filter type for presence filters.
086   */
087  PRESENT(TYPE_FILTER_PRESENCE),
088
089
090
091  /**
092   * The filter type for approximate filters.
093   */
094  APPROXIMATE_MATCH(TYPE_FILTER_APPROXIMATE),
095
096
097
098  /**
099   * The filter type for extensible matching filters.
100   */
101  EXTENSIBLE_MATCH(TYPE_FILTER_EXTENSIBLE_MATCH);
102
103
104
105  /** The LDAP BER type for this filter type. */
106  private byte berType;
107
108
109
110  /**
111   * Creates a new filter type with the provided BER type.
112   *
113   * @param  berType  The LDAP BER type for this filter type.
114   */
115  private FilterType(byte berType)
116  {
117    this.berType = berType;
118  }
119
120
121
122  /**
123   * Retrieves the LDAP BER type for this filter type.
124   *
125   * @return  The LDAP BER type for this filter type.
126   */
127  public byte getBERType()
128  {
129    return berType;
130  }
131
132
133
134  /**
135   * Retrieves a string representation of this filter type.
136   *
137   * @return  A string representation of this filter type.
138   */
139  public String toString()
140  {
141    switch (berType)
142    {
143      case TYPE_FILTER_AND:
144        return "and";
145      case TYPE_FILTER_OR:
146        return "or";
147      case TYPE_FILTER_NOT:
148        return "not";
149      case TYPE_FILTER_EQUALITY:
150        return "equalityMatch";
151      case TYPE_FILTER_SUBSTRING:
152        return "substrings";
153      case TYPE_FILTER_GREATER_OR_EQUAL:
154        return "greaterOrEqual";
155      case TYPE_FILTER_LESS_OR_EQUAL:
156        return "lessOrEqual";
157      case TYPE_FILTER_PRESENCE:
158        return "present";
159      case TYPE_FILTER_APPROXIMATE:
160        return "approxMatch";
161      case TYPE_FILTER_EXTENSIBLE_MATCH:
162        return "extensibleMatch";
163      default:
164        return "Unknown";
165    }
166  }
167}
168