Class Schema

java.lang.Object
com.unboundid.ldap.sdk.schema.Schema
All Implemented Interfaces:
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:
  • Field Details

  • Constructor Details

    • Schema

      public Schema(@NotNull Entry schemaEntry)
      Creates a new schema object by decoding the information in the provided entry. Any schema elements that cannot be parsed will be silently ignored.
      Parameters:
      schemaEntry - The schema entry to decode. It must not be null.
    • Schema

      public Schema(@NotNull Entry schemaEntry, @Nullable Map<String,LDAPException> unparsableAttributeSyntaxes, @Nullable Map<String,LDAPException> unparsableMatchingRules, @Nullable Map<String,LDAPException> unparsableAttributeTypes, @Nullable Map<String,LDAPException> unparsableObjectClasses, @Nullable Map<String,LDAPException> unparsableDITContentRules, @Nullable Map<String,LDAPException> unparsableDITStructureRules, @Nullable Map<String,LDAPException> unparsableNameForms, @Nullable Map<String,LDAPException> unparsableMatchingRuleUses)
      Creates a new schema object by decoding the information in the provided entry, optionally capturing any information about unparsable values in the provided maps.
      Parameters:
      schemaEntry - The schema entry to decode. It must not be null.
      unparsableAttributeSyntaxes - A map that will be updated with information about any attribute syntax definitions that cannot be parsed. It may be null if unparsable attribute syntax definitions should be silently ignored.
      unparsableMatchingRules - A map that will be updated with information about any matching rule definitions that cannot be parsed. It may be null if unparsable matching rule definitions should be silently ignored.
      unparsableAttributeTypes - A map that will be updated with information about any attribute type definitions that cannot be parsed. It may be null if unparsable attribute type definitions should be silently ignored.
      unparsableObjectClasses - A map that will be updated with information about any object class definitions that cannot be parsed. It may be null if unparsable object class definitions should be silently ignored.
      unparsableDITContentRules - A map that will be updated with information about any DIT content rule definitions that cannot be parsed. It may be null if unparsable DIT content rule definitions should be silently ignored.
      unparsableDITStructureRules - A map that will be updated with information about any DIT structure rule definitions that cannot be parsed. It may be null if unparsable attribute DIT structure rule definitions should be silently ignored.
      unparsableNameForms - A map that will be updated with information about any name form definitions that cannot be parsed. It may be null if unparsable name form definitions should be silently ignored.
      unparsableMatchingRuleUses - A map that will be updated with information about any matching rule use definitions that cannot be parsed. It may be null if unparsable matching rule use definitions should be silently ignored.
  • Method Details

    • parseSchemaEntry

      @NotNull public static Schema parseSchemaEntry(@NotNull Entry schemaEntry) throws LDAPException
      Parses all schema elements contained in the provided entry. This method differs from the Schema(Entry) constructor in that this method will throw an exception if it encounters any unparsable schema elements, while the constructor will silently ignore them. Alternatively, the constructor that takes a bunch of maps can be used to obtain information about any unparsable schema elements while still providing access to the parsed schema.
      Parameters:
      schemaEntry - The schema entry to parse. It must not be null.
      Returns:
      The schema entry that was parsed.
      Throws:
      LDAPException - If the provided entry contains any schema element definitions that cannot be parsed.
    • getSchema

      @Nullable public static Schema getSchema(@NotNull 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. Any unparsable schema elements will be silently ignored.
      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

      @Nullable public static Schema getSchema(@NotNull LDAPConnection connection, @Nullable 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. Any unparsable schema elements will be silently ignored.
      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

      @Nullable public static Schema getSchema(@NotNull LDAPConnection connection, @Nullable String entryDN, boolean throwOnUnparsableElement) 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. This method may optionally throw an exception if the retrieved schema contains one or more unparsable schema elements.
      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.
      throwOnUnparsableElement - Indicates whether to throw an exception if the schema entry that is retrieved has one or more unparsable schema elements.
      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, or if the schema contains one or more unparsable elements and throwOnUnparsableElement is true.
    • getSchema

      @Nullable public static Schema getSchema(@NotNull String... schemaFiles) throws 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. Any unparsable schema elements will be silently ignored.
      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:
      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

      @Nullable public static Schema getSchema(@NotNull File... schemaFiles) throws 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. Any unparsable schema elements will be silently ignored.
      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:
      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

      @Nullable public static Schema getSchema(@NotNull List<File> schemaFiles) throws 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. Any unparsable schema elements will be silently ignored.
      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:
      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

      @Nullable public static Schema getSchema(@NotNull List<File> schemaFiles, boolean throwOnUnparsableElement) throws 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.
      throwOnUnparsableElement - Indicates whether to throw an exception if the schema entry that is retrieved has one or more unparsable schema elements.
      Returns:
      The schema read from the specified schema files, or null if none of the files contains any LDIF data to be read.
      Throws:
      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. If throwOnUnparsableElement is true, then this may also be thrown if any of the schema files contains any unparsable schema elements.
    • getSchema

      Reads schema information from the provided input stream. The information should be in LDIF form, with the definitions represented in the form described in section 4.1 of RFC 4512. Only a single entry will be read from the input stream, and it will be closed at the end of this method.
      Parameters:
      inputStream - The input stream from which the schema entry will be read. It must not be null, and it will be closed when this method returns.
      Returns:
      The schema read from the provided input stream, or null if the end of the input stream is reached without reading any data.
      Throws:
      IOException - If a problem is encountered while attempting to read from the provided input stream.
      LDIFException - If a problem occurs while attempting to parse the data read as LDIF.
    • 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.
      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

      @Nullable public static Schema mergeSchemas(@NotNull 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

      Retrieves the entry used to create this schema object.
      Returns:
      The entry used to create this schema object.
    • getSubschemaSubentryDN

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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

      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 Object
      Returns:
      A hash code for this schema object.
    • equals

      public boolean equals(@Nullable Object o)
      Indicates whether the provided object is equal to this schema object.
      Overrides:
      equals in class 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

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