com.unboundid.ldap.sdk.schema
Class Schema

java.lang.Object
  extended by com.unboundid.ldap.sdk.schema.Schema
All Implemented Interfaces:
java.io.Serializable

@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class Schema
extends java.lang.Object
implements java.io.Serializable

This class provides a data structure for representing a directory server subschema subentry. This includes information about the attribute syntaxes, matching rules, attribute types, object classes, name forms, DIT content rules, DIT structure rules, and matching rule uses defined in the server schema.

See Also:
Serialized Form

Field Summary
static java.lang.String ATTR_ATTRIBUTE_SYNTAX
          The name of the attribute used to hold the attribute syntax definitions.
static java.lang.String ATTR_ATTRIBUTE_TYPE
          The name of the attribute used to hold the attribute type definitions.
static java.lang.String ATTR_DIT_CONTENT_RULE
          The name of the attribute used to hold the DIT content rule definitions.
static java.lang.String ATTR_DIT_STRUCTURE_RULE
          The name of the attribute used to hold the DIT structure rule definitions.
static java.lang.String ATTR_MATCHING_RULE
          The name of the attribute used to hold the matching rule definitions.
static java.lang.String ATTR_MATCHING_RULE_USE
          The name of the attribute used to hold the matching rule use definitions.
static java.lang.String ATTR_NAME_FORM
          The name of the attribute used to hold the name form definitions.
static java.lang.String ATTR_OBJECT_CLASS
          The name of the attribute used to hold the object class definitions.
static java.lang.String ATTR_SUBSCHEMA_SUBENTRY
          The name of the attribute used to hold the DN of the subschema subentry with the schema information that governs a specified entry.
 
Constructor Summary
Schema(Entry schemaEntry)
          Creates a new schema object by decoding the information in the provided entry.
 
Method Summary
 boolean equals(java.lang.Object o)
          Indicates whether the provided object is equal to this schema object.
 java.util.Set<ObjectClassDefinition> getAbstractObjectClasses()
          Retrieves the set of abstract object class definitions contained in the server schema.
 AttributeSyntaxDefinition getAttributeSyntax(java.lang.String oid)
          Retrieves the attribute syntax with the specified OID from the server schema.
 java.util.Set<AttributeSyntaxDefinition> getAttributeSyntaxes()
          Retrieves the set of attribute syntax definitions contained in the server schema.
 AttributeTypeDefinition getAttributeType(java.lang.String name)
          Retrieves the attribute type with the specified name or OID from the server schema.
 java.util.Set<AttributeTypeDefinition> getAttributeTypes()
          Retrieves the set of attribute type definitions contained in the server schema.
 java.util.Set<ObjectClassDefinition> getAuxiliaryObjectClasses()
          Retrieves the set of auxiliary object class definitions contained in the server schema.
static Schema getDefaultStandardSchema()
          Retrieves a schema object that contains definitions for a number of standard attribute types and object classes from LDAP-related RFCs and Internet Drafts.
 DITContentRuleDefinition getDITContentRule(java.lang.String name)
          Retrieves the DIT content rule with the specified name or OID from the server schema.
 java.util.Set<DITContentRuleDefinition> getDITContentRules()
          Retrieves the set of DIT content rule definitions contained in the server schema.
 DITStructureRuleDefinition getDITStructureRuleByID(int ruleID)
          Retrieves the DIT content rule with the specified rule ID from the server schema.
 DITStructureRuleDefinition getDITStructureRuleByName(java.lang.String ruleName)
          Retrieves the DIT content rule with the specified name from the server schema.
 DITStructureRuleDefinition getDITStructureRuleByNameForm(java.lang.String nameForm)
          Retrieves the DIT content rule associated with the specified name form from the server schema.
 java.util.Set<DITStructureRuleDefinition> getDITStructureRules()
          Retrieves the set of DIT structure rule definitions contained in the server schema.
 MatchingRuleDefinition getMatchingRule(java.lang.String name)
          Retrieves the matching rule with the specified name or OID from the server schema.
 java.util.Set<MatchingRuleDefinition> getMatchingRules()
          Retrieves the set of matching rule definitions contained in the server schema.
 MatchingRuleUseDefinition getMatchingRuleUse(java.lang.String name)
          Retrieves the matching rule use with the specified name or OID from the server schema.
 java.util.Set<MatchingRuleUseDefinition> getMatchingRuleUses()
          Retrieves the set of matching rule use definitions contained in the server schema.
 NameFormDefinition getNameFormByName(java.lang.String name)
          Retrieves the name form with the specified name or OID from the server schema.
 NameFormDefinition getNameFormByObjectClass(java.lang.String objectClass)
          Retrieves the name form associated with the specified structural object class from the server schema.
 java.util.Set<NameFormDefinition> getNameForms()
          Retrieves the set of name form definitions contained in the server schema.
 ObjectClassDefinition getObjectClass(java.lang.String name)
          Retrieves the object class with the specified name or OID from the server schema.
 java.util.Set<ObjectClassDefinition> getObjectClasses()
          Retrieves the set of object class definitions contained in the server schema.
 java.util.Set<AttributeTypeDefinition> getOperationalAttributeTypes()
          Retrieves the set of operational attribute type definitions (i.e., those definitions with a usage of directoryOperation, distributedOperation, or dSAOperation) contained in the server schema.
static Schema getSchema(java.io.File... schemaFiles)
          Reads schema information from one or more files containing the schema represented in LDIF form, with the definitions represented in the form described in section 4.1 of RFC 4512.
static Schema getSchema(LDAPConnection connection)
          Retrieves the directory server schema over the provided connection.
static Schema getSchema(LDAPConnection connection, java.lang.String entryDN)
          Retrieves the directory server schema that governs the specified entry.
static Schema getSchema(java.util.List<java.io.File> schemaFiles)
          Reads schema information from one or more files containing the schema represented in LDIF form, with the definitions represented in the form described in section 4.1 of RFC 4512.
static Schema getSchema(java.lang.String... schemaFiles)
          Reads schema information from one or more files containing the schema represented in LDIF form, with the definitions represented in the form described in section 4.1 of RFC 4512.
 ReadOnlyEntry getSchemaEntry()
          Retrieves the entry used to create this schema object.
 java.util.Set<ObjectClassDefinition> getStructuralObjectClasses()
          Retrieves the set of structural object class definitions contained in the server schema.
 java.util.List<AttributeTypeDefinition> getSubordinateAttributeTypes(AttributeTypeDefinition d)
          Retrieves a list of all subordinate attribute type definitions for the provided attribute type definition.
static java.lang.String getSubschemaSubentryDN(LDAPConnection connection, java.lang.String entryDN)
          Retrieves the value of the subschemaSubentry attribute from the specified entry using the provided connection.
 java.util.Set<AttributeTypeDefinition> getUserAttributeTypes()
          Retrieves the set of user attribute type definitions (i.e., those definitions with a usage of userApplications) contained in the server schema.
 int hashCode()
          Retrieves a hash code for this schema object.
static Schema mergeSchemas(Schema... schemas)
          Retrieves a schema containing all of the elements of each of the provided schemas.
 java.lang.String toString()
          Retrieves a string representation of the associated schema entry.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

ATTR_ATTRIBUTE_SYNTAX

public static final java.lang.String ATTR_ATTRIBUTE_SYNTAX
The name of the attribute used to hold the attribute syntax definitions.

See Also:
Constant Field Values

ATTR_ATTRIBUTE_TYPE

public static final java.lang.String ATTR_ATTRIBUTE_TYPE
The name of the attribute used to hold the attribute type definitions.

See Also:
Constant Field Values

ATTR_DIT_CONTENT_RULE

public static final java.lang.String ATTR_DIT_CONTENT_RULE
The name of the attribute used to hold the DIT content rule definitions.

See Also:
Constant Field Values

ATTR_DIT_STRUCTURE_RULE

public static final java.lang.String ATTR_DIT_STRUCTURE_RULE
The name of the attribute used to hold the DIT structure rule definitions.

See Also:
Constant Field Values

ATTR_MATCHING_RULE

public static final java.lang.String ATTR_MATCHING_RULE
The name of the attribute used to hold the matching rule definitions.

See Also:
Constant Field Values

ATTR_MATCHING_RULE_USE

public static final java.lang.String ATTR_MATCHING_RULE_USE
The name of the attribute used to hold the matching rule use definitions.

See Also:
Constant Field Values

ATTR_NAME_FORM

public static final java.lang.String ATTR_NAME_FORM
The name of the attribute used to hold the name form definitions.

See Also:
Constant Field Values

ATTR_OBJECT_CLASS

public static final java.lang.String ATTR_OBJECT_CLASS
The name of the attribute used to hold the object class definitions.

See Also:
Constant Field Values

ATTR_SUBSCHEMA_SUBENTRY

public static final java.lang.String ATTR_SUBSCHEMA_SUBENTRY
The name of the attribute used to hold the DN of the subschema subentry with the schema information that governs a specified entry.

See Also:
Constant Field Values
Constructor Detail

Schema

public Schema(Entry schemaEntry)
Creates a new schema object by decoding the information in the provided entry.

Parameters:
schemaEntry - The schema entry to decode.
Method Detail

getSchema

public static Schema getSchema(LDAPConnection connection)
                        throws LDAPException
Retrieves the directory server schema over the provided connection. The root DSE will first be retrieved in order to get its subschemaSubentry DN, and then that entry will be retrieved from the server and its contents decoded as schema elements. This should be sufficient for directories that only provide a single schema, but for directories with multiple schemas it may be necessary to specify the DN of an entry for which to retrieve the subschema subentry.

Parameters:
connection - The connection to use in order to retrieve the server schema. It must not be null.
Returns:
A decoded representation of the server schema.
Throws:
LDAPException - If a problem occurs while obtaining the server schema.

getSchema

public static Schema getSchema(LDAPConnection connection,
                               java.lang.String entryDN)
                        throws LDAPException
Retrieves the directory server schema that governs the specified entry. In some servers, different portions of the DIT may be served by different schemas, and in such cases it will be necessary to provide the DN of the target entry in order to ensure that the appropriate schema which governs that entry is returned. For servers that support only a single schema, any entry DN (including that of the root DSE) should be sufficient.

Parameters:
connection - The connection to use in order to retrieve the server schema. It must not be null.
entryDN - The DN of the entry for which to retrieve the governing schema. It may be null or an empty string in order to retrieve the schema that governs the server's root DSE.
Returns:
A decoded representation of the server schema, or null if it is not available for some reason (e.g., the client does not have permission to read the server schema).
Throws:
LDAPException - If a problem occurs while obtaining the server schema.

getSchema

public static Schema getSchema(java.lang.String... schemaFiles)
                        throws java.io.IOException,
                               LDIFException
Reads schema information from one or more files containing the schema represented in LDIF form, with the definitions represented in the form described in section 4.1 of RFC 4512. Each file should contain a single entry.

Parameters:
schemaFiles - The paths to the LDIF files containing the schema information to be read. At least one file must be specified. If multiple files are specified, then they will be processed in the order in which they have been listed.
Returns:
The schema read from the specified schema files, or null if none of the files contains any LDIF data to be read.
Throws:
java.io.IOException - If a problem occurs while attempting to read from any of the specified files.
LDIFException - If a problem occurs while attempting to parse the contents of any of the schema files.

getSchema

public static Schema getSchema(java.io.File... schemaFiles)
                        throws java.io.IOException,
                               LDIFException
Reads schema information from one or more files containing the schema represented in LDIF form, with the definitions represented in the form described in section 4.1 of RFC 4512. Each file should contain a single entry.

Parameters:
schemaFiles - The paths to the LDIF files containing the schema information to be read. At least one file must be specified. If multiple files are specified, then they will be processed in the order in which they have been listed.
Returns:
The schema read from the specified schema files, or null if none of the files contains any LDIF data to be read.
Throws:
java.io.IOException - If a problem occurs while attempting to read from any of the specified files.
LDIFException - If a problem occurs while attempting to parse the contents of any of the schema files.

getSchema

public static Schema getSchema(java.util.List<java.io.File> schemaFiles)
                        throws java.io.IOException,
                               LDIFException
Reads schema information from one or more files containing the schema represented in LDIF form, with the definitions represented in the form described in section 4.1 of RFC 4512. Each file should contain a single entry.

Parameters:
schemaFiles - The paths to the LDIF files containing the schema information to be read. At least one file must be specified. If multiple files are specified, then they will be processed in the order in which they have been listed.
Returns:
The schema read from the specified schema files, or null if none of the files contains any LDIF data to be read.
Throws:
java.io.IOException - If a problem occurs while attempting to read from any of the specified files.
LDIFException - If a problem occurs while attempting to parse the contents of any of the schema files.

getDefaultStandardSchema

public static Schema getDefaultStandardSchema()
                                       throws LDAPException
Retrieves a schema object that contains definitions for a number of standard attribute types and object classes from LDAP-related RFCs and Internet Drafts.

Returns:
A schema object that contains definitions for a number of standard attribute types and object classes from LDAP-related RFCs and Internet Drafts.
Throws:
LDAPException - If a problem occurs while attempting to obtain or parse the default standard schema definitions.

mergeSchemas

public static Schema mergeSchemas(Schema... schemas)
Retrieves a schema containing all of the elements of each of the provided schemas.

Parameters:
schemas - The schemas to be merged. It must not be null or empty.
Returns:
A merged representation of the provided schemas.

getSchemaEntry

public ReadOnlyEntry getSchemaEntry()
Retrieves the entry used to create this schema object.

Returns:
The entry used to create this schema object.

getSubschemaSubentryDN

public static java.lang.String getSubschemaSubentryDN(LDAPConnection connection,
                                                      java.lang.String entryDN)
                                               throws LDAPException
Retrieves the value of the subschemaSubentry attribute from the specified entry using the provided connection.

Parameters:
connection - The connection to use in order to perform the search. It must not be null.
entryDN - The DN of the entry from which to retrieve the subschemaSubentry attribute. It may be null or an empty string in order to retrieve the value from the server's root DSE.
Returns:
The value of the subschemaSubentry attribute from the specified entry, or null if it is not available for some reason (e.g., the client does not have permission to read the target entry or the subschemaSubentry attribute).
Throws:
LDAPException - If a problem occurs while attempting to retrieve the specified entry.

getAttributeSyntaxes

public java.util.Set<AttributeSyntaxDefinition> getAttributeSyntaxes()
Retrieves the set of attribute syntax definitions contained in the server schema.

Returns:
The set of attribute syntax definitions contained in the server schema.

getAttributeSyntax

public AttributeSyntaxDefinition getAttributeSyntax(java.lang.String oid)
Retrieves the attribute syntax with the specified OID from the server schema.

Parameters:
oid - The OID of the attribute syntax to retrieve. It must not be null. It may optionally include a minimum upper bound (as may appear when the syntax OID is included in an attribute type definition), but if it does then that portion will be ignored when retrieving the attribute syntax.
Returns:
The requested attribute syntax, or null if there is no such syntax defined in the server schema.

getAttributeTypes

public java.util.Set<AttributeTypeDefinition> getAttributeTypes()
Retrieves the set of attribute type definitions contained in the server schema.

Returns:
The set of attribute type definitions contained in the server schema.

getOperationalAttributeTypes

public java.util.Set<AttributeTypeDefinition> getOperationalAttributeTypes()
Retrieves the set of operational attribute type definitions (i.e., those definitions with a usage of directoryOperation, distributedOperation, or dSAOperation) contained in the server schema.

Returns:
The set of operational attribute type definitions contained in the server schema.

getUserAttributeTypes

public java.util.Set<AttributeTypeDefinition> getUserAttributeTypes()
Retrieves the set of user attribute type definitions (i.e., those definitions with a usage of userApplications) contained in the server schema.

Returns:
The set of user attribute type definitions contained in the server schema.

getAttributeType

public AttributeTypeDefinition getAttributeType(java.lang.String name)
Retrieves the attribute type with the specified name or OID from the server schema.

Parameters:
name - The name or OID of the attribute type to retrieve. It must not be null.
Returns:
The requested attribute type, or null if there is no such attribute type defined in the server schema.

getSubordinateAttributeTypes

public java.util.List<AttributeTypeDefinition> getSubordinateAttributeTypes(AttributeTypeDefinition d)
Retrieves a list of all subordinate attribute type definitions for the provided attribute type definition.

Parameters:
d - The attribute type definition for which to retrieve all subordinate attribute types. It must not be null.
Returns:
A list of all subordinate attribute type definitions for the provided attribute type definition, or an empty list if it does not have any subordinate types or the provided attribute type is not defined in the schema.

getDITContentRules

public java.util.Set<DITContentRuleDefinition> getDITContentRules()
Retrieves the set of DIT content rule definitions contained in the server schema.

Returns:
The set of DIT content rule definitions contained in the server schema.

getDITContentRule

public DITContentRuleDefinition getDITContentRule(java.lang.String name)
Retrieves the DIT content rule with the specified name or OID from the server schema.

Parameters:
name - The name or OID of the DIT content rule to retrieve. It must not be null.
Returns:
The requested DIT content rule, or null if there is no such rule defined in the server schema.

getDITStructureRules

public java.util.Set<DITStructureRuleDefinition> getDITStructureRules()
Retrieves the set of DIT structure rule definitions contained in the server schema.

Returns:
The set of DIT structure rule definitions contained in the server schema.

getDITStructureRuleByID

public DITStructureRuleDefinition getDITStructureRuleByID(int ruleID)
Retrieves the DIT content rule with the specified rule ID from the server schema.

Parameters:
ruleID - The rule ID for the DIT structure rule to retrieve.
Returns:
The requested DIT structure rule, or null if there is no such rule defined in the server schema.

getDITStructureRuleByName

public DITStructureRuleDefinition getDITStructureRuleByName(java.lang.String ruleName)
Retrieves the DIT content rule with the specified name from the server schema.

Parameters:
ruleName - The name of the DIT structure rule to retrieve. It must not be null.
Returns:
The requested DIT structure rule, or null if there is no such rule defined in the server schema.

getDITStructureRuleByNameForm

public DITStructureRuleDefinition getDITStructureRuleByNameForm(java.lang.String nameForm)
Retrieves the DIT content rule associated with the specified name form from the server schema.

Parameters:
nameForm - The name or OID of the name form for which to retrieve the associated DIT structure rule.
Returns:
The requested DIT structure rule, or null if there is no such rule defined in the server schema.

getMatchingRules

public java.util.Set<MatchingRuleDefinition> getMatchingRules()
Retrieves the set of matching rule definitions contained in the server schema.

Returns:
The set of matching rule definitions contained in the server schema.

getMatchingRule

public MatchingRuleDefinition getMatchingRule(java.lang.String name)
Retrieves the matching rule with the specified name or OID from the server schema.

Parameters:
name - The name or OID of the matching rule to retrieve. It must not be null.
Returns:
The requested matching rule, or null if there is no such rule defined in the server schema.

getMatchingRuleUses

public java.util.Set<MatchingRuleUseDefinition> getMatchingRuleUses()
Retrieves the set of matching rule use definitions contained in the server schema.

Returns:
The set of matching rule use definitions contained in the server schema.

getMatchingRuleUse

public MatchingRuleUseDefinition getMatchingRuleUse(java.lang.String name)
Retrieves the matching rule use with the specified name or OID from the server schema.

Parameters:
name - The name or OID of the matching rule use to retrieve. It must not be null.
Returns:
The requested matching rule, or null if there is no such matching rule use defined in the server schema.

getNameForms

public java.util.Set<NameFormDefinition> getNameForms()
Retrieves the set of name form definitions contained in the server schema.

Returns:
The set of name form definitions contained in the server schema.

getNameFormByName

public NameFormDefinition getNameFormByName(java.lang.String name)
Retrieves the name form with the specified name or OID from the server schema.

Parameters:
name - The name or OID of the name form to retrieve. It must not be null.
Returns:
The requested name form, or null if there is no such rule defined in the server schema.

getNameFormByObjectClass

public NameFormDefinition getNameFormByObjectClass(java.lang.String objectClass)
Retrieves the name form associated with the specified structural object class from the server schema.

Parameters:
objectClass - The name or OID of the structural object class for which to retrieve the associated name form. It must not be null.
Returns:
The requested name form, or null if there is no such rule defined in the server schema.

getObjectClasses

public java.util.Set<ObjectClassDefinition> getObjectClasses()
Retrieves the set of object class definitions contained in the server schema.

Returns:
The set of object class definitions contained in the server schema.

getAbstractObjectClasses

public java.util.Set<ObjectClassDefinition> getAbstractObjectClasses()
Retrieves the set of abstract object class definitions contained in the server schema.

Returns:
The set of abstract object class definitions contained in the server schema.

getAuxiliaryObjectClasses

public java.util.Set<ObjectClassDefinition> getAuxiliaryObjectClasses()
Retrieves the set of auxiliary object class definitions contained in the server schema.

Returns:
The set of auxiliary object class definitions contained in the server schema.

getStructuralObjectClasses

public java.util.Set<ObjectClassDefinition> getStructuralObjectClasses()
Retrieves the set of structural object class definitions contained in the server schema.

Returns:
The set of structural object class definitions contained in the server schema.

getObjectClass

public ObjectClassDefinition getObjectClass(java.lang.String name)
Retrieves the object class with the specified name or OID from the server schema.

Parameters:
name - The name or OID of the object class to retrieve. It must not be null.
Returns:
The requested object class, or null if there is no such class defined in the server schema.

hashCode

public int hashCode()
Retrieves a hash code for this schema object.

Overrides:
hashCode in class java.lang.Object
Returns:
A hash code for this schema object.

equals

public boolean equals(java.lang.Object o)
Indicates whether the provided object is equal to this schema object.

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 object, or false if not.

toString

public java.lang.String toString()
Retrieves a string representation of the associated schema entry.

Overrides:
toString in class java.lang.Object
Returns:
A string representation of the associated schema entry.