This class resolves a few ambiguities found in RFC 2253 as follows:
String names passed to LdapName or returned by it
use the full Unicode character set. They may also contain
characters encoded into UTF-8 with each octet represented by a
three-character substring such as "\\B4".
They may not, however, contain characters encoded into UTF-8 with
each octet represented by a single character in the string: the
meaning would be ambiguous.
LdapName will properly parse all valid names, but
does not attempt to detect all possible violations when parsing
invalid names. It is "generous" in accepting invalid names.
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.
When names are tested for equality, attribute types, both binary and string values, are case-insensitive. String values with different but equivalent usage of quoting, escaping, or UTF8-hex-encoding are considered equal. The order of components in multi-valued RDNs (such as "ou=Sales+cn=Bob") is not significant.
The components of a LDAP name, that is, RDNs, are numbered. The indexes of a LDAP name with n RDNs range from 0 to n-1. This range may be written as [0,n). The right most RDN is at index 0, and the left most RDN is at index n-1. For example, the distinguished name: "CN=Steve Kille, O=Isode Limited, C=GB" is numbered in the following sequence ranging from 0 to 2: {C=GB, O=Isode Limited, CN=Steve Kille}. An empty LDAP name is represented by an empty RDN list.
Concurrent multithreaded read-only access of an instance of
LdapName need not be synchronized.
Unless otherwise noted, the behavior of passing a null argument to a constructor or method in this class will cause a NullPointerException to be thrown.
| Modifier and Type | Field and Description |
|---|---|
| private transient List | |
| private static final long | |
| private transient String |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Name | Returns: The updated LdapName, not a new instance. Cannot be null.The non-null component to add. comp)Implements javax. Adds a single component to the end of this LDAP name. |
| public Name | |
| public Name | Returns: The updated LdapName, not a new instance. Cannot be null.The index at which to add the new component.
Must be in the range [0,size()]. posn, String The non-null component to add. comp)Implements javax. Adds a single component at a specified position within this LDAP name. |
| public Name | |
| public Name | Returns: The updated name (not a new instance).The non-null components to add. suffix)Implements javax. Adds the components of a name -- in order -- to the end of this name. |
| public Name | |
| public Name | Returns: The updated name (not a new instance).The index at which to add the new component.
Must be in the range [0,size()]. posn, Name The non-null components to add. suffix)Implements javax. Adds the components of a name -- in order -- at a specified position within this name. |
| public Name | |
| public Object | Returns: A copy of the this LDAP name.Overrides java. Implements javax. Generates a new copy of this name. |
| public int | Returns: A negative integer, zero, or a positive integer as this Name is less than, equal to, or greater than the given obj.The non-null LdapName instance to compare against. obj)Implements javax. Compares this LdapName with the specified Object for order. |
| private boolean | |
| public boolean | Returns: true ifn is a suffix of this name, false otherwise.The LDAP name to check. n)Implements javax. Determines whether this LDAP name ends with a specified LDAP name suffix. |
| public boolean | |
| public boolean | Returns: true if obj is equal to this LDAP name, false otherwise.The possibly null object to compare against. obj)Overrides java. Determines whether two LDAP names are equal. |
| public String | Returns: The non-null component at index posn.The 0-based index of the component to retrieve.
Must be in the range [0,size()). posn)Implements javax. Retrieves a component of this LDAP name as a string. |
| public Enumeration | Returns: A non-null enumeration of the components of this LDAP name. Each element of the enumeration is of class String.Implements javax. Retrieves the components of this name as an enumeration of strings. |
| public Name | Returns: An instance ofLdapName consisting of the
components at indexes in the range [0,posn).
If posn is zero, an empty LDAP name is returned.The 0-based index of the component at which to stop.
Must be in the range [0,size()]. posn)Implements javax. Creates a name whose components consist of a prefix of the components of this LDAP name. |
| public Rdn | Returns: The non-null RDN at index posn.The 0-based index of the RDN to retrieve.
Must be in the range [0,size()). posn)Retrieves an RDN of this LDAP name as an Rdn. |
| public List | |
| public Name | Returns: An instance ofLdapName consisting of the
components at indexes in the range [posn,size()).
If posn is equal to size(), an empty LDAP name is
returned.The 0-based index of the component at which to start.
Must be in the range [0,size()]. posn)Implements javax. Creates a name whose components consist of a suffix of the components in this LDAP name. |
| public int | Returns: An int representing the hash code of this name.Overrides java. Computes the hash code of this LDAP name. |
| public boolean | Returns: true if this LDAP name is empty, false otherwise.Implements javax. Determines whether this LDAP name is empty. |
| private boolean | |
| private void | |
| private void | readObject(ObjectInputStream
the s)ObjectInputStream to read fromThe readObject method is called to restore the state of
the |
| public Object | Returns: The component removed (a String).The index of the component to remove.
Must be in the range [0,size()). posn)Implements javax. Removes a component from this LDAP name. |
| public int | Returns: The non-negative number of components in this LDAP name.Implements javax. Retrieves the number of components in this LDAP name. |
| public boolean | Returns: true ifn is a prefix of this LDAP name,
false otherwise.The LDAP name to check. n)Implements javax. Determines whether this LDAP name starts with a specified LDAP name prefix. |
| public boolean | Returns: true ifrdns form a prefix of this LDAP name,
false otherwise.The sequence of rdns)Rdns to check.Determines whether the specified RDN sequence forms a prefix of this LDAP name. |
| public String | Returns: The string representation of the LdapName.Overrides java. Returns a string representation of this LDAP name in a format defined by RFC 2253 and described in the class description. |
| private void | writeObject(ObjectOutputStream
the s)ObjectOutputStream to write toThe writeObject method is called to save the state of the
|
| rdns | back to summary |
|---|---|
| private transient List<Rdn> rdns | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides javax. | |
| unparsed | back to summary |
|---|---|
| private transient String unparsed | |
| LdapName | back to summary |
|---|---|
| public LdapName(String name) throws InvalidNameException Constructs an LDAP name from the given distinguished name.
| |
| LdapName | back to summary |
|---|---|
| public LdapName(List<Rdn> rdns) Constructs an LDAP name given its parsed RDN components. The indexing of RDNs in the list follows the numbering of RDNs described in the class description. | |
| LdapName | back to summary |
|---|---|
| private LdapName(String name, List<Rdn> rdns, int beg, int end) | |
| add | back to summary |
|---|---|
| public Name add(String comp) throws InvalidNameException Implements javax. Adds a single component to the end of this LDAP name.
| |
| add | back to summary |
|---|---|
| public Name add(Rdn comp) Adds a single RDN to the end of this LDAP name. | |
| add | back to summary |
|---|---|
| public Name add(int posn, String comp) throws InvalidNameException Implements javax. Adds a single component at a specified position within this LDAP name. Components of this LDAP name at or after the index (if any) of the new component are shifted up by one (away from index 0) to accommodate the new component.
| |
| add | back to summary |
|---|---|
| public Name add(int posn, Rdn comp) Adds a single RDN at a specified position within this LDAP name. RDNs of this LDAP name at or after the index (if any) of the new RDN are shifted up by one (away from index 0) to accommodate the new RDN.
| |
| addAll | back to summary |
|---|---|
| public Name addAll(Name suffix) throws InvalidNameException Implements javax. Adds the components of a name -- in order -- to the end of this name.
| |
| addAll | back to summary |
|---|---|
| public Name addAll(List<Rdn> suffixRdns) Adds the RDNs of a name -- in order -- to the end of this name. | |
| addAll | back to summary |
|---|---|
| public Name addAll(int posn, Name suffix) throws InvalidNameException Implements javax. Adds the components of a name -- in order -- at a specified position within this name. Components of this LDAP name at or after the index (if any) of the first new component are shifted up (away from index 0) to accommodate the new components.
| |
| addAll | back to summary |
|---|---|
| public Name addAll(int posn, List<Rdn> suffixRdns) Adds the RDNs of a name -- in order -- at a specified position within this name. RDNs of this LDAP name at or after the index (if any) of the first new RDN are shifted up (away from index 0) to accommodate the new RDNs.
| |
| clone | back to summary |
|---|---|
| public Object clone() Overrides java. Implements javax. Generates a new copy of this name. Subsequent changes to the components of this name will not affect the new copy, and vice versa.
| |
| compareTo | back to summary |
|---|---|
| public int compareTo(Object obj) Implements javax. Compares this LdapName with the specified Object for order. Returns a negative integer, zero, or a positive integer as this Name is less than, equal to, or greater than the given Object. If obj is null or not an instance of LdapName, ClassCastException is thrown.
Ordering of LDAP names follows the lexicographical rules for
string comparison, with the extension that this applies to all
the RDNs in the LDAP name. All the RDNs are lined up in their
specified order and compared lexicographically.
See If this LDAP name is lexicographically lesser than obj, a negative number is returned. If this LDAP name is lexicographically greater than obj, a positive number is returned.
| |
| doesListMatch | back to summary |
|---|---|
| private boolean doesListMatch(int beg, int end, List<Rdn> rdns) | |
| endsWith | back to summary |
|---|---|
| public boolean endsWith(Name n) Implements javax. Determines whether this LDAP name ends with a specified
LDAP name suffix.
A name
| |
| endsWith | back to summary |
|---|---|
| public boolean endsWith(List<Rdn> rdns) Determines whether the specified RDN sequence forms a suffix of this LDAP name. Returns true if this LdapName is at least as long as rdns, and for every position p in the range [size() - rdns.size(), size()) the component getRdn(p) matches rdns.get(p). Returns false otherwise. If rdns is null, false is returned. | |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Determines whether two LDAP names are equal. If obj is null or not an LDAP name, false is returned.
Two LDAP names are equal if each RDN in one is equal
to the corresponding RDN in the other. This implies
both have the same number of RDNs, and each RDN's
equals() test against the corresponding RDN in the other
name returns true. See | |
| get | back to summary |
|---|---|
| public String get(int posn) Implements javax. Retrieves a component of this LDAP name as a string.
| |
| getAll | back to summary |
|---|---|
| public Enumeration Implements javax. Retrieves the components of this name as an enumeration of strings. The effect of updates to this name on this enumeration is undefined. If the name has zero components, an empty (non-null) enumeration is returned. The order of the components returned by the enumeration is same as the order in which the components are numbered as described in the class description.
| |
| getPrefix | back to summary |
|---|---|
| public Name getPrefix(int posn) Implements javax. Creates a name whose components consist of a prefix of the components of this LDAP name. Subsequent changes to this name will not affect the name that is returned and vice versa.
| |
| getRdn | back to summary |
|---|---|
| public Rdn getRdn(int posn) Retrieves an RDN of this LDAP name as an Rdn.
| |
| getRdns | back to summary |
|---|---|
| public List Retrieves the list of relative distinguished names. The contents of the list are unmodifiable. The indexing of RDNs in the returned list follows the numbering of RDNs as described in the class description. If the name has zero components, an empty list is returned. | |
| getSuffix | back to summary |
|---|---|
| public Name getSuffix(int posn) Implements javax. Creates a name whose components consist of a suffix of the components in this LDAP name. Subsequent changes to this name do not affect the name that is returned and vice versa.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Computes the hash code of this LDAP name. The hash code is the sum of the hash codes of individual RDNs of this name.
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Implements javax. Determines whether this LDAP name is empty. An empty name is one with zero components.
| |
| matches | back to summary |
|---|---|
| private boolean matches(int beg, int end, Name n) | |
| parse | back to summary |
|---|---|
| private void parse() throws InvalidNameException | |
| readObject | back to summary |
|---|---|
| private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException The readObject method is called to restore the state of
the
| |
| remove | back to summary |
|---|---|
| public Object remove(int posn) throws InvalidNameException Implements javax. Removes a component from this LDAP name. The component of this name at the specified position is removed. Components with indexes greater than this position (if any) are shifted down (toward index 0) by one.
| |
| size | back to summary |
|---|---|
| public int size() Implements javax. Retrieves the number of components in this LDAP name.
| |
| startsWith | back to summary |
|---|---|
| public boolean startsWith(Name n) Implements javax. Determines whether this LDAP name starts with a specified LDAP name
prefix.
A name
| |
| startsWith | back to summary |
|---|---|
| public boolean startsWith(List<Rdn> rdns) Determines whether the specified RDN sequence forms a prefix of this LDAP name. Returns true if this LdapName is at least as long as rdns, and for every position p in the range [0, rdns.size()) the component getRdn(p) matches rdns.get(p). Returns false otherwise. If rdns is null, false is returned. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns a string representation of this LDAP name in a format defined by RFC 2253 and described in the class description. If the name has zero components an empty string is returned.
| |
| writeObject | back to summary |
|---|---|
| private void writeObject(ObjectOutputStream s) throws IOException The writeObject method is called to save the state of the
| |