The work of converting Java field and methods values to LDAP attributes (and vice versa) is performed by ObjectEncoder object instances. The LDAP SDK persistence framework includes a DefaultObjectEncoder instance which supports a wide range of data types, but custom object encoders may be created if other data types should be supported, or if the values should be encoded in a different manner.
The following Java types are supported by the DefaultObjectEncoder class:
In addition, any type of enumeration is supported.
All of the above types are meant to hold a single attribute value. For multivalued attributes, you may use arrays, lists, or sets of any of these types. If a list or set is to be used, then it should have a Java generic type of one of the above types, and list or set itself must have one of the following types:
Note that although the DefaultObjectEncoder class supports most of the Java primitive types, it is generally recommended that you use the corresponding object types in the java.lang package instead of the primitive (e.g., java.lang.Integer instead of the int primitive). The primary reason for this is that primitive types must always have values, whereas object types may be null. If primitive types are used, then it is impossible for them to remain uninitialized, so it is not possible to determine whether the corresponding attribute should be excluded from the encoded entry, or if that field or method was initialized when decoding an entry. This can also cause problems when trying to perform searches, since primitive elements will always have a value and will be included in search filters unless the associated fields or getter methods have been specifically excluded (in which case they can't be used in filters). The java.lang equivalents of these types do not have these limitations.