org.opends.server.types
Class RDN

java.lang.Object
  extended by org.opends.server.types.RDN
All Implemented Interfaces:
java.lang.Comparable<RDN>

@PublicAPI(stability=UNCOMMITTED,
           mayInstantiate=true,
           mayExtend=false,
           mayInvoke=true)
public final class RDN
extends java.lang.Object
implements java.lang.Comparable<RDN>

This class defines a data structure for storing and interacting with the relative distinguished names associated with entries in the Directory Server.


Constructor Summary
RDN(AttributeType[] attributeTypes, java.lang.String[] attributeNames, AttributeValue[] attributeValues)
          Creates a new RDN with the provided information.
RDN(AttributeType attributeType, AttributeValue attributeValue)
          Creates a new RDN with the provided information.
RDN(AttributeType attributeType, java.lang.String attributeName, AttributeValue attributeValue)
          Creates a new RDN with the provided information.
RDN(java.util.List<AttributeType> attributeTypes, java.util.List<java.lang.String> attributeNames, java.util.List<AttributeValue> attributeValues)
          Creates a new RDN with the provided information.
 
Method Summary
 int compareTo(RDN rdn)
          Compares this RDN with the provided RDN based on an alphabetic comparison of the attribute names and values.
static RDN create(AttributeType attributeType, AttributeValue attributeValue)
          Creates a new RDN with the provided information.
static RDN decode(java.lang.String rdnString)
          Decodes the provided string as an RDN.
 RDN duplicate()
          Creates a duplicate of this RDN that can be modified without impacting this RDN.
 boolean equals(java.lang.Object o)
          Indicates whether the provided object is equal to this RDN.
 java.lang.String getAttributeName(int pos)
          Retrieves the name for the attribute type at the specified position in the set of attribute types for this RDN.
 AttributeType getAttributeType(int pos)
          Retrieves the attribute type at the specified position in the set of attribute types for this RDN.
 AttributeValue getAttributeValue(AttributeType attributeType)
          Retrieves the attribute value that is associated with the specified attribute type.
 AttributeValue getAttributeValue(int pos)
          Retrieves the value for the attribute type at the specified position in the set of attribute types for this RDN.
 int getNumValues()
          Retrieves the number of attribute-value pairs contained in this RDN.
 boolean hasAttributeType(AttributeType attributeType)
          Indicates whether this RDN includes the specified attribute type.
 boolean hasAttributeType(java.lang.String lowerName)
          Indicates whether this RDN includes the specified attribute type.
 int hashCode()
          Retrieves the hash code for this RDN.
 boolean hasValue(AttributeType type, AttributeValue value)
          Indicates whether this RDN contains the specified type-value pair.
 boolean isMultiValued()
          Indicates whether this RDN is multivalued.
 java.lang.String toNormalizedString()
          Retrieves a normalized string representation of this RDN.
 void toNormalizedString(java.lang.StringBuilder buffer)
          Appends a normalized string representation of this RDN to the provided buffer.
 java.lang.String toString()
          Retrieves a string representation of this RDN.
 void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this RDN to the provided buffer.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RDN

public RDN(AttributeType attributeType,
           AttributeValue attributeValue)
Creates a new RDN with the provided information.

Parameters:
attributeType - The attribute type for this RDN. It must not be null.
attributeValue - The value for this RDN. It must not be null.

RDN

public RDN(AttributeType attributeType,
           java.lang.String attributeName,
           AttributeValue attributeValue)
Creates a new RDN with the provided information.

Parameters:
attributeType - The attribute type for this RDN. It must not be null.
attributeName - The user-provided name for this RDN. It must not be null.
attributeValue - The value for this RDN. It must not be null.

RDN

public RDN(java.util.List<AttributeType> attributeTypes,
           java.util.List<java.lang.String> attributeNames,
           java.util.List<AttributeValue> attributeValues)
Creates a new RDN with the provided information. The number of type, name, and value elements must be nonzero and equal.

Parameters:
attributeTypes - The set of attribute types for this RDN. It must not be empty or null.
attributeNames - The set of user-provided names for this RDN. It must have the same number of elements as the attributeTypes argument.
attributeValues - The set of values for this RDN. It must have the same number of elements as the attributeTypes argument.

RDN

public RDN(AttributeType[] attributeTypes,
           java.lang.String[] attributeNames,
           AttributeValue[] attributeValues)
Creates a new RDN with the provided information. The number of type, name, and value elements must be nonzero and equal.

Parameters:
attributeTypes - The set of attribute types for this RDN. It must not be empty or null.
attributeNames - The set of user-provided names for this RDN. It must have the same number of elements as the attributeTypes argument.
attributeValues - The set of values for this RDN. It must have the same number of elements as the attributeTypes argument.
Method Detail

create

public static RDN create(AttributeType attributeType,
                         AttributeValue attributeValue)
Creates a new RDN with the provided information.

Parameters:
attributeType - The attribute type for this RDN. It must not be null.
attributeValue - The value for this RDN. It must not be null.
Returns:
The RDN created with the provided information.

getNumValues

public int getNumValues()
Retrieves the number of attribute-value pairs contained in this RDN.

Returns:
The number of attribute-value pairs contained in this RDN.

hasAttributeType

public boolean hasAttributeType(AttributeType attributeType)
Indicates whether this RDN includes the specified attribute type.

Parameters:
attributeType - The attribute type for which to make the determination.
Returns:
true if the RDN includes the specified attribute type, or false if not.

hasAttributeType

public boolean hasAttributeType(java.lang.String lowerName)
Indicates whether this RDN includes the specified attribute type.

Parameters:
lowerName - The name or OID for the attribute type for which to make the determination, formatted in all lowercase characters.
Returns:
true if the RDN includes the specified attribute type, or false if not.

getAttributeType

public AttributeType getAttributeType(int pos)
Retrieves the attribute type at the specified position in the set of attribute types for this RDN.

Parameters:
pos - The position of the attribute type to retrieve.
Returns:
The attribute type at the specified position in the set of attribute types for this RDN.

getAttributeName

public java.lang.String getAttributeName(int pos)
Retrieves the name for the attribute type at the specified position in the set of attribute types for this RDN.

Parameters:
pos - The position of the attribute type for which to retrieve the name.
Returns:
The name for the attribute type at the specified position in the set of attribute types for this RDN.

getAttributeValue

public AttributeValue getAttributeValue(AttributeType attributeType)
Retrieves the attribute value that is associated with the specified attribute type.

Parameters:
attributeType - The attribute type for which to retrieve the corresponding value.
Returns:
The value for the requested attribute type, or null if the specified attribute type is not present in the RDN.

getAttributeValue

public AttributeValue getAttributeValue(int pos)
Retrieves the value for the attribute type at the specified position in the set of attribute types for this RDN.

Parameters:
pos - The position of the attribute type for which to retrieve the value.
Returns:
The value for the attribute type at the specified position in the set of attribute types for this RDN.

isMultiValued

public boolean isMultiValued()
Indicates whether this RDN is multivalued.

Returns:
true if this RDN is multivalued, or false if not.

hasValue

public boolean hasValue(AttributeType type,
                        AttributeValue value)
Indicates whether this RDN contains the specified type-value pair.

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

decode

public static RDN decode(java.lang.String rdnString)
                  throws DirectoryException
Decodes the provided string as an RDN.

Parameters:
rdnString - The string to decode as an RDN.
Returns:
The decoded RDN.
Throws:
DirectoryException - If a problem occurs while trying to decode the provided string as a RDN.

duplicate

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

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

equals

public boolean equals(java.lang.Object o)
Indicates whether the provided object is equal to this RDN. It will only be considered equal if it is an RDN object that contains the same number of elements in the same order with the same types and normalized values.

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

hashCode

public int hashCode()
Retrieves the hash code for this RDN. It will be calculated as the sum of the hash codes of the types and values.

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

toString

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

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

toString

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

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

toNormalizedString

public java.lang.String toNormalizedString()
Retrieves a normalized string representation of this RDN.

Returns:
A normalized string representation of this RDN.

toNormalizedString

public void toNormalizedString(java.lang.StringBuilder buffer)
Appends a normalized string representation of this RDN to the provided buffer.

Parameters:
buffer - The buffer to which to append the information.

compareTo

public int compareTo(RDN rdn)
Compares this RDN with the provided RDN based on an alphabetic comparison of the attribute names and values.

Specified by:
compareTo in interface java.lang.Comparable<RDN>
Parameters:
rdn - The RDN against which to compare this RDN.
Returns:
A negative integer if this RDN should come before the provided RDN, a positive integer if this RDN should come after the provided RDN, or zero if there is no difference with regard to ordering.