public class Rdn extends Object implements Serializable, Comparable<Object>
LdapName
.
The Rdn class represents an RDN as attribute type/value mappings,
which can be viewed using
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
unescapeValue()
method can be
used to unescape the escaped comma resulting in the original
value "Juicy, Fruit". The 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.
Constructor | Description |
---|---|
Rdn(Attributes attrSet) |
Constructs an Rdn from the given attribute set.
|
Rdn(Rdn rdn) |
Constructs an Rdn from the given rdn.
|
Rdn(String rdnString) |
Constructs an Rdn from the given string.
|
Rdn(String type,
Object value) |
Constructs an Rdn from the given attribute type and
value.
|
Modifier and Type | Method | Description |
---|---|---|
int |
compareTo(Object obj) |
Compares this Rdn with the specified Object for order.
|
boolean |
equals(Object obj) |
Compares the specified Object with this Rdn for equality.
|
static String |
escapeValue(Object val) |
Given the value of an attribute, returns a string escaped according
to the rules specified in
RFC 2253.
|
String |
getType() |
Retrieves one of this Rdn's type.
|
Object |
getValue() |
Retrieves one of this Rdn's value.
|
int |
hashCode() |
Returns the hash code of this RDN.
|
int |
size() |
Retrieves the number of attribute type/value pairs in this Rdn.
|
Attributes |
toAttributes() |
Retrieves the
Attributes
view of the type/value mappings contained in this Rdn. |
String |
toString() |
|
static Object |
unescapeValue(String val) |
Given an attribute value string formated according to the rules
specified in
RFC 2253,
returns the unformated value.
|
public Rdn(Attributes attrSet) throws InvalidNameException
Attributes
.
The string attribute values are not interpreted as RFC 2253 formatted RDN strings. That is, the values are used literally (not parsed) and assumed to be unescaped.
attrSet
- The non-null and non-empty attributes containing
type/value mappings.InvalidNameException
- If contents of attrSet cannot
be used to construct a valid RDN.public Rdn(String rdnString) throws InvalidNameException