6.5 - Ava

An Ava is used to store an Attribute value associated to an AttributeType.

It describes a container holding an AttributeType associated with a Value in a Rdn. An example would be :


where 'dc' is the AttributeType and 'example' the associated value.

The value can be a binary or a String value, depending on the AttributeType.

We can create schema aware Ava, or just plain Ava. Having a schema aware Ava allows further controls to be made on the value we inject : its syntax will be checked against the AttributeType syntax.

Most of the time, one will not have to create or manipulate an Ava, as it's an internal element of a Rdn.

Ava is also a Externalizable class.

Ava instances are immutable.


As for the Dn and Rdn classes, we have to hold two representation for the interned AttributeType and Value : the User Provided form, and the escaped form (which is used in filters). If the AVA is schema aware, the escaped form will be computed, otherwise we store the user provided form instead. Let's see some examples.

Schema Aware Ava

Here we will create an AVA and check that the user provided values are preserved. The getName() and getString() methods will give back this user provided form, in a form that allows it to be used in a Filter.

Ava atav = new Ava( schemaManager, " CommonName ", " This is    a TEST " );
System.out.println( "toString     : '" + atav.toString() + "'" );
System.out.println( "Escaped      : '" + atav.getEscaped() + "'" );
System.out.println( "UserProvided : '" + atav.getName() + "'" );

will produce :

toString     : ' CommonName =\ This is    a TEST\ '
Escaped      : ' CommonName =\ This is    a TEST\ '
UserProvided : ' CommonName =\ This is    a TEST\ '

{+}Not Schema Aware{+}

The biggest difference in this case is that the AttributeType will not be replaced by its Oid, but instead by a lower cased form of the provided ID. We also escape the leading and trailing spaces in the value.

{code} public void testAvaSimpleNorm() throws LdapException { Ava atav = new Ava( null, " CommonName ", " This is a TEST " ); assertEquals( " CommonName = This is a TEST ", atav.toString() ); assertEquals( "commonname=\ This is a TEST\ ", atav.getNormName() ); assertEquals( " CommonName = This is a TEST ", atav.getUpName() ); }