org.apache.directory.shared.ldap.name
Class AttributeTypeAndValue

java.lang.Object
  extended by org.apache.directory.shared.ldap.name.AttributeTypeAndValue
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public class AttributeTypeAndValue
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable, java.io.Externalizable

A Attribute Type And Value, which is the basis of all RDN. It contains a type, and a value. The type must not be case sensitive. Superfluous leading and trailing spaces MUST have been trimmed before. The value MUST be in UTF8 format, according to RFC 2253. If the type is in OID form, then the value must be a hexadecimal string prefixed by a '#' character. Otherwise, the string must respect the RC 2253 grammar. No further normalization will be done, because we don't have any knowledge of the Schema definition in the parser. We will also keep a User Provided form of the atav (Attribute Type And Value), called upName.

Version:
$Rev: 686316 $, $Date: 2008-08-15 20:51:12 +0200 (Fr, 15 Aug 2008) $
Author:
Apache Directory Project
See Also:
Serialized Form

Constructor Summary
AttributeTypeAndValue()
          Construct an empty AttributeTypeAndValue
AttributeTypeAndValue(java.lang.String upType, java.lang.String normType, java.lang.Object upValue, java.lang.Object normValue)
          Construct an AttributeTypeAndValue.
 
Method Summary
 java.lang.Object clone()
          Implements the cloning.
 int compareTo(java.lang.Object object)
          Compares two NameComponents.
 int compareToIgnoreCase(java.lang.Object object)
          Compares two NameComponents.
 boolean equals(java.lang.Object obj)
           
 int getLength()
          Get the upName length
 java.lang.String getNormalizedValue()
          Get the normalized Value of a AttributeTypeAndValue
 java.lang.String getNormType()
          Get the normalized type of a AttributeTypeAndValue
 java.lang.Object getNormValue()
          Get the Value of a AttributeTypeAndValue
 int getStart()
          get the position in the original upName where this atav starts.
 java.lang.String getUpName()
          Get the user provided form of this attribute type and value
 java.lang.String getUpType()
          Get the user provided type of a AttributeTypeAndValue
 java.lang.Object getUpValue()
          Get the User Provided Value of a AttributeTypeAndValue
 int hashCode()
          Gets the hashcode of this object.
 java.lang.String normalize()
          A Normalized String representation of a AttributeTypeAndValue : - type is trimed and lowercased - value is trimed and lowercased, and special characters are escaped if needed.
 void readExternal(java.io.ObjectInput in)
           
 void setType(java.lang.String upType, java.lang.String type)
          Store a new type
 void setTypeNormalized(java.lang.String type)
          Store the type, after having trimmed and lowercased it.
 void setValue(java.lang.Object upValue, java.lang.Object normValue)
          Store the value of a AttributeTypeAndValue.
 void setValueNormalized(java.lang.String value)
          Store the value of a AttributeTypeAndValue, after having trimmed it.
 java.lang.String toString()
          A String representation of a AttributeTypeAndValue.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AttributeTypeAndValue

public AttributeTypeAndValue()
Construct an empty AttributeTypeAndValue


AttributeTypeAndValue

public AttributeTypeAndValue(java.lang.String upType,
                             java.lang.String normType,
                             java.lang.Object upValue,
                             java.lang.Object normValue)
                      throws javax.naming.InvalidNameException
Construct an AttributeTypeAndValue. The type and value are normalized :
  • the type is trimmed and lowercased
  • the value is trimmed
  • Note that the upValue should not be null or empty, or resolved to an empty string after having trimmed it.

    Parameters:
    upType - The Usrr Provided type
    normType - The normalized type
    upValue - The User Provided value
    normValue - The normalized value
    Throws:
    javax.naming.InvalidNameException
    Method Detail

    getNormType

    public java.lang.String getNormType()
    Get the normalized type of a AttributeTypeAndValue

    Returns:
    The normalized type

    getUpType

    public java.lang.String getUpType()
    Get the user provided type of a AttributeTypeAndValue

    Returns:
    The user provided type

    setType

    public void setType(java.lang.String upType,
                        java.lang.String type)
                 throws javax.naming.InvalidNameException
    Store a new type

    Parameters:
    upType - The AttributeTypeAndValue User Provided type
    type - The AttributeTypeAndValue type
    Throws:
    javax.naming.InvalidNameException - if the type or upType are empty or null. If the upName is invalid.

    setTypeNormalized

    public void setTypeNormalized(java.lang.String type)
                           throws javax.naming.InvalidNameException
    Store the type, after having trimmed and lowercased it.

    Parameters:
    type - The AttributeTypeAndValue type
    Throws:
    javax.naming.InvalidNameException

    getNormValue

    public java.lang.Object getNormValue()
    Get the Value of a AttributeTypeAndValue

    Returns:
    The value

    getUpValue

    public java.lang.Object getUpValue()
    Get the User Provided Value of a AttributeTypeAndValue

    Returns:
    The value

    getNormalizedValue

    public java.lang.String getNormalizedValue()
    Get the normalized Value of a AttributeTypeAndValue

    Returns:
    The value

    setValue

    public void setValue(java.lang.Object upValue,
                         java.lang.Object normValue)
    Store the value of a AttributeTypeAndValue.

    Parameters:
    value - The user provided value of the AttributeTypeAndValue
    normValue - The normalized value

    getLength

    public int getLength()
    Get the upName length

    Returns:
    the upName length

    getStart

    public int getStart()
    get the position in the original upName where this atav starts.

    Returns:
    The starting position of this atav

    getUpName

    public java.lang.String getUpName()
    Get the user provided form of this attribute type and value

    Returns:
    The user provided form of this atav

    setValueNormalized

    public void setValueNormalized(java.lang.String value)
    Store the value of a AttributeTypeAndValue, after having trimmed it.

    Parameters:
    value - The value of the AttributeTypeAndValue

    clone

    public java.lang.Object clone()
    Implements the cloning.

    Overrides:
    clone in class java.lang.Object
    Returns:
    a clone of this object

    compareTo

    public int compareTo(java.lang.Object object)
    Compares two NameComponents. They are equals if : - types are equals, case insensitive, - values are equals, case sensitive

    Specified by:
    compareTo in interface java.lang.Comparable
    Parameters:
    object -
    Returns:
    0 if both NC are equals, otherwise a positive value if the original NC is superior to the second one, a negative value if the second NC is superior.

    compareToIgnoreCase

    public int compareToIgnoreCase(java.lang.Object object)
    Compares two NameComponents. They are equals if : - types are equals, case insensitive, - values are equals, case insensitive

    Parameters:
    object -
    Returns:
    0 if both NC are equals, otherwise a positive value if the original NC is superior to the second one, a negative value if the second NC is superior.

    normalize

    public java.lang.String normalize()
    A Normalized String representation of a AttributeTypeAndValue : - type is trimed and lowercased - value is trimed and lowercased, and special characters are escaped if needed.

    Returns:
    A normalized string representing a AttributeTypeAndValue

    hashCode

    public int hashCode()
    Gets the hashcode of this object.

    Overrides:
    hashCode in class java.lang.Object
    Returns:
    The instance hash code
    See Also:
    Object.hashCode()

    equals

    public boolean equals(java.lang.Object obj)
    Overrides:
    equals in class java.lang.Object
    See Also:
    Object.equals(Object)

    writeExternal

    public void writeExternal(java.io.ObjectOutput out)
                       throws java.io.IOException
    Specified by:
    writeExternal in interface java.io.Externalizable
    Throws:
    java.io.IOException
    See Also:
    An AttributeTypeAndValue is composed of a type and a value. The data are stored following the structure :
  • upName
  • The User provided ATAV
  • start
  • The position of this ATAV in the DN
  • length
  • The ATAV length
  • upType
  • The user Provided Type
  • normType
  • The normalized AttributeType
  • isHR
  • Tells if the value is a String or not

    if the value is a String :

  • upValue
  • The User Provided value.
  • value
  • The normalized value.

    if the value is binary :

  • upValueLength
  • upValue
  • The User Provided value.
  • valueLength
  • value
  • The normalized value.

    readExternal

    public void readExternal(java.io.ObjectInput in)
                      throws java.io.IOException,
                             java.lang.ClassNotFoundException
    Specified by:
    readExternal in interface java.io.Externalizable
    Throws:
    java.io.IOException
    java.lang.ClassNotFoundException
    See Also:
    We read back the data to create a new ATAV. The structure read is exposed in the {@link AttributeTypeAndValue#writeExternal(ObjectOutput)} method


    toString

    public java.lang.String toString()
    A String representation of a AttributeTypeAndValue.

    Overrides:
    toString in class java.lang.Object
    Returns:
    A string representing a AttributeTypeAndValue


    Copyright © 2003-2011 Apache Software Foundation. All Rights Reserved.