org.apache.directory.api.ldap.model.name
Class Ava

java.lang.Object
  extended by 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.

Author:
Apache Directory Project
See Also:
Serialized Form

Constructor Summary
Ava()
          Constructs an empty Ava
Ava(SchemaManager schemaManager)
          Constructs an empty schema aware Ava.
Ava(SchemaManager schemaManager, String upType, byte[] upValue)
          Construct a schema aware Ava containing a binary value.
Ava(SchemaManager schemaManager, String upType, String upValue)
          Construct a schema aware Ava with a String value.
Ava(String upType, byte[] upValue)
          Construct an Ava containing a binary value.
Ava(String upType, String upValue)
          Construct an Ava with a String value.
 
Method Summary
 void apply(SchemaManager schemaManager)
          Apply a SchemaManager to the Ava.
 Ava clone()
          Implements the cloning.
 int compareTo(Ava that)
           
 boolean equals(Object obj)
           
 AttributeType getAttributeType()
           
 String getName()
          Get the user provided form of this attribute type and value
 String getNormName()
          Get the normalized Name of a Ava
 String getNormType()
          Get the normalized type of a Ava
 Value<?> getNormValue()
          Get the Value of a Ava
 String getType()
          Get the user provided type of a Ava
 Value<?> getValue()
          Get the User Provided Value of a Ava
 int hashCode()
          Gets the hashcode of this object.
 boolean isSchemaAware()
          Tells if the Ava is schema aware or not.
 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.
 void readExternal(ObjectInput in)
          We read back the data to create a new ATAV.
 String toString()
          A String representation of an Ava, as provided by the user.
 void writeExternal(ObjectOutput out)
          An Ava is composed of a type and a value.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

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(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
Method Detail

apply

public void apply(SchemaManager schemaManager)
           throws LdapInvalidDnException
Apply a SchemaManager to the Ava. It will normalize the Ava.
If the Ava already had a SchemaManager, then the new SchemaManager will be used instead.

Parameters:
schemaManager - The SchemaManager instance to use
Throws:
LdapInvalidDnException - If the Ava can't be normalized accordingly to the given SchemaManager

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

getNormValue

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

Returns:
The value

getValue

public Value<?> getValue()
Get the User Provided Value of a Ava

Returns:
The value

getNormName

public String getNormName()
Get the normalized Name of a Ava

Returns:
The name

getName

public String getName()
Get the user provided form of this attribute type and value

Returns:
The user provided form of this ava

clone

public Ava clone()
Implements the cloning.

Overrides:
clone in class Object
Returns:
a clone of this object

normalize

public String normalize()
A Normalized String representation of a Ava : are escaped if needed.

Returns:
A normalized string representing an Ava

hashCode

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

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

equals

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

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 :
if the value is a String :
if the value is binary :

Specified by:
writeExternal in interface Externalizable
Throws:
IoException - If the Ava can't be written in the stream
IOException
See Also:
Externalizable.readExternal(ObjectInput)

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

compareTo

public int compareTo(Ava that)
Specified by:
compareTo in interface Comparable<Ava>
See Also:
Comparable.compareTo(Object)

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


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.