Some quick definitions:
While parts of an rdn (particular attributes and values) may be manipulated as raw, unescaped strings, entire rdns are always escaped when represented as strings (e.g. by the 'toString()' method).
An added complication is unicode. While strings may be entered as escaped utf8, they are always converted to unicode asap, and never returned as utf8. (they are automatically translated to utf8 by jndi when transmitted to the server, or manually by JXplorer when saving ldif files as a final step).
The class is optimised for single valued RDNs, as this represents the majority of examples seen by the author...
This class uses delayed evaluation of RDN strings. Hence invalid RDNs can be instantiated, and will only throw exceptions when used.
@author Chris BettsThe Rdn class represents an RDN as attribute type/value mappings, which can be viewed using {@link javax.naming.directory.Attributes Attributes}. In addition, it contains convenience methods that allow easy retrieval of type and value when the Rdn consist of a single type/value pair, which is how it appears in a typical usage. It also contains helper methods that allow escaping of the unformatted attribute value and unescaping of the value formatted according to the escaping syntax defined in RFC2253. For methods that take or return attribute value as an Object, the value is either a String (in unescaped form) or a byte array.
Rdn
will properly parse all valid RDNs, but does not attempt to detect all possible violations when parsing invalid RDNs. It is "generous" in accepting invalid RDNs. The "validity" of a name is determined ultimately when it is supplied to an LDAP server, which may accept or reject the name based on factors such as its schema information and interoperability considerations.
The following code example shows how to construct an Rdn using the constructor that takes type and value as arguments:
Rdn rdn = new Rdn("cn", "Juicy, Fruit"); System.out.println(rdn.toString());The last line will print cn=Juicy\, Fruit. The {@link #unescapeValue(String) unescapeValue()} method can beused to unescape the escaped comma resulting in the original value "Juicy, Fruit". The {@link #escapeValue(Object) escapeValue()} method adds the escape back preceding the comma.
This class can be instantiated by a string representation of the RDN defined in RFC 2253 as shown in the following code example:
Rdn rdn = new Rdn("cn=Juicy\\, Fruit"); System.out.println(rdn.toString());The last line will print cn=Juicy\, Fruit.
Concurrent multithreaded read-only access of an instance of Rdn need not be synchronized.
Unless otherwise noted, the behavior of passing a null argument to a constructor or method in this class will cause NullPointerException to be thrown. @since 1.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|