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