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 2008 Sun Microsystems, Inc.
026 */
027 package org.opends.server.types;
028
029
030
031 import static org.opends.server.util.StaticUtils.*;
032
033
034
035 /**
036 * This class implements an enumeration that may be used to define the
037 * ways in which an attribute may be indexed within the server.
038 */
039 @org.opends.server.types.PublicAPI(
040 stability=org.opends.server.types.StabilityLevel.UNCOMMITTED,
041 mayInstantiate=false,
042 mayExtend=false,
043 mayInvoke=true)
044 public enum IndexType
045 {
046 /**
047 * Used to denote a presence index, which may be used to identify
048 * entries containing the associated attribute (regardless of the
049 * value for that attribute).
050 */
051 PRESENCE("presence"),
052
053
054
055 /**
056 * Used to denote an equality index, which may be used to identify
057 * entries containing a specified value for the associated
058 * attribute.
059 */
060 EQUALITY("equality"),
061
062
063
064 /**
065 * Used to denote a substring index, which may be used to identify
066 * entries with one or more values for the associated attribute that
067 * match a given substring assertion. That substring assertion may
068 * contain any or all of subInitial, subAny, and subFinal elements.
069 */
070 SUBSTRING("substring"),
071
072
073
074 /**
075 * Used to denote a subInitial index, which may be used to identify
076 * entries with one or more values for the associated attribute that
077 * begin with a specified string.
078 */
079 SUBINITIAL("subinitial"),
080
081
082
083 /**
084 * Used to denote a subAny index, which may be used to identify
085 * entries with one or more values for the associated attribute that
086 * contain a specified string.
087 */
088 SUBANY("subany"),
089
090
091
092 /**
093 * Used to denote a subFinal index, which may be used to identify
094 * entries with one or more values for the associated attribute that
095 * end with a specified string.
096 */
097 SUBFINAL("subfinal"),
098
099
100
101 /**
102 * Used to denote a greater-or-equal index, which may be used to
103 * identify entries with one or more values that are greater than or
104 * equal to a specified value.
105 */
106 GREATER_OR_EQUAL("greater-or-equal"),
107
108
109
110 /**
111 * Used to denote a less-or-equal index, which may be used to
112 * identify entries with one or more values that are less than or
113 * equal to a specified value.
114 */
115 LESS_OR_EQUAL("less-or-equal"),
116
117
118
119 /**
120 * Used to denote an approximate index, which may be used to
121 * identify entries with one or more values that are approximately
122 * equal to a specified value.
123 */
124 APPROXIMATE("approximate");
125
126
127
128 // The human-readable name for this index type.
129 private final String indexName;
130
131
132
133 /**
134 * Creates a new index type with the specified name.
135 *
136 * @param indexName The human-readable name for this index type.
137 */
138 private IndexType(String indexName)
139 {
140 this.indexName = indexName;
141 }
142
143
144
145 /**
146 * Retrieves the index type for the specified name.
147 *
148 * @param indexName The name for which to retrieve the
149 * associated index type.
150 *
151 * @return The requested index type, or {@code null} if there is no
152 * such index type.
153 */
154 public static IndexType forName(String indexName)
155 {
156 String lowerName = toLowerCase(indexName);
157 if (lowerName.equals("presence") || lowerName.equals("pres"))
158 {
159 return PRESENCE;
160 }
161 else if (lowerName.equals("equality") || lowerName.equals("eq"))
162 {
163 return EQUALITY;
164 }
165 else if (lowerName.equals("substring") || lowerName.equals("sub"))
166 {
167 return SUBSTRING;
168 }
169 else if (lowerName.equals("subinitial"))
170 {
171 return SUBINITIAL;
172 }
173 else if (lowerName.equals("subany"))
174 {
175 return SUBANY;
176 }
177 else if (lowerName.equals("subfinal"))
178 {
179 return SUBFINAL;
180 }
181 else if (lowerName.equals("greater-or-equal") ||
182 lowerName.equals("greaterorequal") ||
183 lowerName.equals("greater-than-or-equal-to") ||
184 lowerName.equals("greaterthanorequalto"))
185 {
186 return GREATER_OR_EQUAL;
187 }
188 else if (lowerName.equals("less-or-equal") ||
189 lowerName.equals("lessorequal") ||
190 lowerName.equals("less-than-or-equal-to") ||
191 lowerName.equals("lessthanorequalto"))
192 {
193 return LESS_OR_EQUAL;
194 }
195 else if (lowerName.equals("approximate") ||
196 lowerName.equals("approx"))
197 {
198 return APPROXIMATE;
199 }
200
201 return null;
202 }
203
204
205
206 /**
207 * Retrieves the human-readable name for this index type.
208 *
209 * @return The human-readable name for this index type.
210 */
211 public String toString()
212 {
213 return indexName;
214 }
215 }
216