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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Ava()
Constructs an empty AvaAva(String upType, byte[] upValue)
Construct an Ava containing a binary value.Ava(String upType, String upValue)
Construct an Ava with a String value.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(SchemaManager schemaManager, String upType, String upName, byte[] upValue)
Construct a schema aware Ava containing a binary value.Ava(SchemaManager schemaManager, String upType, String upName, String upValue)
Construct a schema aware Ava with a String value.Ava(SchemaManager schemaManager, Ava ava)
Constructs new Ava using the provided SchemaManager and AVA
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Ava
clone()
Implements the cloning.int
compareTo(Ava that)
int
deserialize(byte[] buffer, int pos)
Deserialize an AVA from a byte[], starting at a given positionboolean
equals(Object obj)
AttributeType
getAttributeType()
String
getEscaped()
String
getName()
Get the user provided form of this attribute type and valueString
getNormType()
Get the normalized type of a AvaString
getType()
Get the user provided type of a AvaValue
getValue()
Get the Value of a Avaint
hashCode()
Gets the hashcode of this object.boolean
isSchemaAware()
Tells if the Ava is schema aware or not.void
readExternal(ObjectInput in)
We read back the data to create a new ATAV.int
serialize(byte[] buffer, int pos)
Serialize the AVA into a buffer at the given position.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.
-
-
-
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(SchemaManager schemaManager, Ava ava) throws LdapInvalidDnException
Constructs new Ava using the provided SchemaManager and AVA- Parameters:
schemaManager
- The SchemaManager instanceava
- 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 typeupValue
- 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 instanceupType
- The User Provided typeupValue
- 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 instanceupType
- The User Provided typeupName
- the User Provided AVAupValue
- 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 typeupValue
- 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 instanceupType
- The User Provided typeupValue
- 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 instanceupType
- The User Provided typeupName
- the User provided AVAupValue
- The User Provided String 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
-
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
-
hashCode
public int hashCode()
Gets the hashcode of this object.- Overrides:
hashCode
in classObject
- Returns:
- The instance hash code
- See Also:
Object.hashCode()
-
equals
public boolean equals(Object obj)
- Overrides:
equals
in classObject
- See Also:
Object.equals(Object)
-
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 Avapos
- 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 AVApos
- The position in the buffer- Returns:
- The new position
- Throws:
IOException
- If the serialized value is not an AVALdapInvalidAttributeValueException
- 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 interfaceExternalizable
- Throws:
IOException
- If the Ava can't be written in the stream- 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 thewriteExternal(ObjectOutput)
method- Specified by:
readExternal
in interfaceExternalizable
- Throws:
IOException
- If the Ava can't b written to the streamClassNotFoundException
- 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 interfaceComparable<Ava>
- See Also:
Comparable.compareTo(Object)
-
-