org.apache.directory.shared.ldap.schema
Class AbstractSchemaObject

java.lang.Object
  extended by org.apache.directory.shared.ldap.schema.AbstractSchemaObject
All Implemented Interfaces:
java.io.Serializable, SchemaObject
Direct Known Subclasses:
AttributeType, DITContentRule, DITStructureRule, LdapSyntax, LoadableSchemaObject, MatchingRule, MatchingRuleUse, NameForm, ObjectClass

public abstract class AbstractSchemaObject
extends java.lang.Object
implements SchemaObject

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

    Version:
    $Rev: 885381 $
    Author:
    Apache Directory Project
    See Also:
    Serialized Form

    Field Summary
    protected  java.lang.String description
              A short description of this SchemaObject
    protected  java.util.Map<java.lang.String,java.util.List<java.lang.String>> extensions
              A map containing the list of supported extensions
    protected  boolean isEnabled
              Whether or not this SchemaObject is enabled
    protected  boolean isObsolete
              Whether or not this SchemaObject is obsolete
    protected  boolean isReadOnly
              Whether or not this SchemaObject can be modified
    protected  boolean locked
              A locked to avoid modifications when set to true
    protected  java.util.List<java.lang.String> names
              The optional names for this SchemaObject
    protected  SchemaObjectType objectType
              The SchemaObjectType
    protected  java.lang.String oid
              The SchemaObject numeric OID
    protected  java.lang.String schemaName
              The name of the schema this object is associated with
    static long serialVersionUID
              The serialVersionUID
    protected  java.lang.String specification
              The SchemaObject specification
     
    Constructor Summary
    protected AbstractSchemaObject(SchemaObjectType objectType)
              Constructor used when a generic reusable SchemaObject is assigned an OID after being instantiated.
    protected AbstractSchemaObject(SchemaObjectType objectType, java.lang.String oid)
              A constructor for a SchemaObject instance.
     
    Method Summary
     void addExtension(java.lang.String key, java.util.List<java.lang.String> values)
              Add an extension with its values
     void addName(java.lang.String... names)
              Add a new name to the list of names for this SchemaObject.
     void addToRegistries(java.util.List<java.lang.Throwable> errors, Registries registries)
              Inject this SchemaObject to the given registries, updating the references to other SchemaObject
     void clear()
              Clear the current SchemaObject : remove all the references to other objects, and all the Maps.
    protected  boolean compareOid(java.lang.String oid1, java.lang.String oid2)
              Compare two oids, and return true if they are both null or equals
    abstract  SchemaObject copy()
              Copy the current SchemaObject on place
     SchemaObject copy(SchemaObject original)
              Copy a SchemaObject.
     boolean equals(java.lang.Object o1)
               
     java.lang.String getDescription()
              Gets a short description about this SchemaObject.
     java.util.Map<java.lang.String,java.util.List<java.lang.String>> getExtensions()
               
     java.lang.String getName()
              Gets the first name in the set of short names for this SchemaObject if any exists for it.
     java.util.List<java.lang.String> getNames()
              Gets short names for this SchemaObject if any exists for it, otherwise, returns an empty list.
     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)
     java.lang.String getOid()
              Gets usually what is the numeric object identifier assigned to this SchemaObject.
     java.lang.String getSchemaName()
              Gets the name of the schema this SchemaObject is associated with.
     java.lang.String getSpecification()
              Gets the SchemaObject specification.
     int hashCode()
               
     boolean isDisabled()
              Tells if this SchemaObject is disabled.
     boolean isEnabled()
              Tells if this SchemaObject is enabled.
     boolean isObsolete()
              Gets whether or not this SchemaObject has been inactivated.
     boolean isReadOnly()
              Tells if this SchemaObject is ReadOnly.
     void lock()
              Transform the SchemaObject to an immutable object TODO locked.
     void registerOid(SchemaObject schemaObject, Registries registries)
              Register the given SchemaObject into the given registries' globalOidRegistry
     void removeFromRegistries(java.util.List<java.lang.Throwable> errors, Registries registries)
              Remove this SchemaObject from the given registries, updating the references to other SchemaObject
     void setDescription(java.lang.String description)
              Sets the SchemaObject's description
     void setEnabled(boolean enabled)
              Sets the SchemaObject state, either enabled or disabled.
     void setExtensions(java.util.Map<java.lang.String,java.util.List<java.lang.String>> extensions)
              Add an extensions with their values.
     void setNames(java.util.List<java.lang.String> names)
              Sets the list of names for this SchemaObject.
     void setNames(java.lang.String... names)
              Sets the list of names for this SchemaObject.
     void setObsolete(boolean obsolete)
              Sets the Obsolete flag.
     void setOid(java.lang.String oid)
              A special method used when renaming an SchemaObject: we may have to change it's OID
     void setReadOnly(boolean isReadOnly)
              Sets the SchemaObject readOnly flag
     void setRegistries(Registries registries)
              Inject the Registries into the SchemaObject
     void setSchemaName(java.lang.String schemaName)
              Sets the name of the schema this SchemaObject is associated with.
     void setSpecification(java.lang.String specification)
              Sets the SchemaObject's specification
     
    Methods inherited from class java.lang.Object
    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    serialVersionUID

    public static final long serialVersionUID
    The serialVersionUID

    See Also:
    Constant Field Values

    oid

    protected java.lang.String oid
    The SchemaObject numeric OID


    names

    protected java.util.List<java.lang.String> names
    The optional names for this SchemaObject


    isEnabled

    protected boolean isEnabled
    Whether or not this SchemaObject is enabled


    isReadOnly

    protected boolean isReadOnly
    Whether or not this SchemaObject can be modified


    isObsolete

    protected boolean isObsolete
    Whether or not this SchemaObject is obsolete


    description

    protected java.lang.String description
    A short description of this SchemaObject


    specification

    protected java.lang.String specification
    The SchemaObject specification


    schemaName

    protected java.lang.String schemaName
    The name of the schema this object is associated with


    objectType

    protected SchemaObjectType objectType
    The SchemaObjectType


    extensions

    protected java.util.Map<java.lang.String,java.util.List<java.lang.String>> extensions
    A map containing the list of supported extensions


    locked

    protected volatile boolean locked
    A locked to avoid modifications when set to true

    Constructor Detail

    AbstractSchemaObject

    protected AbstractSchemaObject(SchemaObjectType objectType,
                                   java.lang.String oid)
    A constructor for a SchemaObject instance. It must be invoked by the inherited class.

    Parameters:
    objectType - The SchemaObjectType to create

    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 java.lang.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(java.lang.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 java.util.List<java.lang.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 java.lang.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

    addToRegistries

    public void addToRegistries(java.util.List<java.lang.Throwable> errors,
                                Registries registries)
                         throws LdapException
    Inject this SchemaObject to the given registries, updating the references to other SchemaObject

    Specified by:
    addToRegistries in interface SchemaObject
    Parameters:
    errors - The errors we got
    registries - The Registries
    Throws:
    LdapException

    removeFromRegistries

    public void removeFromRegistries(java.util.List<java.lang.Throwable> errors,
                                     Registries registries)
                              throws LdapException
    Remove this SchemaObject from the given registries, updating the references to other SchemaObject

    Specified by:
    removeFromRegistries in interface SchemaObject
    Parameters:
    errors - The errors we got
    registries - The Registries
    Throws:
    LdapException

    setRegistries

    public void setRegistries(Registries registries)
    Inject the Registries into the SchemaObject

    Specified by:
    setRegistries in interface SchemaObject
    Parameters:
    registries - The Registries

    addName

    public void addName(java.lang.String... names)
    Add a new name to the list of names for this SchemaObject. The name is lowercased and trimmed.

    Specified by:
    addName in interface SchemaObject
    Parameters:
    names - The names to add

    setNames

    public void setNames(java.util.List<java.lang.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(java.lang.String... names)
    Sets the list of names for this SchemaObject. The names are lowercased and trimmed.

    Parameters:
    names - The list of names.

    getDescription

    public java.lang.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(java.lang.String description)
    Sets the SchemaObject's description

    Specified by:
    setDescription in interface SchemaObject
    Parameters:
    description - The SchemaObject's description

    getSpecification

    public java.lang.String getSpecification()
    Gets the SchemaObject specification.

    Specified by:
    getSpecification in interface SchemaObject
    Returns:
    the SchemaObject specification

    setSpecification

    public void setSpecification(java.lang.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
    Parameters:
    schemaEnabled - the associated schema status
    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

    isReadOnly

    public boolean isReadOnly()
    Tells if this SchemaObject is ReadOnly.

    Specified by:
    isReadOnly in interface SchemaObject
    Returns:
    true if the SchemaObject is not modifiable

    setReadOnly

    public void setReadOnly(boolean isReadOnly)
    Sets the SchemaObject readOnly flag

    Specified by:
    setReadOnly in interface SchemaObject
    Parameters:
    enabled - The current SchemaObject ReadOnly status

    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 java.util.Map<java.lang.String,java.util.List<java.lang.String>> getExtensions()
    Specified by:
    getExtensions in interface SchemaObject
    Returns:
    The SchemaObject extensions, as a Map of [extension, values]

    addExtension

    public void addExtension(java.lang.String key,
                             java.util.List<java.lang.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(java.util.Map<java.lang.String,java.util.List<java.lang.String>> extensions)
    Add an extensions with their values. (Actually do a copy)

    Specified by:
    setExtensions in interface SchemaObject
    Parameters:
    key - The extension key
    values - The associated values

    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 java.lang.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(java.lang.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

    hashCode

    public int hashCode()
    Specified by:
    hashCode in interface SchemaObject
    Overrides:
    hashCode in class java.lang.Object
    See Also:
    Object.hashCode()

    equals

    public boolean equals(java.lang.Object o1)
    Specified by:
    equals in interface SchemaObject
    Overrides:
    equals in class java.lang.Object
    See Also:
    Object.equals(Object)

    registerOid

    public void registerOid(SchemaObject schemaObject,
                            Registries registries)
                     throws LdapException
    Register the given SchemaObject into the given registries' globalOidRegistry

    Specified by:
    registerOid in interface SchemaObject
    Parameters:
    schemaObject - the SchemaObject we want to register
    registries - The registries in which we want it to be stored
    Throws:
    LdapException - If the OID is invalid

    copy

    public abstract SchemaObject copy()
    Copy the current SchemaObject on place

    Specified by:
    copy in interface SchemaObject
    Returns:
    The copied SchemaObject

    compareOid

    protected boolean compareOid(java.lang.String oid1,
                                 java.lang.String oid2)
    Compare two oids, and return true if they are both null or equals


    copy

    public SchemaObject copy(SchemaObject original)
    Copy a SchemaObject.

    Specified by:
    copy in interface SchemaObject
    Returns:
    A copy of the current SchemaObject

    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


    Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.