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:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    A short description of this SchemaObject
    protected Map<String, List<String>>
    A map containing the list of supported extensions
    protected int
    The hashcode for this schemaObject
    protected boolean
    Whether or not this SchemaObject is enabled
    protected boolean
    Whether or not this SchemaObject is obsolete
    protected boolean
    A locked to avoid modifications when set to true
    protected List<String>
    The optional names for this SchemaObject
    The SchemaObjectType
    protected String
    The SchemaObject numeric OID
    protected String
    The name of the schema this object is associated with
    protected String
    The SchemaObject specification
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Constructor used when a generic reusable SchemaObject is assigned an OID after being instantiated.
    protected
    A constructor for a SchemaObject instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addExtension(String key, String... values)
    Add an extension with its values
    void
    addExtension(String key, List<String> values)
    Add an extension with its values
    void
    addName(String... namesToAdd)
    Add a new name to the list of names for this SchemaObject.
    void
    Clear the current SchemaObject : remove all the references to other objects, and all the Maps.
    protected boolean
    compareOid(String oid1, String oid2)
    Compare two oids, and return true if they are both null or equal.
    copy(SchemaObject original)
    Copies the given schema object into this schema object.
    boolean
    Gets a short description about this SchemaObject.
    getExtension(String extension)
    Get back the values associated with a given extension.
    Get the schemaObjct extensions
    Gets the first name in the set of short names for this SchemaObject if any exists for it.
    Gets short names for this SchemaObject if any exists for it, otherwise, returns an empty list.
    The SchemaObject type : AttributeType DitCOntentRule DitStructureRule LdapComparator (specific to ADS) LdapSyntaxe MatchingRule MatchingRuleUse NameForm Normalizer (specific to ADS) ObjectClass SyntaxChecker (specific to ADS)
    Gets usually what is the numeric object identifier assigned to this SchemaObject.
    Gets the name of the schema this SchemaObject is associated with.
    Gets the SchemaObject specification.
    boolean
    hasExtension(String extension)
    Check if a given extension is part of the SchemaObject.
    int
    boolean
    Tells if this SchemaObject is disabled.
    boolean
    Tells if this SchemaObject is enabled.
    boolean
    Gets whether or not this SchemaObject has been inactivated.
    final void
    Transform the SchemaObject to an immutable object TODO locked.
    protected void
    Compute the hashcode, and store it in the 'h' variable
    protected void
    Compute the hashcode, and store it in the 'h' variable
    void
    setDescription(String description)
    Sets the SchemaObject's description
    void
    setEnabled(boolean enabled)
    Sets the SchemaObject state, either enabled or disabled.
    void
    Add an extensions with their values.
    void
    setNames(String... names)
    Sets the list of names for this SchemaObject.
    void
    Sets the list of names for this SchemaObject.
    void
    setObsolete(boolean obsolete)
    Sets the Obsolete flag.
    void
    A special method used when renaming an SchemaObject: we may have to change it's OID
    void
    setSchemaName(String schemaName)
    Sets the name of the schema this SchemaObject is associated with.
    void
    setSpecification(String specification)
    Sets the SchemaObject's specification
    void
    Unlock the Schema Object and make it modifiable again.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface SchemaObject

    copy
  • Field Details

    • oid

      protected String oid
      The SchemaObject numeric OID
    • names

      protected transient List<String> names
      The optional names for this SchemaObject
    • 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 Details

    • 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 create
      oid - 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 Details

    • 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:
      getOid in interface SchemaObject
      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:
      setOid in interface SchemaObject
      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:
      getNames in interface SchemaObject
      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:
      getName in interface SchemaObject
      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:
      addName in interface SchemaObject
      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:
      setNames in interface SchemaObject
      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:
      getDescription in interface SchemaObject
      Returns:
      a short description about this SchemaObject
    • setDescription

      public void setDescription(String description)
      Sets the SchemaObject's description
      Specified by:
      setDescription in interface SchemaObject
      Parameters:
      description - The SchemaObject's description
    • getSpecification

      public String getSpecification()
      Gets the SchemaObject specification.
      Specified by:
      getSpecification in interface SchemaObject
      Returns:
      the SchemaObject specification
    • setSpecification

      public void setSpecification(String specification)
      Sets the SchemaObject's specification
      Specified by:
      setSpecification in interface SchemaObject
      Parameters:
      specification - The SchemaObject's specification
    • isEnabled

      public boolean isEnabled()
      Tells if this SchemaObject is enabled.
      Specified by:
      isEnabled in interface SchemaObject
      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:
      isDisabled in interface SchemaObject
      Returns:
      true if the SchemaObject is disabled
    • setEnabled

      public void setEnabled(boolean enabled)
      Sets the SchemaObject state, either enabled or disabled.
      Specified by:
      setEnabled in interface SchemaObject
      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:
      isObsolete in interface SchemaObject
      Returns:
      true if inactive, false if active
    • setObsolete

      public void setObsolete(boolean obsolete)
      Sets the Obsolete flag.
      Specified by:
      setObsolete in interface SchemaObject
      Parameters:
      obsolete - The Obsolete flag state
    • getExtensions

      public Map<String, List<String>> getExtensions()
      Get the schemaObjct extensions
      Specified by:
      getExtensions in interface SchemaObject
      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:
      hasExtension in interface SchemaObject
      Parameters:
      extension - The extension we are looking for.
      Returns:
      true if the extension is present.
    • getExtension

      public List<String> getExtension(String extension)
      Get back the values associated with a given extension.
      Specified by:
      getExtension in interface SchemaObject
      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:
      addExtension in interface SchemaObject
      Parameters:
      key - The extension key
      values - The associated values
    • addExtension

      public void addExtension(String key, List<String> values)
      Add an extension with its values
      Specified by:
      addExtension in interface SchemaObject
      Parameters:
      key - The extension key
      values - The associated values
    • setExtensions

      public void setExtensions(Map<String, List<String>> extensions)
      Add an extensions with their values. (Actually do a copy)
      Specified by:
      setExtensions in interface SchemaObject
      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:
      getObjectType in interface SchemaObject
      Returns:
      the SchemaObject type
    • getSchemaName

      public String getSchemaName()
      Gets the name of the schema this SchemaObject is associated with.
      Specified by:
      getSchemaName in interface SchemaObject
      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:
      setSchemaName in interface SchemaObject
      Parameters:
      schemaName - the new schema name
    • equals

      public boolean equals(Object o1)
      Specified by:
      equals in interface SchemaObject
      Overrides:
      equals in class Object
    • 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 OID
      oid2 - the second OID
      Returns:
      true if both OIDs are null or equal
    • copy

      public SchemaObject copy(SchemaObject original)
      Copies the given schema object into this schema object.
      Specified by:
      copy in interface SchemaObject
      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:
      clear in interface SchemaObject
    • lock

      public final void lock()
      Transform the SchemaObject to an immutable object TODO locked.
      Specified by:
      lock in interface SchemaObject
    • unlock

      public void unlock()
      Unlock the Schema Object and make it modifiable again.
    • rehash

      protected void rehash()
      Compute the hashcode, and store it in the 'h' variable
    • rehashBase

      protected void rehashBase()
      Compute the hashcode, and store it in the 'h' variable
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface SchemaObject
      Overrides:
      hashCode in class Object