org.opends.server.types
Class ObjectClass

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

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

This class defines a data structure for storing and interacting with an objectclass, which contains a collection of attributes that must and/or may be present in an entry with that objectclass.

Any methods which accesses the set of names associated with this object class, 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, attribute types, 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
ObjectClass(java.lang.String definition, java.lang.String primaryName, java.util.Collection<java.lang.String> names, java.lang.String oid, java.lang.String description, ObjectClass superiorClass, java.util.Set<AttributeType> requiredAttributes, java.util.Set<AttributeType> optionalAttributes, ObjectClassType objectClassType, boolean isObsolete, java.util.Map<java.lang.String,java.util.List<java.lang.String>> extraProperties)
          Creates a new objectclass definition with the provided information.
 
Method Summary
 java.lang.String getDefinition()
          Retrieves the definition string used to create this objectclass.
 java.lang.String getDefinitionWithFileName()
          Retrieves the definition string used to create this objectclass including the X-SCHEMA-FILE extension.
 ObjectClassType getObjectClassType()
          Retrieves the objectclass type for this objectclass.
 java.util.Set<AttributeType> getOptionalAttributeChain()
          Retrieves an unmodifiable view of the set of optional attributes for this objectclass and any superior objectclasses that it might have.
 java.util.Set<AttributeType> getOptionalAttributes()
          Retrieves an unmodifiable view of the set of optional attributes for this objectclass.
 java.util.Set<AttributeType> getRequiredAttributeChain()
          Retrieves an unmodifiable view of the set of all required attributes for this objectclass and any superior objectclasses that it might have.
 java.util.Set<AttributeType> getRequiredAttributes()
          Retrieves an unmodifiable view of the set of required attributes for this objectclass.
 ObjectClass getSuperiorClass()
          Retrieves the reference to the superior class for this objectclass.
 boolean isDescendantOf(ObjectClass objectClass)
          Indicates whether this objectclass is a descendant of the provided class.
 boolean isExtensibleObject()
          Indicates whether this objectclass is the extensibleObject objectclass.
 boolean isOptional(AttributeType attributeType)
          Indicates whether the provided attribute type is included in the optional attribute list for this or any of its superior objectclasses.
 boolean isRequired(AttributeType attributeType)
          Indicates whether the provided attribute type is included in the required attribute list for this or any of its superior objectclasses.
 boolean isRequiredOrOptional(AttributeType attributeType)
          Indicates whether the provided attribute type is in the list of required or optional attributes for this objectclass or any of its superior classes.
 ObjectClass recreateFromDefinition()
          Creates a new instance of this objectclass 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

ObjectClass

public ObjectClass(java.lang.String definition,
                   java.lang.String primaryName,
                   java.util.Collection<java.lang.String> names,
                   java.lang.String oid,
                   java.lang.String description,
                   ObjectClass superiorClass,
                   java.util.Set<AttributeType> requiredAttributes,
                   java.util.Set<AttributeType> optionalAttributes,
                   ObjectClassType objectClassType,
                   boolean isObsolete,
                   java.util.Map<java.lang.String,java.util.List<java.lang.String>> extraProperties)
Creates a new objectclass 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:
definition - The definition string used to create this objectclass. It must not be null.
primaryName - The primary name for this objectclass, or null if there is no primary name.
names - The set of names that may be used to reference this objectclass.
oid - The OID for this objectclass. It must not be null.
description - The description for this objectclass, or null if there is no description.
superiorClass - The superior class for this objectclass, or null if there is no superior object class.
requiredAttributes - The set of required attribute types for this objectclass.
optionalAttributes - The set of optional attribute types for this objectclass.
objectClassType - The objectclass type for this objectclass, or null to default to structural.
isObsolete - Indicates whether this objectclass is declared "obsolete".
extraProperties - A set of extra properties for this objectclass.
Method Detail

getDefinition

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

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

getDefinitionWithFileName

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

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

recreateFromDefinition

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

getSuperiorClass

public ObjectClass getSuperiorClass()
Retrieves the reference to the superior class for this objectclass.

Returns:
The reference to the superior class for this objectlass, or null if there is none.

isDescendantOf

public boolean isDescendantOf(ObjectClass objectClass)
Indicates whether this objectclass is a descendant of the provided class.

Parameters:
objectClass - The objectClass for which to make the determination.
Returns:
true if this objectclass is a descendant of the provided class, or false if not.

getRequiredAttributes

public java.util.Set<AttributeType> getRequiredAttributes()
Retrieves an unmodifiable view of the set of required attributes for this objectclass. Note that this set will not automatically include any required attributes for superior objectclasses.

Returns:
Returns an unmodifiable view of the set of required attributes for this objectclass.

getRequiredAttributeChain

public java.util.Set<AttributeType> getRequiredAttributeChain()
Retrieves an unmodifiable view of the set of all required attributes for this objectclass and any superior objectclasses that it might have.

Returns:
Returns an unmodifiable view of the set of all required attributes for this objectclass and any superior objectclasses that it might have.

isRequired

public boolean isRequired(AttributeType attributeType)
Indicates whether the provided attribute type is included in the required attribute list for this or any of its superior objectclasses.

Parameters:
attributeType - The attribute type for which to make the determination.
Returns:
true if the provided attribute type is required by this objectclass or any of its superior classes, or false if not.

getOptionalAttributes

public java.util.Set<AttributeType> getOptionalAttributes()
Retrieves an unmodifiable view of the set of optional attributes for this objectclass. Note that this list will not automatically include any optional attributes for superior objectclasses.

Returns:
Returns an unmodifiable view of the set of optional attributes for this objectclass.

getOptionalAttributeChain

public java.util.Set<AttributeType> getOptionalAttributeChain()
Retrieves an unmodifiable view of the set of optional attributes for this objectclass and any superior objectclasses that it might have.

Returns:
Returns an unmodifiable view of the set of optional attributes for this objectclass and any superior objectclasses that it might have.

isOptional

public boolean isOptional(AttributeType attributeType)
Indicates whether the provided attribute type is included in the optional attribute list for this or any of its superior objectclasses.

Parameters:
attributeType - The attribute type for which to make the determination.
Returns:
true if the provided attribute type is optional for this objectclass or any of its superior classes, 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 objectclass or any of its superior classes.

Parameters:
attributeType - The attribute type for which to make the determination.
Returns:
true if the provided attribute type is required or allowed for this objectclass or any of its superior classes, or false if it is not.

getObjectClassType

public ObjectClassType getObjectClassType()
Retrieves the objectclass type for this objectclass.

Returns:
The objectclass type for this objectclass.

isExtensibleObject

public boolean isExtensibleObject()
Indicates whether this objectclass is the extensibleObject objectclass.

Returns:
true if this objectclass is the extensibleObject objectclass, or false if it is not.

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.