Class Ava

java.lang.Object
org.apache.directory.api.ldap.model.name.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:
  • Constructor Details

    • 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(SchemaManager schemaManager, Ava ava) throws LdapInvalidDnException
      Constructs new Ava using the provided SchemaManager and AVA
      Parameters:
      schemaManager - The SchemaManager instance
      ava - The AVA to copy
      Throws:
      LdapInvalidDnException - If the Ava is invalid
    • 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
  • Method Details

    • 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:
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
      See Also:
    • 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
    • deserialize

      public int deserialize(byte[] buffer, int pos) throws IOException, LdapInvalidAttributeValueException
      Deserialize an AVA from a byte[], starting at a given position
      Parameters:
      buffer - The buffer containing the AVA
      pos - The position in the buffer
      Returns:
      The new position
      Throws:
      IOException - If the serialized value is not an AVA
      LdapInvalidAttributeValueException - If the serialized AVA is invalid
    • 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:
    • readExternal

      public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
      We read back the data to create a new ATAV. The structure read is exposed in the writeExternal(ObjectOutput) method
      Specified by:
      readExternal in interface Externalizable
      Throws:
      IOException - If the Ava can't b written to the stream
      ClassNotFoundException - If we can't deserialize an Ava from the stream
      See Also:
    • 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
    • compareTo

      public int compareTo(Ava that)
      Specified by:
      compareTo in interface Comparable<Ava>
      See Also:
    • 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