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