org.opends.server.types
Class AbstractAttribute

java.lang.Object
  extended by org.opends.server.types.AbstractAttribute
All Implemented Interfaces:
java.lang.Iterable<AttributeValue>, Attribute
Direct Known Subclasses:
CollectiveVirtualAttribute, VirtualAttribute

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

An abstract base class for implementing new types of Attribute.


Constructor Summary
protected AbstractAttribute()
          Creates a new abstract attribute.
 
Method Summary
 boolean containsAll(java.util.Collection<AttributeValue> values)
          Indicates whether this attribute contains all the values in the collection.
 boolean equals(java.lang.Object o)
          Indicates whether the provided object is an attribute that is equal to this attribute.
 java.lang.String getName()
          Retrieves the user-provided name for this attribute.
 java.lang.String getNameWithOptions()
          Retrieves the user-provided name of this attribute, along with any options that might have been provided.
 boolean hasAllOptions(java.util.Collection<java.lang.String> options)
          Indicates whether this attribute has all of the options in the provided 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 isEmpty()
          Returns true if this attribute contains no attribute values.
 boolean optionsEqual(java.util.Set<java.lang.String> options)
          Indicates whether this attribute has exactly the specified set of options.
 java.lang.String toString()
          Retrieves a one-line string representation of this attribute.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opends.server.types.Attribute
approximatelyEqualTo, contains, getAttributeType, getOptions, greaterThanOrEqualTo, isVirtual, iterator, lessThanOrEqualTo, matchesSubstring, size, toString
 

Constructor Detail

AbstractAttribute

protected AbstractAttribute()
Creates a new abstract attribute.

Method Detail

containsAll

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

This implementation iterates through each attribute value in the provided collection, checking to see if this attribute contains the value using Attribute.contains(AttributeValue).

Specified by:
containsAll in interface Attribute
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.

equals

public final 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.

Specified by:
equals in interface Attribute
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.

getName

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

This implementation returns the primary name associated with this attribute's attribute type or, if there is no primary name, the attribute type's OID.

Specified by:
getName in interface Attribute
Returns:
The user-provided name for this attribute.

getNameWithOptions

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

This implementation returns this attribute's name if there are no attribute options, otherwise it constructs a string comprising of this attribute's name followed by a semi-colon and a semi-colon separated list of its attribute options.

Specified by:
getNameWithOptions in interface Attribute
Returns:
The user-provided name of this attribute, along with any options that might have been provided.

hasAllOptions

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

This implementation returns true if the provided collection of options is null or empty. If the collection is non-empty and this attribute does not have any options then it returns false. Otherwise, each option in the provided collection is checked using hasOption(String) and true is returned if all the provided options are present.

Specified by:
hasAllOptions in interface Attribute
Parameters:
options - The collection of options for which to make the determination (may be null).
Returns:
true if this attribute has all of the specified options, or false if it does not have at least one of them.

hashCode

public final 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.

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

hasOption

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

This implementation calls Attribute.getOptions() to retrieve this attribute's set of options and then compares them one at a time against the provided option. All comparisons are case insensitive (this is why we iterate through the set of options, rather than doing a simpler set membership test).

Specified by:
hasOption in interface Attribute
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.

This implementation retrieves the set of options associated with this attribute and tests to see if it is empty.

Specified by:
hasOptions in interface Attribute
Returns:
true if this attribute has at least one option, or false if not.

isEmpty

public boolean isEmpty()
Returns true if this attribute contains no attribute values.

This implementation returns true if the Attribute.size() of this attribute is zero.

Specified by:
isEmpty in interface Attribute
Returns:
true if this attribute contains no attribute values.

optionsEqual

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

This implementation returns !hasOptions() if the provided set of options is null. Otherwise it checks that the size of the provided set of options is equal to the size of this attribute's options, return false if the sizes differ. If the sizes are the same then each option in the provided set is checked using hasOption(String) and true is returned if all the provided options are present.

Specified by:
optionsEqual in interface Attribute
Parameters:
options - The set of options for which to make the determination (may be null).
Returns:
true if this attribute has exactly the specified set of options.

toString

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

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