org.opends.server.types
Class Attribute

java.lang.Object
  extended by org.opends.server.types.Attribute
Direct Known Subclasses:
VirtualAttribute

@PublicAPI(stability=UNCOMMITTED,
           mayInstantiate=true,
           mayExtend=false,
           mayInvoke=true)
public class Attribute
extends java.lang.Object

This class defines a data structure for storing and interacting with an attribute that may be used in the Directory Server.


Constructor Summary
Attribute(AttributeType attributeType)
          Creates a new attribute with the specified type.
Attribute(AttributeType attributeType, java.lang.String name)
          Creates a new attribute with the specified type and user-provided name.
Attribute(AttributeType attributeType, java.lang.String name, java.util.LinkedHashSet<AttributeValue> values)
          Creates a new attribute with the specified type, user-provided name, and set of values.
Attribute(AttributeType attributeType, java.lang.String name, java.util.LinkedHashSet<java.lang.String> options, java.util.LinkedHashSet<AttributeValue> values)
          Creates a new attribute with the specified type, user-provided name, and set of values.
Attribute(java.lang.String lowerName, java.lang.String valueString)
          Creates a new attribute with the specified name and value.
 
Method Summary
 ConditionResult approximatelyEqualTo(AttributeValue value)
          Indicates whether this attribute has any value(s) that are approximately equal to the provided value.
 Attribute duplicate()
          Creates a duplicate of this attribute that can be modified without impacting this attribute.
 Attribute duplicate(boolean omitValues)
          Creates a duplicate of this attribute that can be modified without impacting this attribute.
 boolean equals(java.lang.Object o)
          Indicates whether the provided object is an attribute that is equal to this attribute.
 AttributeType getAttributeType()
          Retrieves the attribute type for this attribute.
 java.lang.String getName()
          Retrieves the user-provided name for this attribute.
 java.lang.String getNameWithOptions()
          Retrieves the user-provided name of the attribute, along with any options that might have been provided.
 java.util.LinkedHashSet<java.lang.String> getOptions()
          Retrieves the set of attribute options for this attribute.
 java.util.LinkedHashSet<AttributeValue> getValues()
          Retrieves the set of values for this attribute.
 ConditionResult greaterThanOrEqualTo(AttributeValue value)
          Indicates whether this attribute has any value(s) that are greater than or equal to the provided value.
 boolean hasAllValues(java.util.Collection<AttributeValue> values)
          Indicates whether this attribute contains all the values in the collection.
 boolean hasAnyValue(java.util.Collection<AttributeValue> values)
          Indicates whether this attribute contains any of the values in the collection.
 int hashCode()
          Retrieves the hash code for this attribute.
 boolean hasOption(java.lang.String option)
          Indicates whether this attribute has the specified option.
 boolean hasOptions()
          Indicates whether this attribute has any options at all.
 boolean hasOptions(java.util.Collection<java.lang.String> options)
          Indicates whether this attribute has all of the options in the provided collection.
 boolean hasValue()
          Indicates whether this attribute contains one or more values.
 boolean hasValue(AttributeValue value)
          Indicates whether this attribute contains the specified value.
 boolean isVirtual()
          Indicates whether this is a virtual attribute rather than a real attribute.
 ConditionResult lessThanOrEqualTo(AttributeValue value)
          Indicates whether this attribute has any value(s) that are less than or equal to the provided value.
 ConditionResult matchesSubstring(ByteString subInitial, java.util.List<ByteString> subAny, ByteString subFinal)
          Indicates whether this attribute has any value(s) that match the provided substring.
 boolean optionsEqual(java.util.Set<java.lang.String> options)
          Indicates whether this attribute has exactly the set of options in the provided set.
 void setValues(java.util.LinkedHashSet<AttributeValue> values)
          Specifies the set of values for this attribute.
 java.lang.String toLDIF()
          Retrieves a string representation of this attribute in LDIF form.
 void toLDIF(java.lang.StringBuilder buffer)
          Appends a string representation of this attribute in LDIF form to the provided buffer.
 java.lang.String toString()
          Retrieves a one-line string representation of this attribute.
 void toString(java.lang.StringBuilder buffer)
          Appends a one-line string representation of this attribute to the provided buffer.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Attribute

public Attribute(AttributeType attributeType)
Creates a new attribute with the specified type. It will not have any values.

Parameters:
attributeType - The attribute type for this attribute.

Attribute

public Attribute(AttributeType attributeType,
                 java.lang.String name)
Creates a new attribute with the specified type and user-provided name. It will not have any values.

Parameters:
attributeType - The attribute type for this attribute.
name - The user-provided name for this attribute.

Attribute

public Attribute(AttributeType attributeType,
                 java.lang.String name,
                 java.util.LinkedHashSet<AttributeValue> values)
Creates a new attribute with the specified type, user-provided name, and set of values.

Parameters:
attributeType - The attribute type for this attribute.
name - The user-provided name for this attribute.
values - The set of values for this attribute.

Attribute

public Attribute(java.lang.String lowerName,
                 java.lang.String valueString)
Creates a new attribute with the specified name and value.

Parameters:
lowerName - The name or OID of the attribute type for this attribute, formatted in all lowercase characters.
valueString - The String representation of the attribute value.

Attribute

public Attribute(AttributeType attributeType,
                 java.lang.String name,
                 java.util.LinkedHashSet<java.lang.String> options,
                 java.util.LinkedHashSet<AttributeValue> values)
Creates a new attribute with the specified type, user-provided name, and set of values.

Parameters:
attributeType - The attribute type for this attribute.
name - The user-provided name for this attribute.
options - The set of options for this attribute.
values - The set of values for this attribute.
Method Detail

getAttributeType

public AttributeType getAttributeType()
Retrieves the attribute type for this attribute.

Returns:
The attribute type for this attribute.

getName

public java.lang.String getName()
Retrieves the user-provided name for this attribute.

Returns:
The user-provided name for this attribute.

getNameWithOptions

public java.lang.String getNameWithOptions()
Retrieves the user-provided name of the attribute, along with any options that might have been provided.

Returns:
The user-provided name of the attribute, along with any options that might have been provided.

getOptions

public java.util.LinkedHashSet<java.lang.String> getOptions()
Retrieves the set of attribute options for this attribute.

Returns:
The set of attribute options for this attribute.

hasOption

public boolean hasOption(java.lang.String option)
Indicates whether this attribute has the specified option.

Parameters:
option - The option for which to make the determination.
Returns:
true if this attribute has the specified option, or false if not.

hasOptions

public boolean hasOptions()
Indicates whether this attribute has any options at all.

Returns:
true if this attribute has at least one option, or false if not.

hasOptions

public boolean hasOptions(java.util.Collection<java.lang.String> options)
Indicates whether this attribute has all of the options in the provided collection.

Parameters:
options - The collection of options for which to make the determination.
Returns:
true if this attribute has all of the specified options, or false if it does not have at least one of them.

optionsEqual

public boolean optionsEqual(java.util.Set<java.lang.String> options)
Indicates whether this attribute has exactly the set of options in the provided set.

Parameters:
options - The set of options for which to make the determination.
Returns:
true if this attribute has exactly the specified set of options, or false if the set of options is different in any way.

getValues

public java.util.LinkedHashSet<AttributeValue> getValues()
Retrieves the set of values for this attribute. The returned set of values may be altered by the caller.

Returns:
The set of values for this attribute.

setValues

public void setValues(java.util.LinkedHashSet<AttributeValue> values)
Specifies the set of values for this attribute.

Parameters:
values - The set of values for this attribute.

hasValue

public boolean hasValue()
Indicates whether this attribute contains one or more values.

Returns:
true if this attribute contains one or more values, or false if it does not.

hasValue

public boolean hasValue(AttributeValue value)
Indicates whether this attribute contains the specified value.

Parameters:
value - The value for which to make the determination.
Returns:
true if this attribute has the specified value, or false if not.

hasAllValues

public boolean hasAllValues(java.util.Collection<AttributeValue> values)
Indicates whether this attribute contains all the values in the collection.

Parameters:
values - The set of values for which to make the determination.
Returns:
true if this attribute contains all the values in the provided collection, or false if it does not contain at least one of them.

hasAnyValue

public boolean hasAnyValue(java.util.Collection<AttributeValue> values)
Indicates whether this attribute contains any of the values in the collection.

Parameters:
values - The set of values for which to make the determination.
Returns:
true if this attribute contains at least one of the values in the provided collection, or false if it does not contain any of the values.

matchesSubstring

public ConditionResult matchesSubstring(ByteString subInitial,
                                        java.util.List<ByteString> subAny,
                                        ByteString subFinal)
Indicates whether this attribute has any value(s) that match the provided substring.

Parameters:
subInitial - The subInitial component to use in the determination.
subAny - The subAny components to use in the determination.
subFinal - The subFinal component to use in the determination.
Returns:
UNDEFINED if this attribute does not have a substring matching rule, TRUE if at least one value matches the provided substring, or FALSE otherwise.

greaterThanOrEqualTo

public ConditionResult greaterThanOrEqualTo(AttributeValue value)
Indicates whether this attribute has any value(s) that are greater than or equal to the provided value.

Parameters:
value - The value for which to make the determination.
Returns:
UNDEFINED if this attribute does not have an ordering matching rule, TRUE if at least one value is greater than or equal to the provided value, or false otherwise.

lessThanOrEqualTo

public ConditionResult lessThanOrEqualTo(AttributeValue value)
Indicates whether this attribute has any value(s) that are less than or equal to the provided value.

Parameters:
value - The value for which to make the determination.
Returns:
UNDEFINED if this attribute does not have an ordering matching rule, TRUE if at least one value is less than or equal to the provided value, or false otherwise.

approximatelyEqualTo

public ConditionResult approximatelyEqualTo(AttributeValue value)
Indicates whether this attribute has any value(s) that are approximately equal to the provided value.

Parameters:
value - The value for which to make the determination.
Returns:
UNDEFINED if this attribute does not have an approximate matching rule, TRUE if at least one value is approximately equal to the provided value, or false otherwise.

isVirtual

public boolean isVirtual()
Indicates whether this is a virtual attribute rather than a real attribute.

Returns:
true if this is a virtual attribute, or false if it is a real attribute.

duplicate

public Attribute duplicate()
Creates a duplicate of this attribute that can be modified without impacting this attribute.

Returns:
A duplicate of this attribute that can be modified without impacting this attribute.

duplicate

public Attribute duplicate(boolean omitValues)
Creates a duplicate of this attribute that can be modified without impacting this attribute.

Parameters:
omitValues - true if the values should be omitted.
Returns:
A duplicate of this attribute that can be modified without impacting this attribute.

equals

public boolean equals(java.lang.Object o)
Indicates whether the provided object is an attribute that is equal to this attribute. It will be considered equal if the attribute type, set of values, and set of options are equal.

Overrides:
equals in class java.lang.Object
Parameters:
o - The object for which to make the determination.
Returns:
true if the provided object is an attribute that is equal to this attribute, or false if not.

hashCode

public int hashCode()
Retrieves the hash code for this attribute. It will be calculated as the sum of the hash code for the attribute type and all values.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code for this attribute.

toString

public java.lang.String toString()
Retrieves a one-line string representation of this attribute.

Overrides:
toString in class java.lang.Object
Returns:
A one-line string representation of this attribute.

toString

public void toString(java.lang.StringBuilder buffer)
Appends a one-line string representation of this attribute to the provided buffer.

Parameters:
buffer - The buffer to which the information should be appended.

toLDIF

public java.lang.String toLDIF()
Retrieves a string representation of this attribute in LDIF form.

Returns:
A string representation of this attribute in LDIF form.

toLDIF

public void toLDIF(java.lang.StringBuilder buffer)
Appends a string representation of this attribute in LDIF form to the provided buffer.

Parameters:
buffer - The buffer to which the information should be appended.