public final class Schema extends Object
| Modifier and Type | Method and Description |
|---|---|
Schema |
asNonStrictSchema()
Returns a non-strict view of this schema.
|
Schema |
asStrictSchema()
Returns a strict view of this schema.
|
AttributeType |
getAttributeType(String name)
Returns the attribute type with the specified name or numeric OID.
|
Collection<AttributeType> |
getAttributeTypes()
Returns an unmodifiable collection containing all of the attribute types
contained in this schema.
|
List<AttributeType> |
getAttributeTypesWithName(String name)
Returns an unmodifiable collection containing all of the attribute types
having the specified name or numeric OID.
|
static Schema |
getCoreSchema()
Returns the core schema.
|
static Schema |
getDefaultSchema()
Returns the default schema which should be used by this application.
|
DITContentRule |
getDITContentRule(ObjectClass structuralClass)
Returns the DIT content rule associated with the provided structural
object class, or
null if no rule is defined. |
DITContentRule |
getDITContentRule(String name)
Returns the DIT content rule with the specified name or numeric OID.
|
Collection<DITContentRule> |
getDITContentRules()
Returns an unmodifiable collection containing all of the DIT content
rules contained in this schema.
|
Collection<DITContentRule> |
getDITContentRulesWithName(String name)
Returns an unmodifiable collection containing all of the DIT content
rules having the specified name or numeric OID.
|
DITStructureRule |
getDITStructureRule(int ruleID)
Returns the DIT structure rule with the specified name or numeric OID.
|
Collection<DITStructureRule> |
getDITStructureRules(NameForm nameForm)
Returns an unmodifiable collection containing all of the DIT structure
rules associated with the provided name form.
|
Collection<DITStructureRule> |
getDITStructureRulesWithName(String name)
Returns an unmodifiable collection containing all of the DIT structure
rules having the specified name or numeric OID.
|
Collection<DITStructureRule> |
getDITStuctureRules()
Returns an unmodifiable collection containing all of the DIT structure
rules contained in this schema.
|
static Schema |
getEmptySchema()
Returns the empty schema.
|
MatchingRule |
getMatchingRule(String name)
Returns the matching rule with the specified name or numeric OID.
|
Collection<MatchingRule> |
getMatchingRules()
Returns an unmodifiable collection containing all of the matching rules
contained in this schema.
|
Collection<MatchingRule> |
getMatchingRulesWithName(String name)
Returns an unmodifiable collection containing all of the matching rules
having the specified name or numeric OID.
|
MatchingRuleUse |
getMatchingRuleUse(MatchingRule matchingRule)
Returns the matching rule use associated with the provided matching rule,
or
null if no use is defined. |
MatchingRuleUse |
getMatchingRuleUse(String name)
Returns the matching rule use with the specified name or numeric OID.
|
Collection<MatchingRuleUse> |
getMatchingRuleUses()
Returns an unmodifiable collection containing all of the matching rule
uses contained in this schema.
|
Collection<MatchingRuleUse> |
getMatchingRuleUsesWithName(String name)
Returns an unmodifiable collection containing all of the matching rule
uses having the specified name or numeric OID.
|
NameForm |
getNameForm(String name)
Returns the name form with the specified name or numeric OID.
|
Collection<NameForm> |
getNameForms()
Returns an unmodifiable collection containing all of the name forms
contained in this schema.
|
Collection<NameForm> |
getNameForms(ObjectClass structuralClass)
Returns an unmodifiable collection containing all of the name forms
associated with the provided structural object class.
|
Collection<NameForm> |
getNameFormsWithName(String name)
Returns an unmodifiable collection containing all of the name forms
having the specified name or numeric OID.
|
ObjectClass |
getObjectClass(String name)
Returns the object class with the specified name or numeric OID.
|
Collection<ObjectClass> |
getObjectClasses()
Returns an unmodifiable collection containing all of the object classes
contained in this schema.
|
Collection<ObjectClass> |
getObjectClassesWithName(String name)
Returns an unmodifiable collection containing all of the object classes
having the specified name or numeric OID.
|
<T> T |
getOption(Option<T> option)
Returns the value associated to the provided
Option or the option
default value, if there is no such option in this schema. |
String |
getSchemaName()
Returns the user-friendly name of this schema which may be used for
debugging purposes.
|
Syntax |
getSyntax(String numericOID)
Returns the syntax with the specified numeric OID.
|
Collection<Syntax> |
getSyntaxes()
Returns an unmodifiable collection containing all of the syntaxes
contained in this schema.
|
Collection<LocalizableMessage> |
getWarnings()
Returns an unmodifiable collection containing all of the warnings that
were detected when this schema was constructed.
|
boolean |
hasAttributeType(String name)
Indicates whether or not this schema contains an attribute type with the
specified name or numeric OID.
|
boolean |
hasDITContentRule(String name)
Indicates whether or not this schema contains a DIT content rule with the
specified name or numeric OID.
|
boolean |
hasDITStructureRule(int ruleID)
Indicates whether or not this schema contains a DIT structure rule with
the specified rule ID.
|
boolean |
hasMatchingRule(String name)
Indicates whether or not this schema contains a matching rule with the
specified name or numeric OID.
|
boolean |
hasMatchingRuleUse(String name)
Indicates whether or not this schema contains a matching rule use with
the specified name or numeric OID.
|
boolean |
hasNameForm(String name)
Indicates whether or not this schema contains a name form with the
specified name or numeric OID.
|
boolean |
hasObjectClass(String name)
Indicates whether or not this schema contains an object class with the
specified name or numeric OID.
|
boolean |
hasSyntax(String numericOID)
Indicates whether or not this schema contains a syntax with the specified
numeric OID.
|
boolean |
isStrict()
Indicates whether or not this schema is strict.
|
static Schema |
readSchema(Connection connection,
DN name)
Reads the schema contained in the named subschema sub-entry.
|
static LdapPromise<Schema> |
readSchemaAsync(Connection connection,
DN name)
Asynchronously reads the schema contained in the named subschema
sub-entry.
|
static Schema |
readSchemaForEntry(Connection connection,
DN name)
Reads the schema contained in the subschema sub-entry which applies to
the named entry.
|
static LdapPromise<Schema> |
readSchemaForEntryAsync(Connection connection,
DN name)
Asynchronously reads the schema contained in the subschema sub-entry
which applies to the named entry.
|
static void |
setDefaultSchema(Schema schema)
Sets the default schema which should be used by this application.
|
Entry |
toEntry(Entry entry)
Adds the definitions of all the schema elements contained in this schema
to the provided subschema subentry.
|
boolean |
validateEntry(Entry entry,
SchemaValidationPolicy policy,
Collection<LocalizableMessage> errorMessages)
Returns
true if the provided entry is valid according to this
schema and the specified schema validation policy. |
static Schema |
valueOf(Entry entry)
Parses the provided entry as a subschema subentry.
|
public static Schema getCoreSchema()
public static Schema getDefaultSchema()
public static Schema getEmptySchema()
public static Schema readSchema(Connection connection, DN name) throws LdapException
If the requested schema is not returned by the Directory Server then the
request will fail with an EntryNotFoundException. More
specifically, this method will never return null.
connection - A connection to the Directory Server whose schema is to be
read.name - The distinguished name of the subschema sub-entry.LdapException - If the result code indicates that the request failed for some
reason.UnsupportedOperationException - If the connection does not support search operations.IllegalStateException - If the connection has already been closed, i.e. if
connection.isClosed() == true.NullPointerException - If the connection or name was null.public static LdapPromise<Schema> readSchemaAsync(Connection connection, DN name)
If the requested schema is not returned by the Directory Server then the
request will fail with an EntryNotFoundException. More
specifically, the returned promise will never return null.
connection - A connection to the Directory Server whose schema is to be
read.name - The distinguished name of the subschema sub-entry.
the operation result when it is received, may be null.UnsupportedOperationException - If the connection does not support search operations.IllegalStateException - If the connection has already been closed, i.e. if
connection.isClosed() == true.NullPointerException - If the connection or name was null.public static Schema readSchemaForEntry(Connection connection, DN name) throws LdapException
If the requested entry or its associated schema are not returned by the
Directory Server then the request will fail with an
EntryNotFoundException. More specifically, this method will never
return null.
This implementation first reads the subschemaSubentry attribute
of the entry in order to identify the schema and then invokes
readSchema(Connection, DN) to read the schema.
connection - A connection to the Directory Server whose schema is to be
read.name - The distinguished name of the entry whose schema is to be
located.LdapException - If the result code indicates that the request failed for some
reason.UnsupportedOperationException - If the connection does not support search operations.IllegalStateException - If the connection has already been closed, i.e. if
connection.isClosed() == true.NullPointerException - If the connection or name was null.public static LdapPromise<Schema> readSchemaForEntryAsync(Connection connection, DN name)
If the requested entry or its associated schema are not returned by the
Directory Server then the request will fail with an
EntryNotFoundException. More specifically, the returned promise
will never return null.
This implementation first reads the subschemaSubentry attribute
of the entry in order to identify the schema and then invokes
#readSchemaAsync(Connection, DN, ResultHandler) to read the
schema.
connection - A connection to the Directory Server whose schema is to be
read.name - The distinguished name of the entry whose schema is to be
located.UnsupportedOperationException - If the connection does not support search operations.IllegalStateException - If the connection has already been closed, i.e. if
connection.isClosed() == true.NullPointerException - If the connection or name was null.public static void setDefaultSchema(Schema schema)
schema - The default schema which should be used by this application.public static Schema valueOf(Entry entry)
getWarnings() method.entry - The subschema subentry to be parsed.public Schema asNonStrictSchema()
See the description of isStrict() for more details.
isStrict()public Schema asStrictSchema()
See the description of isStrict() for more details.
isStrict()public AttributeType getAttributeType(String name)
If the requested attribute type is not registered in this schema and this
schema is non-strict then a temporary "place-holder" attribute type will
be created and returned. Place holder attribute types have an OID which
is the normalized attribute name with the string -oid appended.
In addition, they will use the directory string syntax and case ignore
matching rule.
name - The name or OID of the attribute type to retrieve.UnknownSchemaElementException - If this is a strict schema and the requested attribute type
was not found or if the provided name is ambiguous.AttributeType.isPlaceHolder()public Collection<AttributeType> getAttributeTypes()
public List<AttributeType> getAttributeTypesWithName(String name)
name - The name or OID of the attribute types to retrieve.public DITContentRule getDITContentRule(ObjectClass structuralClass)
null if no rule is defined.structuralClass - The structural object class .null if no rule is defined.public DITContentRule getDITContentRule(String name)
name - The name or OID of the DIT content rule to retrieve.UnknownSchemaElementException - If this is a strict schema and the requested DIT content rule
was not found or if the provided name is ambiguous.public Collection<DITContentRule> getDITContentRules()
public Collection<DITContentRule> getDITContentRulesWithName(String name)
name - The name or OID of the DIT content rules to retrieve.public DITStructureRule getDITStructureRule(int ruleID)
ruleID - The ID of the DIT structure rule to retrieve.UnknownSchemaElementException - If this is a strict schema and the requested DIT structure
rule was not found.public Collection<DITStructureRule> getDITStructureRules(NameForm nameForm)
nameForm - The name form.public Collection<DITStructureRule> getDITStructureRulesWithName(String name)
name - The name or OID of the DIT structure rules to retrieve.public Collection<DITStructureRule> getDITStuctureRules()
public MatchingRule getMatchingRule(String name)
name - The name or OID of the matching rule to retrieve.UnknownSchemaElementException - If this is a strict schema and the requested matching rule
was not found or if the provided name is ambiguous.public Collection<MatchingRule> getMatchingRules()
public Collection<MatchingRule> getMatchingRulesWithName(String name)
name - The name or OID of the matching rules to retrieve.public MatchingRuleUse getMatchingRuleUse(MatchingRule matchingRule)
null if no use is defined.matchingRule - The matching rule whose matching rule use is to be retrieved.null if no use is defined.public MatchingRuleUse getMatchingRuleUse(String name)
name - The name or OID of the matching rule use to retrieve.UnknownSchemaElementException - If this is a strict schema and the requested matching rule
use was not found or if the provided name is ambiguous.public Collection<MatchingRuleUse> getMatchingRuleUses()
public Collection<MatchingRuleUse> getMatchingRuleUsesWithName(String name)
name - The name or OID of the matching rule uses to retrieve.public NameForm getNameForm(String name)
name - The name or OID of the name form to retrieve.UnknownSchemaElementException - If this is a strict schema and the requested name form was
not found or if the provided name is ambiguous.public Collection<NameForm> getNameForms()
public Collection<NameForm> getNameForms(ObjectClass structuralClass)
structuralClass - The structural object class whose name forms are to be
retrieved.public Collection<NameForm> getNameFormsWithName(String name)
name - The name or OID of the name forms to retrieve.public ObjectClass getObjectClass(String name)
name - The name or OID of the object class to retrieve.UnknownSchemaElementException - If this is a strict schema and the requested object class was
not found or if the provided name is ambiguous.public Collection<ObjectClass> getObjectClasses()
public Collection<ObjectClass> getObjectClassesWithName(String name)
name - The name or OID of the object classes to retrieve.public <T> T getOption(Option<T> option)
Option or the option
default value, if there is no such option in this schema.T - The option type.option - The option whose associated value should to be retrieve.Option or the option
default value, if there is no such option in this schema.public String getSchemaName()
public Syntax getSyntax(String numericOID)
numericOID - The OID of the syntax to retrieve.UnknownSchemaElementException - If this is a strict schema and the requested syntax was not
found or if the provided name is ambiguous.public Collection<Syntax> getSyntaxes()
public Collection<LocalizableMessage> getWarnings()
public boolean hasAttributeType(String name)
name - The name or OID of the attribute type.true if this schema contains an attribute type with the
specified name or numeric OID, otherwise false.public boolean hasDITContentRule(String name)
name - The name or OID of the DIT content rule.true if this schema contains a DIT content rule with the
specified name or numeric OID, otherwise false.public boolean hasDITStructureRule(int ruleID)
ruleID - The ID of the DIT structure rule.true if this schema contains a DIT structure rule with
the specified rule ID, otherwise false.public boolean hasMatchingRule(String name)
name - The name or OID of the matching rule.true if this schema contains a matching rule with the
specified name or numeric OID, otherwise false.public boolean hasMatchingRuleUse(String name)
name - The name or OID of the matching rule use.true if this schema contains a matching rule use with the
specified name or numeric OID, otherwise false.public boolean hasNameForm(String name)
name - The name or OID of the name form.true if this schema contains a name form with the
specified name or numeric OID, otherwise false.public boolean hasObjectClass(String name)
name - The name or OID of the object class.true if this schema contains an object class with the
specified name or numeric OID, otherwise false.public boolean hasSyntax(String numericOID)
numericOID - The OID of the syntax.true if this schema contains a syntax with the specified
numeric OID, otherwise false.public boolean isStrict()
Attribute type queries against non-strict schema always succeed: if the requested attribute type is not found then a temporary attribute type is created automatically having the Octet String syntax and associated matching rules.
Strict schema, on the other hand, throw an
UnknownSchemaElementException whenever an attempt is made to
retrieve a non-existent attribute type.
true if this schema is strict.public Entry toEntry(Entry entry)
entry - The subschema subentry to which all schema definitions should
be added.NullPointerException - If entry was null.public boolean validateEntry(Entry entry, SchemaValidationPolicy policy, Collection<LocalizableMessage> errorMessages)
true if the provided entry is valid according to this
schema and the specified schema validation policy.
If attribute value validation is enabled then following checks will be performed:
entry - The entry to be validated.policy - The schema validation policy.errorMessages - A collection into which any schema validation warnings or
error messages can be placed, or null if they should
not be saved.true if an entry conforms to this schema based on the
provided schema validation policy.Copyright © 2011-2015 ForgeRock AS. All Rights Reserved.