Package org.forgerock.opendj.ldap
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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(AttributeDescription other)
Compares this attribute description to the provided attribute description.static AttributeDescription
create(String attributeName, AttributeType attributeType)
Creates an attribute description having the provided attribute name, type and no options.static AttributeDescription
create(AttributeType attributeType)
Creates an attribute description having the provided attribute type and no options.static AttributeDescription
create(AttributeType attributeType, String option)
Creates an attribute description having the provided attribute type and single option.static AttributeDescription
create(AttributeType attributeType, String... options)
Creates an attribute description having the provided attribute type and options.static AttributeDescription
create(AttributeType attributeType, Collection<String> options)
Creates an attribute description having the provided attribute type and options.boolean
equals(Object o)
Indicates whether the provided object is an attribute description which is equal to this attribute description.AttributeType
getAttributeType()
Returns the attribute type associated with this attribute description.Iterable<String>
getOptions()
Returns anIterable
containing the options contained in this attribute description.int
hashCode()
Returns the hash code for this attribute description.boolean
hasOption(String option)
Indicates whether this attribute description contains the provided option.boolean
hasOptions()
Indicates whether this attribute description has any options.boolean
isObjectClass()
Indicates whether this attribute description is theobjectClass
attribute description with no options.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.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.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.boolean
matches(AttributeDescription other)
Indicates whether the provided attribute description matches this attribute description.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.static AttributeDescription
objectClass()
Returns an attribute description representing the object class attribute type with no options.String
toString()
Returns the string representation of this attribute description as defined in RFC4512 section 2.5.static AttributeDescription
valueOf(String attributeDescription)
Parses the provided LDAP string representation of an attribute description using the default schema.static AttributeDescription
valueOf(String attributeDescription, Schema schema)
Parses the provided LDAP string representation of an attribute description using the provided schema.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.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.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.AttributeDescription
withoutAnyOptions()
Returns an attribute description having the same attribute type as this attribute description except that all options has been removed.AttributeDescription
withoutOption(String option)
Returns an attribute description having the same attribute type and options as this attribute description except for the provided option.
-
-
-
Method Detail
-
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
- Ifoption
wasnull
.
-
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
- Ifoptions
wasnull
.
-
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
- Ifoptions
wasnull
.
-
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
- Ifoption
wasnull
.
-
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
- IfattributeDescription
oroption
wasnull
.
-
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
- IfattributeType
wasnull
.
-
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
- IfattributeType
wasnull
.
-
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 asSortedSet
s andSortedMap
s. 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
- IfattributeType
wasnull
.
-
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
- IfattributeType
oroption
wasnull
.
-
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
- IfattributeType
oroptions
wasnull
.
-
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
- IfattributeType
oroptions
wasnull
.
-
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
- IfattributeDescription
contains an attribute type which is not contained in the default schema and the schema is strict.LocalizedIllegalArgumentException
- IfattributeDescription
is not a valid LDAP string representation of an attribute description.NullPointerException
- IfattributeDescription
wasnull
.
-
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
- IfattributeDescription
contains an attribute type which is not contained in the provided schema and the schema is strict.LocalizedIllegalArgumentException
- IfattributeDescription
is not a valid LDAP string representation of an attribute description.NullPointerException
- IfattributeDescription
orschema
wasnull
.
-
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 interfaceComparable<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
- Ifname
wasnull
.
-
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, orfalse
if not.- Throws:
NullPointerException
- Ifoption
wasnull
.
-
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 areequal
and normalized sorted list of options are identical.
-
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 anIterable
containing the options contained in this attribute description. Attempts to remove options using an iterator'sremove()
method are not permitted and will result in anUnsupportedOperationException
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.
-
hasOptions
public boolean hasOptions()
Indicates whether this attribute description has any options.- Returns:
true
if this attribute description has any options, orfalse
if not.
-
isObjectClass
public boolean isObjectClass()
Indicates whether this attribute description is theobjectClass
attribute description with no options.- Returns:
true
if this attribute description is theobjectClass
attribute description with no options, orfalse
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:
Schema.getAttributeType(String)
,AttributeType.isPlaceHolder()
-
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 returntrue
if and only if the following conditions are bothtrue
:- 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.
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, orfalse
if not.- Throws:
NullPointerException
- Ifname
wasnull
.
- This attribute description has an attribute type which
-
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 returntrue
if and only if the following conditions are bothtrue
:- 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.
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, orfalse
if not.- Throws:
NullPointerException
- Ifname
wasnull
.
- This attribute description has an attribute type which
-
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 typesmatch
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, orfalse
if not.
-
-