org.opends.server.types
Class AttributeType

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

@PublicAPI(stability=UNCOMMITTED,
           mayInstantiate=false,
           mayExtend=false,
           mayInvoke=true)
public final class AttributeType
extends CommonSchemaElements
implements SchemaFileElement

This class defines a data structure for storing and interacting with an attribute type, which contains information about the format of an attribute and the syntax and matching rules that should be used when interacting with it.

Any methods which accesses the set of names associated with this attribute type, 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 CommonSchemaElements.toString() methods.


Constructor Summary
AttributeType(java.lang.String definition, java.lang.String primaryName, java.util.Collection<java.lang.String> typeNames, java.lang.String oid, java.lang.String description, AttributeType superiorType, AttributeSyntax syntax, ApproximateMatchingRule approximateMatchingRule, EqualityMatchingRule equalityMatchingRule, OrderingMatchingRule orderingMatchingRule, SubstringMatchingRule substringMatchingRule, AttributeUsage attributeUsage, boolean isCollective, boolean isNoUserModification, boolean isObsolete, boolean isSingleValue, java.util.Map<java.lang.String,java.util.List<java.lang.String>> extraProperties)
          Creates a new attribute type with the provided information.
AttributeType(java.lang.String definition, java.lang.String primaryName, java.util.Collection<java.lang.String> typeNames, java.lang.String oid, java.lang.String description, AttributeType superiorType, AttributeSyntax syntax, AttributeUsage attributeUsage, boolean isCollective, boolean isNoUserModification, boolean isObsolete, boolean isSingleValue)
          Creates a new attribute type with the provided information.
 
Method Summary
 int generateHashCode(AttributeValue value)
          Generates a hash code for the specified attribute value.
 ApproximateMatchingRule getApproximateMatchingRule()
          Retrieves the matching rule that should be used for approximate matching with this attribute type.
 java.lang.String getDefinition()
          Retrieves the definition string used to create this attribute type.
 java.lang.String getDefinitionWithFileName()
          Retrieves the definition string used to create this attribute type and including the X-SCHEMA-FILE extension.
 EqualityMatchingRule getEqualityMatchingRule()
          Retrieves the matching rule that should be used for equality matching with this attribute type.
 OrderingMatchingRule getOrderingMatchingRule()
          Retrieves the matching rule that should be used for ordering with this attribute type.
 SubstringMatchingRule getSubstringMatchingRule()
          Retrieves the matching rule that should be used for substring matching with this attribute type.
 AttributeType getSuperiorType()
          Retrieves the superior type for this attribute type.
 AttributeSyntax getSyntax()
          Retrieves the syntax for this attribute type.
 java.lang.String getSyntaxOID()
          Retrieves the OID for this syntax associated with this attribute type.
 AttributeUsage getUsage()
          Retrieves the usage indicator for this attribute type.
 boolean isCollective()
          Indicates whether this attribute type is declared "collective".
 boolean isNoUserModification()
          Indicates whether this attribute type is declared "no-user-modification".
 boolean isObjectClassType()
          Indicates whether this attribute type represents the "objectclass" attribute.
 boolean isOperational()
          Indicates whether this is an operational attribute.
 boolean isSingleValue()
          Indicates whether this attribute type is declared "single-value".
 ByteString normalize(ByteString value)
          Attempts to normalize the provided value using the equality matching rule associated with this attribute type.
 AttributeType recreateFromDefinition()
          Creates a new instance of this attribute type based on the definition string.
protected  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 org.opends.server.types.CommonSchemaElements
equals, getDescription, getExtraProperty, getExtraPropertyNames, getNameOrOID, getNormalizedNames, getNormalizedPrimaryName, getOID, getPrimaryName, getSchemaFile, getUserDefinedNames, hashCode, hasName, hasNameOrOID, isObsolete, setExtraProperty, setExtraProperty, setSchemaFile, toString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opends.server.types.SchemaFileElement
getSchemaFile, setSchemaFile
 

Constructor Detail

AttributeType

public AttributeType(java.lang.String definition,
                     java.lang.String primaryName,
                     java.util.Collection<java.lang.String> typeNames,
                     java.lang.String oid,
                     java.lang.String description,
                     AttributeType superiorType,
                     AttributeSyntax syntax,
                     AttributeUsage attributeUsage,
                     boolean isCollective,
                     boolean isNoUserModification,
                     boolean isObsolete,
                     boolean isSingleValue)
Creates a new attribute type 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:
definition - The definition string used to create this attribute type. It must not be null.
primaryName - The primary name for this attribute type, or null if there is no primary name.
typeNames - The full set of names for this attribute type, or null if there are no names.
oid - The OID for this attribute type. It must not be null.
description - The description for the attribute type, or null if there is no description.
superiorType - The reference to the superior type for this attribute type, or null if there is no superior type.
syntax - The syntax for this attribute type, or null if there is no syntax.
attributeUsage - The attribute usage for this attribute type, or null to default to user applications.
isCollective - Indicates whether this attribute type is declared "collective".
isNoUserModification - Indicates whether this attribute type is declared "no-user-modification".
isObsolete - Indicates whether this attribute type is declared "obsolete".
isSingleValue - Indicates whether this attribute type is declared "single-value".

AttributeType

public AttributeType(java.lang.String definition,
                     java.lang.String primaryName,
                     java.util.Collection<java.lang.String> typeNames,
                     java.lang.String oid,
                     java.lang.String description,
                     AttributeType superiorType,
                     AttributeSyntax syntax,
                     ApproximateMatchingRule approximateMatchingRule,
                     EqualityMatchingRule equalityMatchingRule,
                     OrderingMatchingRule orderingMatchingRule,
                     SubstringMatchingRule substringMatchingRule,
                     AttributeUsage attributeUsage,
                     boolean isCollective,
                     boolean isNoUserModification,
                     boolean isObsolete,
                     boolean isSingleValue,
                     java.util.Map<java.lang.String,java.util.List<java.lang.String>> extraProperties)
Creates a new attribute type 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:
definition - The definition string used to create this attribute type. It must not be null.
primaryName - The primary name for this attribute type, or null if there is no primary name.
typeNames - The full set of names for this attribute type, or null if there are no names.
oid - The OID for this attribute type. It must not be null.
description - The description for the attribute type, or null if there is no description.
superiorType - The reference to the superior type for this attribute type, or null if there is no superior type.
syntax - The syntax for this attribute type, or null if there is no syntax.
approximateMatchingRule - The approximate matching rule for this attribute type, or null if there is no rule.
equalityMatchingRule - The equality matching rule for this attribute type, or null if there is no rule.
orderingMatchingRule - The ordering matching rule for this attribute type, or null if there is no rule.
substringMatchingRule - The substring matching rule for this attribute type, or null if there is no rule.
attributeUsage - The attribute usage for this attribute type, or null to default to user applications.
isCollective - Indicates whether this attribute type is declared "collective".
isNoUserModification - Indicates whether this attribute type is declared "no-user-modification".
isObsolete - Indicates whether this attribute type is declared "obsolete".
isSingleValue - Indicates whether this attribute type is declared "single-value".
extraProperties - A set of extra properties for this attribute type, or null if there are no extra properties.
Method Detail

getDefinition

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

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

getDefinitionWithFileName

public java.lang.String getDefinitionWithFileName()
Retrieves the definition string used to create this attribute type and including the X-SCHEMA-FILE extension.

Returns:
The definition string used to create this attribute type including the X-SCHEMA-FILE extension.

recreateFromDefinition

public AttributeType recreateFromDefinition()
                                     throws DirectoryException
Creates a new instance of this attribute type based on the definition string. It will also preserve other state information associated with this attribute type 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 attribute type based on the definition string.
Throws:
DirectoryException - If a problem occurs while attempting to create a new attribute type instance from the definition string.

getSuperiorType

public AttributeType getSuperiorType()
Retrieves the superior type for this attribute type.

Returns:
The superior type for this attribute type, or null if it does not have one.

getSyntax

public AttributeSyntax getSyntax()
Retrieves the syntax for this attribute type.

Returns:
The syntax for this attribute type.

getSyntaxOID

public java.lang.String getSyntaxOID()
Retrieves the OID for this syntax associated with this attribute type.

Returns:
The OID for this syntax associated with this attribute type.

getApproximateMatchingRule

public ApproximateMatchingRule getApproximateMatchingRule()
Retrieves the matching rule that should be used for approximate matching with this attribute type.

Returns:
The matching rule that should be used for approximate matching with this attribute type.

getEqualityMatchingRule

public EqualityMatchingRule getEqualityMatchingRule()
Retrieves the matching rule that should be used for equality matching with this attribute type.

Returns:
The matching rule that should be used for equality matching with this attribute type.

getOrderingMatchingRule

public OrderingMatchingRule getOrderingMatchingRule()
Retrieves the matching rule that should be used for ordering with this attribute type.

Returns:
The matching rule that should be used for ordering with this attribute type.

getSubstringMatchingRule

public SubstringMatchingRule getSubstringMatchingRule()
Retrieves the matching rule that should be used for substring matching with this attribute type.

Returns:
The matching rule that should be used for substring matching with this attribute type.

getUsage

public AttributeUsage getUsage()
Retrieves the usage indicator for this attribute type.

Returns:
The usage indicator for this attribute type.

isOperational

public boolean isOperational()
Indicates whether this is an operational attribute. An operational attribute is one with a usage of "directoryOperation", "distributedOperation", or "dSAOperation" (i.e., only userApplications is not operational).

Returns:
true if this is an operational attribute, or false if not.

isCollective

public boolean isCollective()
Indicates whether this attribute type is declared "collective".

Returns:
true if this attribute type is declared "collective", or false if not.

isNoUserModification

public boolean isNoUserModification()
Indicates whether this attribute type is declared "no-user-modification".

Returns:
true if this attribute type is declared "no-user-modification", or false if not.

isSingleValue

public boolean isSingleValue()
Indicates whether this attribute type is declared "single-value".

Returns:
true if this attribute type is declared "single-value", or false if not.

isObjectClassType

public boolean isObjectClassType()
Indicates whether this attribute type represents the "objectclass" attribute. The determination will be made based on the name and/or OID.

Returns:
true if this attribute type is the objectclass type, or false if not.

normalize

public ByteString normalize(ByteString value)
                     throws DirectoryException
Attempts to normalize the provided value using the equality matching rule associated with this attribute type.

Parameters:
value - The value to be normalized.
Returns:
The normalized form of the provided value.
Throws:
DirectoryException - If this attribute type does not have an equality matching rule, or if the provided value could not be normalized.

generateHashCode

public int generateHashCode(AttributeValue value)
Generates a hash code for the specified attribute value. If an equality matching rule is defined for this type, then it will be used to generate the hash code. If the value does not have an equality matching rule but does have a normalized form, then that will be used to obtain the hash code. Otherwise, it will simply be the hash code of the provided value.

Parameters:
value - The attribute value for which to generate the hash code.
Returns:
The generated hash code for the provided value.

toStringContent

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

Specified by:
toStringContent in class CommonSchemaElements
Parameters:
buffer - The buffer to which the information should be appended.