001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * https://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020package org.apache.directory.api.ldap.model.schema; 021 022 023import java.util.List; 024import java.util.Map; 025 026 027/** 028 * Most schema objects have some common attributes. This class 029 * contains the minimum set of properties exposed by a SchemaObject.<br> 030 * We have 11 types of SchemaObjects : 031 * <ul> 032 * <li> AttributeType </li> 033 * <li> DitCOntentRule </li> 034 * <li> DitStructureRule </li> 035 * <li> LdapComparator (specific to ADS) </li> 036 * <li> LdapSyntaxe </li> 037 * <li> MatchingRule </li> 038 * <li> MatchingRuleUse </li> 039 * <li> NameForm </li> 040 * <li> Normalizer (specific to ADS) </li> 041 * <li> ObjectClass </li> 042 * <li> SyntaxChecker (specific to ADS) </li> 043 * </ul> 044 * <br> 045 * <br> 046 * This class provides accessors and setters for the following attributes, 047 * which are common to all those SchemaObjects : 048 * <ul> 049 * <li>oid : The numeric OID </li> 050 * <li>description : The SchemaObject description </li> 051 * <li>obsolete : Tells if the schema object is obsolete </li> 052 * <li>extensions : The extensions, a key/Values map </li> 053 * <li>schemaObjectType : The SchemaObject type (see upper) </li> 054 * <li>schema : The schema the SchemaObject is associated with (it's an extension). 055 * Can be null </li> 056 * <li>isEnabled : The SchemaObject status (it's related to the schema status) </li> 057 * <li>isReadOnly : Tells if the SchemaObject can be modified or not </li> 058 * </ul> 059 * <br><br> 060 * Some of those attributes are not used by some Schema elements, even if they should 061 * have been used. Here is the list : 062 * <ul> 063 * <li><b>name</b> : LdapSyntax, Comparator, Normalizer, SyntaxChecker</li> 064 * <li><b>numericOid</b> : DitStructureRule</li> 065 * <li><b>obsolete</b> : LdapSyntax, Comparator, Normalizer, SyntaxChecker</li> 066 * </ul> 067 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a> 068 */ 069public interface SchemaObject 070{ 071 /** 072 * Gets usually what is the numeric object identifier assigned to this 073 * SchemaObject. All schema objects except for MatchingRuleUses have an OID 074 * assigned specifically to then. A MatchingRuleUse's OID really is the OID 075 * of it's MatchingRule and not specific to the MatchingRuleUse. This 076 * effects how MatchingRuleUse objects are maintained by the system. 077 * 078 * @return an OID for this SchemaObject or its MatchingRule if this 079 * SchemaObject is a MatchingRuleUse object 080 */ 081 String getOid(); 082 083 084 /** 085 * A special method used when renaming an SchemaObject: we may have to 086 * change it's OID 087 * @param oid The new OID 088 */ 089 void setOid( String oid ); 090 091 092 /** 093 * Gets short names for this SchemaObject if any exists for it, otherwise, 094 * returns an empty list. 095 * 096 * @return the names for this SchemaObject 097 */ 098 List<String> getNames(); 099 100 101 /** 102 * Gets the first name in the set of short names for this SchemaObject if 103 * any exists for it. 104 * 105 * @return the first of the names for this SchemaObject or the oid 106 * if one does not exist 107 */ 108 String getName(); 109 110 111 /** 112 * Add a new name to the list of names for this SchemaObject. The name 113 * is lower cased and trimmed. 114 * 115 * @param names The names to add 116 */ 117 void addName( String... names ); 118 119 120 /** 121 * Sets the list of names for this SchemaObject. The names are 122 * lower cased and trimmed. 123 * 124 * @param names The list of names. Can be empty 125 */ 126 void setNames( List<String> names ); 127 128 129 /** 130 * Gets a short description about this SchemaObject. 131 * 132 * @return a short description about this SchemaObject 133 */ 134 String getDescription(); 135 136 137 /** 138 * Sets the SchemaObject's description 139 * 140 * @param description The SchemaObject's description 141 */ 142 void setDescription( String description ); 143 144 145 /** 146 * Gets the SchemaObject specification. 147 * 148 * @return the SchemaObject specification 149 */ 150 String getSpecification(); 151 152 153 /** 154 * Sets the SchemaObject's specification 155 * 156 * @param specification The SchemaObject's specification 157 */ 158 void setSpecification( String specification ); 159 160 161 /** 162 * Tells if this SchemaObject is enabled. 163 * 164 * @return true if the SchemaObject is enabled, or if it depends on 165 * an enabled schema 166 */ 167 boolean isEnabled(); 168 169 170 /** 171 * Tells if this SchemaObject is disabled. 172 * 173 * @return true if the SchemaObject is disabled 174 */ 175 boolean isDisabled(); 176 177 178 /** 179 * Sets the SchemaObject state, either enabled or disabled. 180 * 181 * @param enabled The current SchemaObject state 182 */ 183 void setEnabled( boolean enabled ); 184 185 186 /** 187 * Gets whether or not this SchemaObject has been inactivated. All 188 * SchemaObjects except Syntaxes allow for this parameter within their 189 * definition. For Syntaxes this property should always return false in 190 * which case it is never included in the description. 191 * 192 * @return true if inactive, false if active 193 */ 194 boolean isObsolete(); 195 196 197 /** 198 * Sets the Obsolete flag. 199 * 200 * @param obsolete The Obsolete flag state 201 */ 202 void setObsolete( boolean obsolete ); 203 204 205 /** 206 * @return The SchemaObject extensions, as a Map of [extension, values] 207 */ 208 Map<String, List<String>> getExtensions(); 209 210 211 /** 212 * Check if a given extension is part of the SchemaObject. Extensions are case insensitive. 213 * 214 * @param extension The extension we are looking for. 215 * @return <code>true</code> if the extension is present. 216 */ 217 boolean hasExtension( String extension ); 218 219 220 /** 221 * Get back the values associated with a given extension. 222 * 223 * @param extension The extension we are looking for. 224 * @return The list of values associated with the extension 225 */ 226 List<String> getExtension( String extension ); 227 228 229 /** 230 * Add an extension with its values 231 * @param key The extension key 232 * @param values The associated values 233 */ 234 void addExtension( String key, String... values ); 235 236 237 /** 238 * Add an extension with its values 239 * @param key The extension key 240 * @param values The associated values 241 */ 242 void addExtension( String key, List<String> values ); 243 244 245 /** 246 * Add an extensions with their values. (Actually do a copy) 247 * 248 * @param extensions The extensions map 249 */ 250 void setExtensions( Map<String, List<String>> extensions ); 251 252 253 /** 254 * The SchemaObject type : 255 * <ul> 256 * <li> AttributeType</li> 257 * <li> DitCOntentRule</li> 258 * <li> DitStructureRule</li> 259 * <li> LdapComparator (specific to ADS)</li> 260 * <li> LdapSyntaxe</li> 261 * <li> MatchingRule</li> 262 * <li> MatchingRuleUse</li> 263 * <li> NameForm</li> 264 * <li> Normalizer (specific to ADS)</li> 265 * <li> ObjectClass</li> 266 * <li> SyntaxChecker (specific to ADS)</li> 267 * </ul> 268 * 269 * @return the SchemaObject type 270 */ 271 SchemaObjectType getObjectType(); 272 273 274 /** 275 * Gets the name of the schema this SchemaObject is associated with. 276 * 277 * @return the name of the schema associated with this schemaObject 278 */ 279 String getSchemaName(); 280 281 282 /** 283 * Sets the name of the schema this SchemaObject is associated with. 284 * 285 * @param schemaName the new schema name 286 */ 287 void setSchemaName( String schemaName ); 288 289 290 /** 291 * {@inheritDoc} 292 */ 293 @Override 294 int hashCode(); 295 296 297 /** 298 * {@inheritDoc} 299 */ 300 @Override 301 boolean equals( Object o1 ); 302 303 304 /** 305 * Copy the current SchemaObject on place 306 * 307 * @return The copied SchemaObject 308 */ 309 SchemaObject copy(); 310 311 312 /** 313 * Copies the given schema object into this schema object. 314 * 315 * @param original the original SchemaObject 316 * @return this 317 */ 318 SchemaObject copy( SchemaObject original ); 319 320 321 /** 322 * Clear the current SchemaObject : remove all the references to other objects, 323 * and all the Maps. 324 */ 325 void clear(); 326 327 328 /** 329 * Transform the SchemaObject to an immutable object 330 * TODO locked. 331 * 332 */ 333 void lock(); 334}