org.opends.server.types
Class CommonSchemaElements

java.lang.Object
  extended by org.opends.server.types.CommonSchemaElements
Direct Known Subclasses:
AttributeType, ObjectClass

@PublicAPI(stability=VOLATILE,
           mayInstantiate=false,
           mayExtend=false,
           mayInvoke=true)
public abstract class CommonSchemaElements
extends java.lang.Object

An abstract base class for LDAP schema definitions which contain an OID, optional names, description, an obsolete flag, and an optional set of extra properties.

This class defines common properties and behaviour of the various types of schema definitions (e.g. object class definitions, and attribute type definitions).

Any methods which accesses the set of names associated with this definition, will retrieve the primary name as the first name, regardless of whether or not it was contained in the original set of names passed to the constructor.

Where ordered sets of names, or extra properties are provided, the ordering will be preserved when the associated fields are accessed via their getters or via the toString() methods.

Note that these schema elements are not completely immutable, as the set of extra properties for the schema element may be altered after the element is created. Among other things, this allows the associated schema file to be edited so that an element created over protocol may be associated with a particular schema file.


Constructor Summary
protected CommonSchemaElements(java.lang.String primaryName, java.util.Collection<java.lang.String> names, java.lang.String oid, java.lang.String description, boolean isObsolete, java.util.Map<java.lang.String,java.util.List<java.lang.String>> extraProperties)
          Creates a new definition with the provided information.
 
Method Summary
 boolean equals(java.lang.Object o)
          Indicates whether the provided object is equal to this attribute type.
 java.lang.String getDescription()
          Retrieves the description for this schema definition.
 java.lang.Iterable<java.lang.String> getExtraProperty(java.lang.String name)
          Retrieves an iterable over the value(s) of the specified "extra" property for this schema definition.
 java.lang.Iterable<java.lang.String> getExtraPropertyNames()
          Retrieves an iterable over the names of "extra" properties associated with this schema definition.
 java.lang.String getNameOrOID()
          Retrieves the name or OID for this schema definition.
 java.lang.Iterable<java.lang.String> getNormalizedNames()
          Retrieves an iterable over the set of normalized names that may be used to reference this schema definition.
 java.lang.String getNormalizedPrimaryName()
          Retrieve the normalized primary name for this schema definition.
 java.lang.String getOID()
          Retrieves the OID for this schema definition.
 java.lang.String getPrimaryName()
          Retrieves the primary name for this schema definition.
 java.lang.String getSchemaFile()
          Retrieves the name of the schema file that contains the definition for this schema definition.
 java.lang.Iterable<java.lang.String> getUserDefinedNames()
          Retrieves an iterable over the set of user-defined names that may be used to reference this schema definition.
 int hashCode()
          Retrieves the hash code for this schema definition.
 boolean hasName(java.lang.String lowerName)
          Indicates whether this schema definition has the specified name.
 boolean hasNameOrOID(java.lang.String lowerValue)
          Indicates whether this schema definition has the specified name or OID.
 boolean isObsolete()
          Indicates whether this schema definition is declared "obsolete".
 void setExtraProperty(java.lang.String name, java.util.List<java.lang.String> values)
          Sets the values for an "extra" property for this schema element.
 void setExtraProperty(java.lang.String name, java.lang.String value)
          Sets the value for an "extra" property for this schema element.
 void setSchemaFile(java.lang.String schemaFile)
          Specifies the name of the schema file that contains the definition for this schema element.
 java.lang.String toString()
          Retrieves the string representation of this schema definition in the form specified in RFC 2252.
 void toString(java.lang.StringBuilder buffer, boolean includeFileElement)
          Appends a string representation of this schema definition in the form specified in RFC 2252 to the provided buffer.
protected abstract  void toStringContent(java.lang.StringBuilder buffer)
          Appends a string representation of this schema definition's non-generic properties to the provided buffer.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CommonSchemaElements

protected CommonSchemaElements(java.lang.String primaryName,
                               java.util.Collection<java.lang.String> names,
                               java.lang.String oid,
                               java.lang.String description,
                               boolean isObsolete,
                               java.util.Map<java.lang.String,java.util.List<java.lang.String>> extraProperties)
                        throws java.lang.NullPointerException
Creates a new definition with the provided information.

If no primaryName is specified, but a set of names is specified, then the first name retrieved from the set of names will be used as the primary name.

Parameters:
primaryName - The primary name for this definition, or null if there is no primary name.
names - The full set of names for this definition, or null if there are no names.
oid - The OID for this definition (must not be null).
description - The description for the definition, or null if there is no description.
isObsolete - Indicates whether this definition is declared "obsolete".
extraProperties - A set of extra properties for this definition, or null if there are no extra properties.
Throws:
java.lang.NullPointerException - If the provided OID was null.
Method Detail

getPrimaryName

public final java.lang.String getPrimaryName()
Retrieves the primary name for this schema definition.

Returns:
The primary name for this schema definition, or null if there is no primary name.

getNormalizedPrimaryName

public final java.lang.String getNormalizedPrimaryName()
Retrieve the normalized primary name for this schema definition.

Returns:
Returns the normalized primary name for this attribute type, or null if there is no primary name.

getNormalizedNames

public final java.lang.Iterable<java.lang.String> getNormalizedNames()
Retrieves an iterable over the set of normalized names that may be used to reference this schema definition. The normalized form of an attribute name is defined as the user-defined name converted to lower-case.

Returns:
Returns an iterable over the set of normalized names that may be used to reference this schema definition.

getUserDefinedNames

public final java.lang.Iterable<java.lang.String> getUserDefinedNames()
Retrieves an iterable over the set of user-defined names that may be used to reference this schema definition.

Returns:
Returns an iterable over the set of user-defined names that may be used to reference this schema definition.

hasName

public final boolean hasName(java.lang.String lowerName)
Indicates whether this schema definition has the specified name.

Parameters:
lowerName - The lowercase name for which to make the determination.
Returns:
true if the specified name is assigned to this schema definition, or false if not.

getOID

public final java.lang.String getOID()
Retrieves the OID for this schema definition.

Returns:
The OID for this schema definition.

getNameOrOID

public final java.lang.String getNameOrOID()
Retrieves the name or OID for this schema definition. If it has one or more names, then the primary name will be returned. If it does not have any names, then the OID will be returned.

Returns:
The name or OID for this schema definition.

hasNameOrOID

public final boolean hasNameOrOID(java.lang.String lowerValue)
Indicates whether this schema definition has the specified name or OID.

Parameters:
lowerValue - The lowercase value for which to make the determination.
Returns:
true if the provided value matches the OID or one of the names assigned to this schema definition, or false if not.

getSchemaFile

public final java.lang.String getSchemaFile()
Retrieves the name of the schema file that contains the definition for this schema definition.

Returns:
The name of the schema file that contains the definition for this schema definition, or null if it is not known or if it is not stored in any schema file.

setSchemaFile

public final void setSchemaFile(java.lang.String schemaFile)
Specifies the name of the schema file that contains the definition for this schema element. If a schema file is already defined in the set of extra properties, then it will be overwritten. If the provided schema file value is null, then any existing schema file definition will be removed.

Parameters:
schemaFile - The name of the schema file that contains the definition for this schema element.

getDescription

public final java.lang.String getDescription()
Retrieves the description for this schema definition.

Returns:
The description for this schema definition, or null if there is no description.

isObsolete

public final boolean isObsolete()
Indicates whether this schema definition is declared "obsolete".

Returns:
true if this schema definition is declared "obsolete", or false if not.

getExtraPropertyNames

public final java.lang.Iterable<java.lang.String> getExtraPropertyNames()
Retrieves an iterable over the names of "extra" properties associated with this schema definition.

Returns:
Returns an iterable over the names of "extra" properties associated with this schema definition.

getExtraProperty

public final java.lang.Iterable<java.lang.String> getExtraProperty(java.lang.String name)
Retrieves an iterable over the value(s) of the specified "extra" property for this schema definition.

Parameters:
name - The name of the "extra" property for which to retrieve the value(s).
Returns:
Returns an iterable over the value(s) of the specified "extra" property for this schema definition, or null if no such property is defined.

setExtraProperty

public final void setExtraProperty(java.lang.String name,
                                   java.lang.String value)
Sets the value for an "extra" property for this schema element. If a property already exists with the specified name, then it will be overwritten. If the value is null, then any existing property with the given name will be removed.

Parameters:
name - The name for the "extra" property. It must not be null.
value - The value for the "extra" property. If it is null, then any existing definition will be removed.

setExtraProperty

public final void setExtraProperty(java.lang.String name,
                                   java.util.List<java.lang.String> values)
Sets the values for an "extra" property for this schema element. If a property already exists with the specified name, then it will be overwritten. If the set of values is null or empty, then any existing property with the given name will be removed.

Parameters:
name - The name for the "extra" property. It must not be null.
values - The set of values for the "extra" property. If it is null or empty, then any existing definition will be removed.

equals

public final boolean equals(java.lang.Object o)
Indicates whether the provided object is equal to this attribute type. The object will be considered equal if it is an attribute type with the same OID as the current type.

Overrides:
equals in class java.lang.Object
Parameters:
o - The object for which to make the determination.
Returns:
true if the provided object is equal to this schema definition, or false if not.

hashCode

public final int hashCode()
Retrieves the hash code for this schema definition. It will be based on the sum of the bytes of the OID.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code for this schema definition.

toString

public final java.lang.String toString()
Retrieves the string representation of this schema definition in the form specified in RFC 2252.

Overrides:
toString in class java.lang.Object
Returns:
The string representation of this schema definition in the form specified in RFC 2252.

toString

public final void toString(java.lang.StringBuilder buffer,
                           boolean includeFileElement)
Appends a string representation of this schema definition in the form specified in RFC 2252 to the provided buffer.

Parameters:
buffer - The buffer to which the information should be appended.
includeFileElement - Indicates whether to include an "extra" property that specifies the path to the schema file from which this schema definition was loaded.

toStringContent

protected abstract void toStringContent(java.lang.StringBuilder buffer)
Appends a string representation of this schema definition's non-generic properties to the provided buffer.

Parameters:
buffer - The buffer to which the information should be appended.