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 :

dc=example

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

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

Again, we can create schema aware Ava, or just plain Ava. Having a schema aware Ava allows further controls to be made o 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 a final class, it can be schema aware. It's also a Externalizable class.

Usage

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 normalized form. If the AVA is schema aware, we will use the AttributeType's Oid as the normalized form for the AttributeType, and the value will be normalized accordingly to the equality matching rule the AttributeType defines, if any. Let's see some examples.

Schema Aware Ava

Here we will create an AVA and check that the user provided values are preserved. The getUpName() and getString() methods will give back this user provided form.

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

will produce :

ToString     : ' CommonName = This is    a TEST '
Normalized   : '2.5.4.3=this is a test'
UserProvided : ' CommonName = This is    a TEST '

Note that the normalized value has transformed the AttributeType and now uses its Oid, and the value has been lower cased and the superfluous spaces have been removed, as dictated by the CaseIgnoreMatch MatchingRule (e)

{+}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() ); } {code}