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.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| private transient ArrayList | |
| private static final String | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| public | Rdn(Attributes
The non-null and non-empty attributes containing
type/value mappings. attrSet)Constructs an Rdn from the given attribute set. |
| public | |
| public | |
| public | |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public int | Returns: A negative integer, zero, or a positive integer as this Rdn is less than, equal to, or greater than the given Object.The non-null object to compare against. obj)Implements java. Compares this Rdn with the specified Object for order. |
| private static byte[] | |
| public boolean | Returns: true if the specified object is equal to this Rdn.object to be compared for equality with this Rdn. obj)Overrides java. Compares the specified Object with this Rdn for equality. |
| private static String | |
| private static String | |
| public static String | Returns: Escaped string value.The non-null object to be escaped. val)Given the value of an attribute, returns a string escaped according to the rules specified in RFC 2253. |
| public String | |
| private static byte[] | |
| public Object | |
| public int | Returns: An int representing the hash code of this Rdn.Overrides java. Returns the hash code of this RDN. |
| private boolean | |
| private static boolean | |
| pack-priv Rdn | |
| private void | readObject(ObjectInputStream
the s)ObjectInputStream to read fromThe readObject method is called to restore the state of
the |
| public int | Returns: The non-negative number of type/value pairs in this Rdn.Retrieves the number of attribute type/value pairs in this Rdn. |
| pack-priv void | |
| public Attributes | Returns: The non-null attributes containing the type/value mappings of this Rdn.Retrieves the |
| public String | Returns: The string representation of the Rdn.Overrides java. Returns this Rdn as a string represented in a format defined by
RFC 2253 and described
in the class description for |
| public static Object | Returns: Unescaped value.The non-null string to be unescaped. val)Given an attribute value string formatted according to the rules specified in RFC 2253, returns the unformatted value. |
| private void | writeObject(ObjectOutputStream
the s)ObjectOutputStream to write toThe writeObject method is called to save the state of the
|
| DEFAULT_SIZE | back to summary |
|---|---|
| private static final int DEFAULT_SIZE | |
| entries | back to summary |
|---|---|
| private transient ArrayList<Rdn. | |
| escapees | back to summary |
|---|---|
| private static final String escapees | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID
| |
| Rdn | back to summary |
|---|---|
| public Rdn(Attributes attrSet) throws InvalidNameException Constructs an Rdn from the given attribute set. See
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.
| |
| Rdn | back to summary |
|---|---|
| public Rdn(String rdnString) throws InvalidNameException Constructs an Rdn from the given string.
This constructor takes a string formatted according to the rules
defined in RFC 2253
and described in the class description for
| |
| Rdn | back to summary |
|---|---|
| public Rdn(Rdn rdn) Constructs an Rdn from the given
| |
| Rdn | back to summary |
|---|---|
| public Rdn(String type, Object value) throws InvalidNameException Constructs an Rdn from the given attribute type and value. 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.
| |
| Rdn | back to summary |
|---|---|
| pack-priv Rdn() | |
| compareTo | back to summary |
|---|---|
| public int compareTo(Object obj) Implements java. Compares this Rdn with the specified Object for order. Returns a negative integer, zero, or a positive integer as this Rdn is less than, equal to, or greater than the given Object. If obj is null or not an instance of Rdn, ClassCastException is thrown. The attribute type and value pairs of the RDNs are lined up against each other and compared lexicographically. The order of components in multi-valued Rdns (such as "ou=Sales+cn=Bob") is not significant.
| |
| decodeHexPairs | back to summary |
|---|---|
| private static byte[] decodeHexPairs(char[] chars, int beg, int end) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Compares the specified Object with this Rdn for equality. Returns true if the given object is also a Rdn and the two Rdns represent the same attribute type and value mappings. The order of components in multi-valued Rdns (such as "ou=Sales+cn=Bob") is not significant. Type and value equality matching is done as below:
If obj is null or not an instance of Rdn, false is returned.
| |
| escapeBinaryValue | back to summary |
|---|---|
| private static String escapeBinaryValue(byte[] val) | |
| escapeStringValue | back to summary |
|---|---|
| private static String escapeStringValue(String val) | |
| escapeValue | back to summary |
|---|---|
| public static String escapeValue(Object val) Given the value of an attribute, returns a string escaped according to the rules specified in RFC 2253. For example, if the val is "Sue, Grabbit and Runn", the escaped value returned by this method is "Sue\, Grabbit and Runn". A string value is represented as a String and binary value as a byte array.
| |
| getType | back to summary |
|---|---|
| public String getType() Retrieves one of this Rdn's type. This is a convenience method for obtaining the type, when the RDN contains a single type and value mapping, which is the common RDN usage.
For a multi-valued RDN, the type/value pairs have
no specific order defined on them. In that case, this method
returns type of one of the type/value pairs.
The
| |
| getUtf8Octets | back to summary |
|---|---|
| private static byte[] getUtf8Octets(char[] chars, int beg, int end) | |
| getValue | back to summary |
|---|---|
| public Object getValue() Retrieves one of this Rdn's value. This is a convenience method for obtaining the value, when the RDN contains a single type and value mapping, which is the common RDN usage.
For a multi-valued RDN, this method returns value corresponding
to the type returned by
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns the hash code of this RDN. Two RDNs that are equal (according to the equals method) will have the same hash code.
| |
| isEmptyValue | back to summary |
|---|---|
| private boolean isEmptyValue(Object val) | |
| isWhitespace | back to summary |
|---|---|
| private static boolean isWhitespace(char c) | |
| put | back to summary |
|---|---|
| pack-priv Rdn put(String type, Object value) | |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException The readObject method is called to restore the state of
the
| |
| size | back to summary |
|---|---|
| public int size() Retrieves the number of attribute type/value pairs in this Rdn.
| |
| sort | back to summary |
|---|---|
| pack-priv void sort() | |
| toAttributes | back to summary |
|---|---|
| public Attributes toAttributes() Retrieves the
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns this Rdn as a string represented in a format defined by
RFC 2253 and described
in the class description for
| |
| unescapeValue | back to summary |
|---|---|
| public static Object unescapeValue(String val) Given an attribute value string formatted according to the rules specified in RFC 2253, returns the unformatted value. Escapes and quotes are stripped away, and hex-encoded UTF-8 is converted to equivalent UTF-16 characters. Returns a string value as a String, and a binary value as a byte array.
Legal and illegal values are defined in RFC 2253.
This method is generous in accepting the values and does not
catch all illegal values.
Therefore, passing in an illegal value might not necessarily
trigger an
| |
| writeObject | back to summary |
|---|---|
| private void writeObject(ObjectOutputStream s) throws IOException The writeObject method is called to save the state of the
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public int | compareTo(Rdn.
Implements java. Compares this object with the specified object for order. |
| public boolean | equals(Object obj)
Overrides java. Indicates whether some other object is "equal to" this one. |
| pack-priv String | |
| pack-priv Object | |
| private String | |
| public int | |
| public String |
| comparable | back to summary |
|---|---|
| private String comparable | |
| type | back to summary |
|---|---|
| private String type | |
| value | back to summary |
|---|---|
| private Object value | |
| RdnEntry | back to summary |
|---|---|
| private RdnEntry() | |
| compareTo | back to summary |
|---|---|
| public int compareTo(Rdn. Implements java. Doc from java. Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object. The implementor must ensure The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| getType | back to summary |
|---|---|
| pack-priv String getType() | |
| getValue | back to summary |
|---|---|
| pack-priv Object getValue() | |
| getValueComparable | back to summary |
|---|---|
| private String getValueComparable() | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
Satisfying this method's contract implies a non- | |