org.opends.server.types
Class AttributeValue

java.lang.Object
  extended by org.opends.server.types.AttributeValue

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

This class defines a data structure that holds information about a single value of an attribute. It will always store the value in user-provided form, and will also store either a reference to the associated attribute type or the normalized form of the value. The normalized form of the value should only be used in cases where equality matching between two values can be performed with byte-for-byte comparisons of the normalized values.


Constructor Summary
AttributeValue(AttributeType attributeType, ByteString value)
          Creates a new attribute value with the provided information.
AttributeValue(AttributeType attributeType, java.lang.String value)
          Creates a new attribute value with the provided information.
AttributeValue(ByteString value, ByteString normalizedValue)
          Creates a new attribute value with the provided information.
 
Method Summary
 boolean equals(java.lang.Object o)
          Determines whether this attribute value is equal to the provided object.
 java.lang.String getNormalizedStringValue()
          Retrieves a string representation of the normalized form of this attribute value.
 ByteString getNormalizedValue()
          Retrieves the normalized form of this attribute value.
 byte[] getNormalizedValueBytes()
          Retrieves the bytes that make up the normalized form of this value.
 java.lang.String getStringValue()
          Retrieves a string representation of the user-defined form of this attribute value.
 ByteString getValue()
          Retrieves the user-defined form of this attribute value.
 byte[] getValueBytes()
          Retrieves the raw bytes that make up this attribute value.
 int hashCode()
          Retrieves the hash code for this attribute value.
 java.lang.String toString()
          Retrieves a string representation of this attribute value.
 void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this attribute value to the provided buffer.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AttributeValue

public AttributeValue(AttributeType attributeType,
                      ByteString value)
Creates a new attribute value with the provided information.

Parameters:
attributeType - The attribute type for this attribute value. It must not be null.
value - The value in user-provided form for this attribute value. It must not be null.

AttributeValue

public AttributeValue(AttributeType attributeType,
                      java.lang.String value)
Creates a new attribute value with the provided information.

Parameters:
attributeType - The attribute type for this attribute value. It must not be null.
value - The value in user-provided form for this attribute value. It must not be null.

AttributeValue

public AttributeValue(ByteString value,
                      ByteString normalizedValue)
Creates a new attribute value with the provided information. Note that this version of the constructor should only be used for attribute types in which equality matching can be performed by byte-for-byte comparison of normalized values.

Parameters:
value - The user-provided form of this value. It must not be null.
normalizedValue - The normalized form of this value. It must not be null.
Method Detail

getValue

public ByteString getValue()
Retrieves the user-defined form of this attribute value.

Returns:
The user-defined form of this attribute value.

getValueBytes

public byte[] getValueBytes()
Retrieves the raw bytes that make up this attribute value.

Returns:
The raw bytes that make up this attribute value.

getStringValue

public java.lang.String getStringValue()
Retrieves a string representation of the user-defined form of this attribute value.

Returns:
The string representation of the user-defined form of this attribute value.

getNormalizedValue

public ByteString getNormalizedValue()
                              throws DirectoryException
Retrieves the normalized form of this attribute value.

Returns:
The normalized form of this attribute value.
Throws:
DirectoryException - If an error occurs while trying to normalize the value (e.g., if it is not acceptable for use with the associated equality matching rule).

getNormalizedValueBytes

public byte[] getNormalizedValueBytes()
                               throws DirectoryException
Retrieves the bytes that make up the normalized form of this value.

Returns:
The bytes that make up the normalized form of this value.
Throws:
DirectoryException - If an error occurs while trying to normalize the value (e.g., if it is not acceptable for use with the associated equality matching rule).

getNormalizedStringValue

public java.lang.String getNormalizedStringValue()
                                          throws DirectoryException
Retrieves a string representation of the normalized form of this attribute value.

Returns:
The string representation of the normalized form of this attribute value.
Throws:
DirectoryException - If an error occurs while trying to normalize the value (e.g., if it is not acceptable for use with the associated equality matching rule).

equals

public boolean equals(java.lang.Object o)
Determines whether this attribute value is equal to the provided object.

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

hashCode

public int hashCode()
Retrieves the hash code for this attribute value. It will be calculated as the sum of the first two bytes in the value, or the value of a single-byte value, or zero for an empty value.

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

toString

public java.lang.String toString()
Retrieves a string representation of this attribute value.

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

toString

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

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