org.opends.server.types
Class NameForm

java.lang.Object
  extended by org.opends.server.types.NameForm
All Implemented Interfaces:
SchemaFileElement

@PublicAPI(stability=UNCOMMITTED,
           mayInstantiate=false,
           mayExtend=false,
           mayInvoke=true)
public final class NameForm
extends java.lang.Object
implements SchemaFileElement

This class defines a data structure for storing and interacting with a name form, which defines the attribute type(s) that must and/or may be used in the RDN of an entry with a given structural objectclass.


Constructor Summary
NameForm(java.lang.String definition, java.util.Map<java.lang.String,java.lang.String> names, java.lang.String oid, java.lang.String description, boolean isObsolete, ObjectClass structuralClass, java.util.Set<AttributeType> requiredAttributes, java.util.Set<AttributeType> optionalAttributes, java.util.Map<java.lang.String,java.util.List<java.lang.String>> extraProperties)
          Creates a new name form definition with the provided information.
 
Method Summary
 boolean equals(java.lang.Object o)
          Indicates whether the provided object is equal to this name form.
 java.lang.String getDefinition()
          Retrieves the definition string used to create this name form.
 java.lang.String getDescription()
          Retrieves the description for this name form.
 java.util.Map<java.lang.String,java.util.List<java.lang.String>> getExtraProperties()
          Retrieves a mapping between the names of any extra non-standard properties that may be associated with this name form and the value for that property.
 java.util.List<java.lang.String> getExtraProperty(java.lang.String propertyName)
          Retrieves the value of the specified "extra" property for this name form.
 java.lang.String getNameOrOID()
          Retrieves the name or OID that should be used to reference this name form.
 java.util.Map<java.lang.String,java.lang.String> getNames()
          Retrieves the set of names that may be used to reference this name form.
 java.lang.String getOID()
          Retrieves the OID for this name form.
 java.util.Set<AttributeType> getOptionalAttributes()
          Retrieves the set of optional attributes for this name form.
 java.util.Set<AttributeType> getRequiredAttributes()
          Retrieves the set of required attributes for this name form.
 java.lang.String getSchemaFile()
          Retrieves the path to the schema file that contains the definition for this name form.
 ObjectClass getStructuralClass()
          Retrieves the reference to the structural objectclass for this name form.
 int hashCode()
          Retrieves the hash code for this name form.
 boolean hasName(java.lang.String lowerName)
          Indicates whether the provided lowercase name may be used to reference this name form.
 boolean hasNameOrOID(java.lang.String lowerValue)
          Indicates whether the provided lowercase value is equal to the OID or any of the names that may be used to reference this name form.
 boolean isObsolete()
          Indicates whether this name form is declared "obsolete".
 boolean isOptional(AttributeType attributeType)
          Indicates whether the provided attribute type is included in the optional attribute list for this name form.
 boolean isRequired(AttributeType attributeType)
          Indicates whether the provided attribute type is included in the required attribute list for this name form.
 boolean isRequiredOrOptional(AttributeType attributeType)
          Indicates whether the provided attribute type is in the list of required or optional attributes for this name form.
 NameForm recreateFromDefinition()
          Creates a new instance of this name form based on the definition string.
 void setExtraProperty(java.lang.String name, java.util.List<java.lang.String> values)
          Specifies the provided "extra" property for this name form.
 void setExtraProperty(java.lang.String name, java.lang.String value)
          Specifies the provided "extra" property for this name form.
 void setSchemaFile(java.lang.String schemaFile)
          Specifies the path to the schema file that contains the definition for this name form.
 java.lang.String toString()
          Retrieves the string representation of this name form in the form specified in RFC 2252.
 void toString(java.lang.StringBuilder buffer, boolean includeFileElement)
          Appends a string representation of this name form in the form specified in RFC 2252 to the provided buffer.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NameForm

public NameForm(java.lang.String definition,
                java.util.Map<java.lang.String,java.lang.String> names,
                java.lang.String oid,
                java.lang.String description,
                boolean isObsolete,
                ObjectClass structuralClass,
                java.util.Set<AttributeType> requiredAttributes,
                java.util.Set<AttributeType> optionalAttributes,
                java.util.Map<java.lang.String,java.util.List<java.lang.String>> extraProperties)
Creates a new name form definition with the provided information.

Parameters:
definition - The definition string used to create this name form. It must not be null.
names - The set of names that may be used to reference this name form.
oid - The OID for this name form. It must not be null.
description - The description for this name form.
isObsolete - Indicates whether this name form is declared "obsolete".
structuralClass - The structural objectclass with which this name form is associated. It must not be null.
requiredAttributes - The set of required attribute types for this name form.
optionalAttributes - The set of optional attribute types for this name form.
extraProperties - A set of extra properties for this name form.
Method Detail

getDefinition

public java.lang.String getDefinition()
Retrieves the definition string used to create this name form.

Specified by:
getDefinition in interface SchemaFileElement
Returns:
The definition string used to create this name form.

recreateFromDefinition

public NameForm recreateFromDefinition()
                                throws DirectoryException
Creates a new instance of this name form based on the definition string. It will also preserve other state information associated with this name form that is not included in the definition string (e.g., the name of the schema file with which it is associated).

Specified by:
recreateFromDefinition in interface SchemaFileElement
Returns:
The new instance of this name form based on the definition string.
Throws:
DirectoryException - If a problem occurs while attempting to create a new name form instance from the definition string.

getNames

public java.util.Map<java.lang.String,java.lang.String> getNames()
Retrieves the set of names that may be used to reference this name form. The returned object will be a mapping between each name in all lowercase characters and that name in a user-defined form (which may include mixed capitalization).

Returns:
The set of names that may be used to reference this name form.

hasName

public boolean hasName(java.lang.String lowerName)
Indicates whether the provided lowercase name may be used to reference this name form.

Parameters:
lowerName - The name for which to make the determination, in all lowercase characters.
Returns:
true if the provided lowercase name may be used to reference this name form, or false if not.

getOID

public java.lang.String getOID()
Retrieves the OID for this name form.

Returns:
The OID for this name form.

getNameOrOID

public java.lang.String getNameOrOID()
Retrieves the name or OID that should be used to reference this name form. If at least one name is defined, then the first will be returned. Otherwise, the OID will be returned.

Returns:
The name or OID that should be used to reference this name form.

hasNameOrOID

public boolean hasNameOrOID(java.lang.String lowerValue)
Indicates whether the provided lowercase value is equal to the OID or any of the names that may be used to reference this name form.

Parameters:
lowerValue - The value, in all lowercase characters, that may be used to make the determination.
Returns:
true if the provided lowercase value is one of the names or the OID of this name form, or false if it is not.

getSchemaFile

public java.lang.String getSchemaFile()
Retrieves the path to the schema file that contains the definition for this name form.

Specified by:
getSchemaFile in interface SchemaFileElement
Returns:
The path to the schema file that contains the definition for this name form, or null if it is not known or if it is not stored in any schema file.

setSchemaFile

public void setSchemaFile(java.lang.String schemaFile)
Specifies the path to the schema file that contains the definition for this name form.

Specified by:
setSchemaFile in interface SchemaFileElement
Parameters:
schemaFile - The path to the schema file that contains the definition for this name form.

getDescription

public java.lang.String getDescription()
Retrieves the description for this name form.

Returns:
The description for this name form, or true if there is none.

getStructuralClass

public ObjectClass getStructuralClass()
Retrieves the reference to the structural objectclass for this name form.

Returns:
The reference to the structural objectclass for this name form.

getRequiredAttributes

public java.util.Set<AttributeType> getRequiredAttributes()
Retrieves the set of required attributes for this name form.

Returns:
The set of required attributes for this name form.

isRequired

public boolean isRequired(AttributeType attributeType)
Indicates whether the provided attribute type is included in the required attribute list for this name form.

Parameters:
attributeType - The attribute type for which to make the determination.
Returns:
true if the provided attribute type is required by this name form, or false if not.

getOptionalAttributes

public java.util.Set<AttributeType> getOptionalAttributes()
Retrieves the set of optional attributes for this name form.

Returns:
The set of optional attributes for this name form.

isOptional

public boolean isOptional(AttributeType attributeType)
Indicates whether the provided attribute type is included in the optional attribute list for this name form.

Parameters:
attributeType - The attribute type for which to make the determination.
Returns:
true if the provided attribute type is optional for this name form, or false if not.

isRequiredOrOptional

public boolean isRequiredOrOptional(AttributeType attributeType)
Indicates whether the provided attribute type is in the list of required or optional attributes for this name form.

Parameters:
attributeType - The attribute type for which to make the determination.
Returns:
true if the provided attribute type is required or optional for this name form, or false if it is not.

isObsolete

public boolean isObsolete()
Indicates whether this name form is declared "obsolete".

Returns:
true if this name form is declared "obsolete", or false if it is not.

getExtraProperties

public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getExtraProperties()
Retrieves a mapping between the names of any extra non-standard properties that may be associated with this name form and the value for that property.

Returns:
A mapping between the names of any extra non-standard properties that may be associated with this name form and the value for that property.

getExtraProperty

public java.util.List<java.lang.String> getExtraProperty(java.lang.String propertyName)
Retrieves the value of the specified "extra" property for this name form.

Parameters:
propertyName - The name of the "extra" property for which to retrieve the value.
Returns:
The value of the specified "extra" property for this name form, or null if no such property is defined.

setExtraProperty

public void setExtraProperty(java.lang.String name,
                             java.lang.String value)
Specifies the provided "extra" property for this name form.

Parameters:
name - The name for the "extra" property. It must not be null.
value - The value for the "extra" property, or null if the property is to be removed.

setExtraProperty

public void setExtraProperty(java.lang.String name,
                             java.util.List<java.lang.String> values)
Specifies the provided "extra" property for this name form.

Parameters:
name - The name for the "extra" property. It must not be null.
values - The set of value for the "extra" property, or null if the property is to be removed.

equals

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

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 name form, or true if not.

hashCode

public int hashCode()
Retrieves the hash code for this name form. 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 name form.

toString

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

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

toString

public void toString(java.lang.StringBuilder buffer,
                     boolean includeFileElement)
Appends a string representation of this name form 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 name form was loaded.