Class Ava

  • All Implemented Interfaces:
    Externalizable, Serializable, Cloneable, Comparable<Ava>

    public class Ava
    extends Object
    implements Externalizable, Cloneable, Comparable<Ava>

    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.

    We will also keep a User Provided form of the AVA (Attribute Type And Value), called upName.

    This class is immutable

    Author:
    Apache Directory Project
    See Also:
    Serialized Form
    • Constructor Detail

      • Ava

        public Ava()
        Constructs an empty Ava
      • Ava

        public Ava​(SchemaManager schemaManager)
        Constructs an empty schema aware Ava.
        Parameters:
        schemaManager - The SchemaManager instance
      • Ava

        public Ava​(String upType,
                   byte[] upValue)
            throws LdapInvalidDnException
        Construct an Ava containing a binary value.

        Note that the upValue should not be null or empty, or resolve to an empty string after having trimmed it.

        Parameters:
        upType - The User Provided type
        upValue - The User Provided binary value
        Throws:
        LdapInvalidDnException - If the given type or value are invalid
      • Ava

        public Ava​(SchemaManager schemaManager,
                   String upType,
                   byte[] upValue)
            throws LdapInvalidDnException
        Construct a schema aware Ava containing a binary value. The AttributeType and value will be normalized accordingly to the given SchemaManager.

        Note that the upValue should not be null or empty, or resolve to an empty string after having trimmed it.

        Parameters:
        schemaManager - The SchemaManager instance
        upType - The User Provided type
        upValue - The User Provided binary value
        Throws:
        LdapInvalidDnException - If the given type or value are invalid
      • Ava

        public Ava​(SchemaManager schemaManager,
                   String upType,
                   String upName,
                   byte[] upValue)
            throws LdapInvalidDnException
        Construct a schema aware Ava containing a binary value. The AttributeType and value will be normalized accordingly to the given SchemaManager.

        Note that the upValue should not be null or empty, or resolve to an empty string after having trimmed it.

        Parameters:
        schemaManager - The SchemaManager instance
        upType - The User Provided type
        upName - the User Provided AVA
        upValue - The User Provided binary value
        Throws:
        LdapInvalidDnException - If the given type or value are invalid
      • Ava

        public Ava​(String upType,
                   String upValue)
            throws LdapInvalidDnException
        Construct an Ava with a String value.

        Note that the upValue should not be null or empty, or resolve to an empty string after having trimmed it.

        Parameters:
        upType - The User Provided type
        upValue - The User Provided String value
        Throws:
        LdapInvalidDnException - If the given type or value are invalid
      • Ava

        public Ava​(SchemaManager schemaManager,
                   String upType,
                   String upValue)
            throws LdapInvalidDnException
        Construct a schema aware Ava with a String value.

        Note that the upValue should not be null or empty, or resolve to an empty string after having trimmed it.

        Parameters:
        schemaManager - The SchemaManager instance
        upType - The User Provided type
        upValue - The User Provided String value
        Throws:
        LdapInvalidDnException - If the given type or value are invalid
      • Ava

        public Ava​(SchemaManager schemaManager,
                   String upType,
                   String upName,
                   String upValue)
            throws LdapInvalidDnException
        Construct a schema aware Ava with a String value.

        Note that the upValue should not be null or empty, or resolve to an empty string after having trimmed it.

        Parameters:
        schemaManager - The SchemaManager instance
        upType - The User Provided type
        upName - the User provided AVA
        upValue - The User Provided String value
        Throws:
        LdapInvalidDnException - If the given type or value are invalid
      • Ava

        Ava​(String upType,
            String normType,
            Value value,
            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
        value - The User Provided value
        upName - The User Provided name (may be escaped)
        Throws:
        LdapInvalidDnException - If the given type or value are invalid
      • Ava

        Ava​(AttributeType attributeType,
            String upType,
            String normType,
            Value value,
            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:
        attributeType - The AttributeType for this value
        upType - The User Provided type
        normType - The normalized type
        value - The value
        upName - The User Provided name (may be escaped)
        Throws:
        LdapInvalidDnException - If the given type or value are invalid
      • Ava

        Ava​(SchemaManager schemaManager,
            String upType,
            String normType,
            Value value)
        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:
        schemaManager - The SchemaManager
        upType - The User Provided type
        normType - The normalized type
        value - The value
        Throws:
        LdapInvalidDnException - If the given type or value are invalid
    • Method Detail

      • getNormType

        public String getNormType()
        Get the normalized type of a Ava
        Returns:
        The normalized type
      • getType

        public String getType()
        Get the user provided type of a Ava
        Returns:
        The user provided type
      • getValue

        public Value getValue()
        Get the Value of a Ava
        Returns:
        The value
      • getName

        public String getName()
        Get the user provided form of this attribute type and value
        Returns:
        The user provided form of this ava
      • getEscaped

        public String getEscaped()
        Returns:
        The Ava as an escaped String
      • clone

        public Ava clone()
        Implements the cloning.
        Overrides:
        clone in class Object
        Returns:
        a clone of this object
      • hashCode

        public int hashCode()
        Gets the hashcode of this object.
        Overrides:
        hashCode in class Object
        Returns:
        The instance hash code
        See Also:
        Object.hashCode()
      • serialize

        public int serialize​(byte[] buffer,
                             int pos)
                      throws IOException
        Serialize the AVA into a buffer at the given position.
        Parameters:
        buffer - The buffer which will contain the serialized Ava
        pos - The position in the buffer for the serialized value
        Returns:
        The new position in the buffer
        Throws:
        IOException - Id the serialization failed
      • writeExternal

        public void writeExternal​(ObjectOutput out)
                           throws IOException
        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 :
        • value The value

        if the value is binary :
        • valueLength
        • value The value
        Specified by:
        writeExternal in interface Externalizable
        Throws:
        IOException - If the Ava can't be written in the stream
        See Also:
        Externalizable.readExternal(ObjectInput)
      • isSchemaAware

        public boolean isSchemaAware()
        Tells if the Ava is schema aware or not.
        Returns:
        true if the Ava is schema aware
      • getAttributeType

        public AttributeType getAttributeType()
        Returns:
        the attributeType
      • toString

        public String toString()
        A String representation of an Ava, as provided by the user.
        Overrides:
        toString in class Object
        Returns:
        A string representing an Ava