Class AttributeDescription

java.lang.Object
org.forgerock.opendj.ldap.AttributeDescription
All Implemented Interfaces:
Comparable<AttributeDescription>

public final class AttributeDescription extends Object implements Comparable<AttributeDescription>
An attribute description as defined in RFC 4512 section 2.5. Attribute descriptions are used to identify an attribute in an entry and are composed of an attribute type and a set of zero or more attribute options.
See Also:
  • Method Details

    • withOption

      public AttributeDescription withOption(String option)
      Returns an attribute description having the same attribute type and options as this attribute description as well as the provided option.
      Parameters:
      option - The attribute option.
      Returns:
      The new attribute description containing option.
      Throws:
      NullPointerException - If option was null.
    • withOptions

      public AttributeDescription withOptions(Iterable<String> options)
      Returns an attribute description having the same attribute type and options as this attribute description as well as the provided options.
      Parameters:
      options - The attribute options.
      Returns:
      The new attribute description containing options.
      Throws:
      NullPointerException - If options was null.
    • withOptions

      public AttributeDescription withOptions(String... options)
      Returns an attribute description having the same attribute type and options as this attribute description as well as the provided options.
      Parameters:
      options - The attribute options.
      Returns:
      The new attribute description containing options.
      Throws:
      NullPointerException - If options was null.
    • withoutOption

      public AttributeDescription withoutOption(String option)
      Returns an attribute description having the same attribute type and options as this attribute description except for the provided option.

      This method is idempotent: if this attribute description does not contain the provided option then this attribute description will be returned.

      Parameters:
      option - The attribute option.
      Returns:
      The new attribute description excluding option.
      Throws:
      NullPointerException - If option was null.
    • withoutAnyOptions

      public AttributeDescription withoutAnyOptions()
      Returns an attribute description having the same attribute type as this attribute description except that all options has been removed.

      This method is idempotent: if this attribute description does not contain option then this attribute description will be returned.

      Returns:
      The new attribute description excluding all option.
      Throws:
      NullPointerException - If attributeDescription or option was null.
    • create

      public static AttributeDescription create(AttributeType attributeType)
      Creates an attribute description having the provided attribute type and no options.
      Parameters:
      attributeType - The attribute type.
      Returns:
      The attribute description.
      Throws:
      NullPointerException - If attributeType was null.
    • create

      public static AttributeDescription create(String attributeName, AttributeType attributeType)
      Creates an attribute description having the provided attribute name, type and no options.
      Parameters:
      attributeName - The attribute name.
      attributeType - The attribute type.
      Returns:
      The attribute description.
      Throws:
      NullPointerException - If attributeType was null.
    • maxKey

      public static AttributeDescription maxKey(AttributeType attributeType)
      Returns an attribute description having the provided attribute type and a set of options which sorts after any other set of options. This attribute description may be used in order to perform range queries on attribute description keyed collections such as SortedSets and SortedMaps. For example, the following code can be used to construct a range whose contents is all attributes having the same attribute type:
       
       SortedMap<AttributeDescription, Attribute> attributes = ...;
       AttributeType attributeType = ...;
      
       // Returns a map containing all attributes sharing the same attribute type.
       SortedMap<AttributeDescription, Attribute> subMap =
           attributes.subMap(attributeType.toAttributeDescription(), AttributeDescription.maxKey(attributeType));
       
       
      Parameters:
      attributeType - The attribute type.
      Returns:
      An attribute description having the provided attribute type and a set of options which sorts after any other set of options.
      Throws:
      NullPointerException - If attributeType was null.
    • create

      public static AttributeDescription create(AttributeType attributeType, String option)
      Creates an attribute description having the provided attribute type and single option.
      Parameters:
      attributeType - The attribute type.
      option - The attribute option.
      Returns:
      The attribute description.
      Throws:
      NullPointerException - If attributeType or option was null.
    • create

      public static AttributeDescription create(AttributeType attributeType, Collection<String> options)
      Creates an attribute description having the provided attribute type and options.
      Parameters:
      attributeType - The attribute type.
      options - The attribute options.
      Returns:
      The attribute description.
      Throws:
      NullPointerException - If attributeType or options was null.
    • create

      public static AttributeDescription create(AttributeType attributeType, String... options)
      Creates an attribute description having the provided attribute type and options.
      Parameters:
      attributeType - The attribute type.
      options - The attribute options.
      Returns:
      The attribute description.
      Throws:
      NullPointerException - If attributeType or options was null.
    • objectClass

      public static AttributeDescription objectClass()
      Returns an attribute description representing the object class attribute type with no options.
      Returns:
      The object class attribute description.
    • valueOf

      public static AttributeDescription valueOf(String attributeDescription)
      Parses the provided LDAP string representation of an attribute description using the default schema.
      Parameters:
      attributeDescription - The LDAP string representation of an attribute description.
      Returns:
      The parsed attribute description.
      Throws:
      UnknownSchemaElementException - If attributeDescription contains an attribute type which is not contained in the default schema and the schema is strict.
      LocalizedIllegalArgumentException - If attributeDescription is not a valid LDAP string representation of an attribute description.
      NullPointerException - If attributeDescription was null.
    • valueOf

      public static AttributeDescription valueOf(String attributeDescription, Schema schema)
      Parses the provided LDAP string representation of an attribute description using the provided schema.
      Parameters:
      attributeDescription - The LDAP string representation of an attribute description.
      schema - The schema to use when parsing the attribute description.
      Returns:
      The parsed attribute description.
      Throws:
      UnknownSchemaElementException - If attributeDescription contains an attribute type which is not contained in the provided schema and the schema is strict.
      LocalizedIllegalArgumentException - If attributeDescription is not a valid LDAP string representation of an attribute description.
      NullPointerException - If attributeDescription or schema was null.
    • compareTo

      public int compareTo(AttributeDescription other)
      Compares this attribute description to the provided attribute description. The attribute types are compared first and then, if equal, the options are normalized, sorted, and compared.
      Specified by:
      compareTo in interface Comparable<AttributeDescription>
      Parameters:
      other - The attribute description to be compared.
      Returns:
      A negative integer, zero, or a positive integer as this attribute description is less than, equal to, or greater than the specified attribute description.
      Throws:
      NullPointerException - If name was null.
    • hasOption

      public boolean hasOption(String option)
      Indicates whether this attribute description contains the provided option.
      Parameters:
      option - The option for which to make the determination.
      Returns:
      true if this attribute description has the provided option, or false if not.
      Throws:
      NullPointerException - If option was null.
    • equals

      public boolean equals(Object o)
      Indicates whether the provided object is an attribute description which is equal to this attribute description. It will be considered equal if the attribute types are equal and normalized sorted list of options are identical.
      Overrides:
      equals in class Object
      Parameters:
      o - The object for which to make the determination.
      Returns:
      true if the provided object is an attribute description that is equal to this attribute description, or false if not.
    • getAttributeType

      public AttributeType getAttributeType()
      Returns the attribute type associated with this attribute description.
      Returns:
      The attribute type associated with this attribute description.
    • getOptions

      public Iterable<String> getOptions()
      Returns an Iterable containing the options contained in this attribute description. Attempts to remove options using an iterator's remove() method are not permitted and will result in an UnsupportedOperationException being thrown.
      Returns:
      An Iterable containing the options.
    • hashCode

      public int hashCode()
      Returns the hash code for this attribute description. It will be calculated as the sum of the hash codes of the attribute type and normalized sorted list of options.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code for this attribute description.
    • hasOptions

      public boolean hasOptions()
      Indicates whether this attribute description has any options.
      Returns:
      true if this attribute description has any options, or false if not.
    • isObjectClass

      public boolean isObjectClass()
      Indicates whether this attribute description is the objectClass attribute description with no options.
      Returns:
      true if this attribute description is the objectClass attribute description with no options, or false if not.
    • isPlaceHolder

      public boolean isPlaceHolder()
      Indicates whether this attribute description is a temporary place-holder allocated dynamically by a non-strict schema when no corresponding registered attribute type was found.

      Place holder attribute descriptions have an attribute type whose OID is the normalized attribute name with the string -oid appended. In addition, they will use the directory string syntax and case ignore matching rule.

      Returns:
      true if this is a temporary place-holder attribute description allocated dynamically by a non-strict schema when no corresponding registered attribute type was found.
      See Also:
    • isSubTypeOf

      public boolean isSubTypeOf(AttributeDescription other)
      Indicates whether this attribute description is a sub-type of the provided attribute description as defined in RFC 4512 section 2.5. Specifically, this method will return true if and only if the following conditions are both true:
      • This attribute description has an attribute type which matches, or is a sub-type of, the attribute type in the provided attribute description.
      • This attribute description contains all of the options contained in the provided attribute description.
      Note that this method will return true if this attribute description is equal to the provided attribute description.
      Parameters:
      other - The attribute description for which to make the determination.
      Returns:
      true if this attribute description is a sub-type of the provided attribute description, or false if not.
      Throws:
      NullPointerException - If name was null.
    • isSuperTypeOf

      public boolean isSuperTypeOf(AttributeDescription other)
      Indicates whether this attribute description is a super-type of the provided attribute description as defined in RFC 4512 section 2.5. Specifically, this method will return true if and only if the following conditions are both true:
      • This attribute description has an attribute type which matches, or is a super-type of, the attribute type in the provided attribute description.
      • This attribute description contains a sub-set of the options contained in the provided attribute description.
      Note that this method will return true if this attribute description is equal to the provided attribute description.
      Parameters:
      other - The attribute description for which to make the determination.
      Returns:
      true if this attribute description is a super-type of the provided attribute description, or false if not.
      Throws:
      NullPointerException - If name was null.
    • matches

      public boolean matches(AttributeDescription other)
      Indicates whether the provided attribute description matches this attribute description. It will be considered a match if the attribute types match and the normalized sorted list of options are identical.
      Parameters:
      other - The attribute description for which to make the determination.
      Returns:
      true if the provided attribute description matches this attribute description, or false if not.
    • toString

      public String toString()
      Returns the string representation of this attribute description as defined in RFC4512 section 2.5.
      Overrides:
      toString in class Object
      Returns:
      The string representation of this attribute description.