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(String upType, String normType, Value value, String upName)Construct an Ava.Ava(AttributeType attributeType, String upType, String normType, Value value, String upName)Construct an 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(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, String upType, String normType, Value value)Construct an Ava.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 Avaclone()Implements the cloning.intcompareTo(Ava that)intdeserialize(byte[] buffer, int pos)Deserialize an AVA from a byte[], starting at a given positionbooleanequals(Object obj)AttributeTypegetAttributeType()StringgetEscaped()StringgetName()Get the user provided form of this attribute type and valueStringgetNormType()Get the normalized type of a AvaStringgetType()Get the user provided type of a AvaValuegetValue()Get the Value of a AvainthashCode()Gets the hashcode of this object.booleanisSchemaAware()Tells if the Ava is schema aware or not.voidreadExternal(ObjectInput in)We read back the data to create a new ATAV.intserialize(byte[] buffer, int pos)Serialize the AVA into a buffer at the given position.StringtoString()A String representation of an Ava, as provided by the user.voidwriteExternal(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
-
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 typenormType- The normalized typevalue- The User Provided valueupName- 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 valueupType- The User Provided typenormType- The normalized typevalue- The valueupName- 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 SchemaManagerupType- The User Provided typenormType- The normalized typevalue- 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.
-
hashCode
public int hashCode()
Gets the hashcode of this object.- Overrides:
hashCodein classObject- Returns:
- The instance hash code
- See Also:
Object.hashCode()
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin classObject- See Also:
Object.equals(Object)
-
serialize
public int serialize(byte[] buffer, int pos) throws IOExceptionSerialize 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, LdapInvalidAttributeValueExceptionDeserialize 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:
writeExternalin 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:
readExternalin 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:
compareToin interfaceComparable<Ava>- See Also:
Comparable.compareTo(Object)
-
-