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

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

public class AVA
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: 928945 $, $Date: 2010-03-30 01:59:49 +0200 (Tue, 30 Mar 2010) $
Author:
Apache Directory Project
See Also:
Serialized Form

Constructor Summary
AVA()
          Construct an empty AVA
AVA(java.lang.String upType, java.lang.String normType, byte[] upValue, byte[] normValue)
          Construct an AVA.
AVA(java.lang.String upType, java.lang.String normType, java.lang.String upValue, java.lang.String normValue)
          Construct an AVA.
AVA(java.lang.String upType, java.lang.String normType, Value<?> upValue, Value<?> normValue)
          Construct an AVA.
AVA(java.lang.String upType, java.lang.String normType, Value<?> upValue, Value<?> normValue, java.lang.String upName)
          Construct an AVA.
 
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 getNormName()
          Get the normalized Name of a AVA
 java.lang.String getNormType()
          Get the normalized type of a AVA
 Value<?> getNormValue()
          Get the Value of a AVA
 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 AVA
 Value<?> getUpValue()
          Get the User Provided Value of a AVA
 int hashCode()
          Gets the hashcode of this object.
 java.lang.String normalize()
          A Normalized String representation of a AVA : - type is trimed and lowercased - value is trimed and lowercased, and special characters are escaped if needed.
 java.lang.String normalizeValue()
           
 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(Value<?> upValue, Value<?> normValue)
          Store the value of a AVA.
 void setValueNormalized(java.lang.String value)
          Store the value of a AVA, after having trimmed it.
 java.lang.String toString()
          A String representation of a AVA.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AVA

public AVA()
Construct an empty AVA


AVA

public AVA(java.lang.String upType,
           java.lang.String normType,
           java.lang.String upValue,
           java.lang.String normValue)
    throws LdapInvalidDnException
Construct an AVA. 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:
    LdapInvalidDnException

    AVA

    public AVA(java.lang.String upType,
               java.lang.String normType,
               byte[] upValue,
               byte[] normValue)
        throws LdapInvalidDnException
    Construct an AVA. 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:
    LdapInvalidDnException

    AVA

    public AVA(java.lang.String upType,
               java.lang.String normType,
               Value<?> upValue,
               Value<?> normValue)
        throws LdapInvalidDnException
    Construct an AVA. 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:
    LdapInvalidDnException

    AVA

    public AVA(java.lang.String upType,
               java.lang.String normType,
               Value<?> upValue,
               Value<?> normValue,
               java.lang.String upName)
        throws LdapInvalidDnException
    Construct an AVA. 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 User Provided type
    normType - The normalized type
    upValue - The User Provided value
    normValue - The normalized value
    upName - The User Provided name (may be escaped)
    Throws:
    LdapInvalidDnException
    Method Detail

    getNormType

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

    Returns:
    The normalized type

    getUpType

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

    Returns:
    The user provided type

    setType

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

    Parameters:
    upType - The AVA User Provided type
    type - The AVA type
    Throws:
    LdapInvalidDnException - if the type or upType are empty or null. If the upName is invalid.

    setTypeNormalized

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

    Parameters:
    type - The AVA type
    Throws:
    LdapInvalidDnException

    getNormValue

    public Value<?> getNormValue()
    Get the Value of a AVA

    Returns:
    The value

    getUpValue

    public Value<?> getUpValue()
    Get the User Provided Value of a AVA

    Returns:
    The value

    getNormName

    public java.lang.String getNormName()
    Get the normalized Name of a AVA

    Returns:
    The name

    setValue

    public void setValue(Value<?> upValue,
                         Value<?> normValue)
    Store the value of a AVA.

    Parameters:
    value - The user provided value of the AVA
    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 AVA, after having trimmed it.

    Parameters:
    value - The value of the AVA

    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.

    normalizeValue

    public java.lang.String normalizeValue()

    normalize

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

    Returns:
    A normalized string representing a AVA

    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 AVA 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 AVA#writeExternal(ObjectOutput)} method


    toString

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

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


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