Class AbstractSchemaObject
- java.lang.Object
-
- org.apache.directory.api.ldap.model.schema.AbstractSchemaObject
-
- All Implemented Interfaces:
Serializable,SchemaObject
- Direct Known Subclasses:
AttributeType,DitContentRule,DitStructureRule,LdapSyntax,LoadableSchemaObject,MatchingRule,MatchingRuleUse,NameForm,ObjectClass
public abstract class AbstractSchemaObject extends Object implements SchemaObject, Serializable
Most schema objects have some common attributes. This class contains the minimum set of properties exposed by a SchemaObject.
We have 11 types of SchemaObjects :- AttributeType
- DitCOntentRule
- DitStructureRule
- LdapComparator (specific to ADS)
- LdapSyntaxe
- MatchingRule
- MatchingRuleUse
- NameForm
- Normalizer (specific to ADS)
- ObjectClass
- SyntaxChecker (specific to ADS)
This class provides accessors and setters for the following attributes, which are common to all those SchemaObjects :- oid : The numeric OID
- description : The SchemaObject description
- obsolete : Tells if the schema object is obsolete
- extensions : The extensions, a key/Values map
- schemaObjectType : The SchemaObject type (see upper)
- schema : The schema the SchemaObject is associated with (it's an extension). Can be null
- isEnabled : The SchemaObject status (it's related to the schema status)
- isReadOnly : Tells if the SchemaObject can be modified or not
Some of those attributes are not used by some Schema elements, even if they should have been used. Here is the list :- name : LdapSyntax, Comparator, Normalizer, SyntaxChecker
- numericOid : DitStructureRule
- obsolete : LdapSyntax, Comparator, Normalizer, SyntaxChecker
- Author:
- Apache Directory Project
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected StringdescriptionA short description of this SchemaObjectprotected Map<String,List<String>>extensionsA map containing the list of supported extensionsprotected inthThe hashcode for this schemaObjectprotected booleanisEnabledWhether or not this SchemaObject is enabledprotected booleanisObsoleteWhether or not this SchemaObject is obsoleteprotected booleanlockedA locked to avoid modifications when set to trueprotected List<String>namesThe optional names for this SchemaObjectprotected SchemaObjectTypeobjectTypeThe SchemaObjectTypeprotected StringoidThe SchemaObject numeric OIDprotected StringschemaNameThe name of the schema this object is associated withprotected StringspecificationThe SchemaObject specification
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractSchemaObject(SchemaObjectType objectType)Constructor used when a generic reusable SchemaObject is assigned an OID after being instantiated.protectedAbstractSchemaObject(SchemaObjectType objectType, String oid)A constructor for a SchemaObject instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExtension(String key, String... values)Add an extension with its valuesvoidaddExtension(String key, List<String> values)Add an extension with its valuesvoidaddName(String... namesToAdd)Add a new name to the list of names for this SchemaObject.voidclear()Clear the current SchemaObject : remove all the references to other objects, and all the Maps.protected booleancompareOid(String oid1, String oid2)Compare two oids, and return true if they are both null or equal.protected voidcomputeHashCode()Compute the hashcode, and store it in the 'h' variableSchemaObjectcopy(SchemaObject original)Copies the given schema object into this schema object.booleanequals(Object o1)StringgetDescription()Gets a short description about this SchemaObject.List<String>getExtension(String extension)Get back the values associated with a given extension.Map<String,List<String>>getExtensions()StringgetName()Gets the first name in the set of short names for this SchemaObject if any exists for it.List<String>getNames()Gets short names for this SchemaObject if any exists for it, otherwise, returns an empty list.SchemaObjectTypegetObjectType()The SchemaObject type : AttributeType DitCOntentRule DitStructureRule LdapComparator (specific to ADS) LdapSyntaxe MatchingRule MatchingRuleUse NameForm Normalizer (specific to ADS) ObjectClass SyntaxChecker (specific to ADS)StringgetOid()Gets usually what is the numeric object identifier assigned to this SchemaObject.StringgetSchemaName()Gets the name of the schema this SchemaObject is associated with.StringgetSpecification()Gets the SchemaObject specification.booleanhasExtension(String extension)Check if a given extension is part of the SchemaObject.inthashCode()booleanisDisabled()Tells if this SchemaObject is disabled.booleanisEnabled()Tells if this SchemaObject is enabled.booleanisObsolete()Gets whether or not this SchemaObject has been inactivated.voidlock()Transform the SchemaObject to an immutable object TODO locked.voidsetDescription(String description)Sets the SchemaObject's descriptionvoidsetEnabled(boolean enabled)Sets the SchemaObject state, either enabled or disabled.voidsetExtensions(Map<String,List<String>> extensions)Add an extensions with their values.voidsetNames(String... names)Sets the list of names for this SchemaObject.voidsetNames(List<String> names)Sets the list of names for this SchemaObject.voidsetObsolete(boolean obsolete)Sets the Obsolete flag.voidsetOid(String oid)A special method used when renaming an SchemaObject: we may have to change it's OIDvoidsetSchemaName(String schemaName)Sets the name of the schema this SchemaObject is associated with.voidsetSpecification(String specification)Sets the SchemaObject's specificationvoidunlock()Unlock the Schema Object and make it modifiable again.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.directory.api.ldap.model.schema.SchemaObject
copy
-
-
-
-
Field Detail
-
oid
protected String oid
The SchemaObject numeric OID
-
isEnabled
protected boolean isEnabled
Whether or not this SchemaObject is enabled
-
isObsolete
protected boolean isObsolete
Whether or not this SchemaObject is obsolete
-
description
protected String description
A short description of this SchemaObject
-
specification
protected String specification
The SchemaObject specification
-
schemaName
protected String schemaName
The name of the schema this object is associated with
-
objectType
protected SchemaObjectType objectType
The SchemaObjectType
-
extensions
protected transient Map<String,List<String>> extensions
A map containing the list of supported extensions
-
locked
protected volatile boolean locked
A locked to avoid modifications when set to true
-
h
protected volatile int h
The hashcode for this schemaObject
-
-
Constructor Detail
-
AbstractSchemaObject
protected AbstractSchemaObject(SchemaObjectType objectType, String oid)
A constructor for a SchemaObject instance. It must be invoked by the inherited class.- Parameters:
objectType- The SchemaObjectType to createoid- the SchemaObject numeric OID
-
AbstractSchemaObject
protected AbstractSchemaObject(SchemaObjectType objectType)
Constructor used when a generic reusable SchemaObject is assigned an OID after being instantiated.- Parameters:
objectType- The SchemaObjectType to create
-
-
Method Detail
-
getOid
public String getOid()
Gets usually what is the numeric object identifier assigned to this SchemaObject. All schema objects except for MatchingRuleUses have an OID assigned specifically to then. A MatchingRuleUse's OID really is the OID of it's MatchingRule and not specific to the MatchingRuleUse. This effects how MatchingRuleUse objects are maintained by the system.- Specified by:
getOidin interfaceSchemaObject- Returns:
- an OID for this SchemaObject or its MatchingRule if this SchemaObject is a MatchingRuleUse object
-
setOid
public void setOid(String oid)
A special method used when renaming an SchemaObject: we may have to change it's OID- Specified by:
setOidin interfaceSchemaObject- Parameters:
oid- The new OID
-
getNames
public List<String> getNames()
Gets short names for this SchemaObject if any exists for it, otherwise, returns an empty list.- Specified by:
getNamesin interfaceSchemaObject- Returns:
- the names for this SchemaObject
-
getName
public String getName()
Gets the first name in the set of short names for this SchemaObject if any exists for it.- Specified by:
getNamein interfaceSchemaObject- Returns:
- the first of the names for this SchemaObject or the oid if one does not exist
-
addName
public void addName(String... namesToAdd)
Add a new name to the list of names for this SchemaObject. The name is lower cased and trimmed.- Specified by:
addNamein interfaceSchemaObject- Parameters:
namesToAdd- The names to add
-
setNames
public void setNames(List<String> names)
Sets the list of names for this SchemaObject. The names are lowercased and trimmed.- Specified by:
setNamesin interfaceSchemaObject- Parameters:
names- The list of names. Can be empty
-
setNames
public void setNames(String... names)
Sets the list of names for this SchemaObject. The names are lowercased and trimmed.- Parameters:
names- The list of names.
-
getDescription
public String getDescription()
Gets a short description about this SchemaObject.- Specified by:
getDescriptionin interfaceSchemaObject- Returns:
- a short description about this SchemaObject
-
setDescription
public void setDescription(String description)
Sets the SchemaObject's description- Specified by:
setDescriptionin interfaceSchemaObject- Parameters:
description- The SchemaObject's description
-
getSpecification
public String getSpecification()
Gets the SchemaObject specification.- Specified by:
getSpecificationin interfaceSchemaObject- Returns:
- the SchemaObject specification
-
setSpecification
public void setSpecification(String specification)
Sets the SchemaObject's specification- Specified by:
setSpecificationin interfaceSchemaObject- Parameters:
specification- The SchemaObject's specification
-
isEnabled
public boolean isEnabled()
Tells if this SchemaObject is enabled.- Specified by:
isEnabledin interfaceSchemaObject- Returns:
- true if the SchemaObject is enabled, or if it depends on an enabled schema
-
isDisabled
public boolean isDisabled()
Tells if this SchemaObject is disabled.- Specified by:
isDisabledin interfaceSchemaObject- Returns:
- true if the SchemaObject is disabled
-
setEnabled
public void setEnabled(boolean enabled)
Sets the SchemaObject state, either enabled or disabled.- Specified by:
setEnabledin interfaceSchemaObject- Parameters:
enabled- The current SchemaObject state
-
isObsolete
public boolean isObsolete()
Gets whether or not this SchemaObject has been inactivated. All SchemaObjects except Syntaxes allow for this parameter within their definition. For Syntaxes this property should always return false in which case it is never included in the description.- Specified by:
isObsoletein interfaceSchemaObject- Returns:
- true if inactive, false if active
-
setObsolete
public void setObsolete(boolean obsolete)
Sets the Obsolete flag.- Specified by:
setObsoletein interfaceSchemaObject- Parameters:
obsolete- The Obsolete flag state
-
getExtensions
public Map<String,List<String>> getExtensions()
- Specified by:
getExtensionsin interfaceSchemaObject- Returns:
- The SchemaObject extensions, as a Map of [extension, values]
-
hasExtension
public boolean hasExtension(String extension)
Check if a given extension is part of the SchemaObject. Extensions are case insensitive.- Specified by:
hasExtensionin interfaceSchemaObject- Parameters:
extension- The extension we are looking for.- Returns:
trueif the extension is present.
-
getExtension
public List<String> getExtension(String extension)
Get back the values associated with a given extension.- Specified by:
getExtensionin interfaceSchemaObject- Parameters:
extension- The extension we are looking for.- Returns:
- The list of values associated with the extension
-
addExtension
public void addExtension(String key, String... values)
Add an extension with its values- Specified by:
addExtensionin interfaceSchemaObject- Parameters:
key- The extension keyvalues- The associated values
-
addExtension
public void addExtension(String key, List<String> values)
Add an extension with its values- Specified by:
addExtensionin interfaceSchemaObject- Parameters:
key- The extension keyvalues- The associated values
-
setExtensions
public void setExtensions(Map<String,List<String>> extensions)
Add an extensions with their values. (Actually do a copy)- Specified by:
setExtensionsin interfaceSchemaObject- Parameters:
extensions- The extensions map
-
getObjectType
public SchemaObjectType getObjectType()
The SchemaObject type :- AttributeType
- DitCOntentRule
- DitStructureRule
- LdapComparator (specific to ADS)
- LdapSyntaxe
- MatchingRule
- MatchingRuleUse
- NameForm
- Normalizer (specific to ADS)
- ObjectClass
- SyntaxChecker (specific to ADS)
- Specified by:
getObjectTypein interfaceSchemaObject- Returns:
- the SchemaObject type
-
getSchemaName
public String getSchemaName()
Gets the name of the schema this SchemaObject is associated with.- Specified by:
getSchemaNamein interfaceSchemaObject- Returns:
- the name of the schema associated with this schemaObject
-
setSchemaName
public void setSchemaName(String schemaName)
Sets the name of the schema this SchemaObject is associated with.- Specified by:
setSchemaNamein interfaceSchemaObject- Parameters:
schemaName- the new schema name
-
equals
public boolean equals(Object o1)
- Specified by:
equalsin interfaceSchemaObject- Overrides:
equalsin classObject
-
compareOid
protected boolean compareOid(String oid1, String oid2)
Compare two oids, and return true if they are both null or equal.- Parameters:
oid1- the first OIDoid2- the second OID- Returns:
trueif both OIDs are null or equal
-
copy
public SchemaObject copy(SchemaObject original)
Copies the given schema object into this schema object.- Specified by:
copyin interfaceSchemaObject- Parameters:
original- the original SchemaObject- Returns:
- this
-
clear
public void clear()
Clear the current SchemaObject : remove all the references to other objects, and all the Maps.- Specified by:
clearin interfaceSchemaObject
-
lock
public final void lock()
Transform the SchemaObject to an immutable object TODO locked.- Specified by:
lockin interfaceSchemaObject
-
unlock
public void unlock()
Unlock the Schema Object and make it modifiable again.
-
computeHashCode
protected void computeHashCode()
Compute the hashcode, and store it in the 'h' variable
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfaceSchemaObject- Overrides:
hashCodein classObject
-
-