|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.directory.shared.ldap.name.LdapDN
public class LdapDN
The LdapDN class contains a DN (Distinguished Name). Its specification can be found in RFC 2253, "UTF-8 String Representation of Distinguished Names". We will store two representation of a DN : - a user Provider represeentation, which is the parsed String given by a user - an internal representation. A DN is formed of RDNs, in a specific order : RDN[n], RDN[n-1], ... RDN[1], RDN[0] It represents a tree, in which the root is the last RDN (RDN[0]) and the leaf is the first RDN (RDN[n]).
Field Summary | |
---|---|
static LdapDN |
EMPTY_LDAPDN
A null LdapDN |
static int |
EQUALS
Value returned by the compareTo method if values are equals |
static int |
NOT_EQUALS
Value returned by the compareTo method if values are not equals |
Constructor Summary | |
---|---|
LdapDN()
Construct an empty LdapDN object |
|
LdapDN(byte[] bytes)
Parse a buffer and checks that it is a valid DN |
|
LdapDN(Name name)
Transduces, or copies a Name to an LdapDN. |
|
LdapDN(String upName)
Parse a String and checks that it is a valid DN |
Method Summary | |
---|---|
Name |
add(int posn,
String comp)
Adds a single component at a specified position within this name. |
Name |
add(Rdn newRdn)
Adds a single RDN to the end of this name. |
Name |
add(String comp)
Adds a single component to the end of this name. |
Name |
addAll(int posn,
Name name)
Adds the components of a name -- in order -- at a specified position within this name. |
Name |
addAll(Name suffix)
Adds the components of a name -- in order -- to the end of this name. |
Object |
clone()
Generates a new copy of this name. |
int |
compareTo(Object obj)
Compares this name with another name for order. |
boolean |
endsWith(Name name)
Determines whether this name ends with a specified suffix. |
boolean |
equals(Object obj)
|
String |
get(int posn)
Retrieves a component of this name. |
Enumeration |
getAll()
Retrieves the components of this name as an enumeration of strings. |
Enumeration |
getAllRdn()
Retrieves the components of this name as an enumeration of strings. |
static byte[] |
getBytes(LdapDN dn)
Get an UTF-8 representation of the normalized form of the DN |
static int |
getNbBytes(Name dn)
Get the number of bytes necessary to store this DN |
String |
getNormName()
Get the initial DN (without normalization) |
Name |
getPrefix(int posn)
Creates a name whose components consist of a prefix of the components of this name. |
Rdn |
getRdn()
Retrieves the last component of this name. |
Rdn |
getRdn(int posn)
Retrieves a component of this name. |
List |
getRdns()
Retrieves all the components of this name. |
Name |
getSuffix(int posn)
Creates a name whose components consist of a suffix of the components in this name. |
String |
getUpName()
Get the initial DN (without normalization) |
int |
hashCode()
Gets the hashcode of this name. |
boolean |
isEmpty()
Determines whether this name is empty. |
static LdapDN |
normalize(LdapDN dn,
Map oidsMap)
Change the internal DN, using the first alias instead of oids or other aliases. |
void |
normalize(Map oidsMap)
Change the internal DN, using the first alias instead of oids or other aliases. |
Object |
remove(int posn)
Removes a component from this name. |
int |
size()
Get the number of NameComponent conatained in this LdapDN |
boolean |
startsWith(Name name)
Determines whether this name starts with a specified prefix. |
String |
toNormName()
Build the normalized DN as a String, |
String |
toString()
Return the normalized DN as a String. |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int NOT_EQUALS
public static final int EQUALS
public static final LdapDN EMPTY_LDAPDN
Constructor Detail |
---|
public LdapDN()
public LdapDN(Name name) throws InvalidNameException
name
- composed of String name components.
InvalidNameException
public LdapDN(String upName) throws InvalidNameException
<distinguishedName> ::= <name> | e
<name> ::= <name-component> <name-components>
<name-components> ::= <spaces> <separator>
<spaces> <name-component> <name-components> | e
upName
- The String that contains the DN
InvalidNameException
- is thrown if the buffer does not
contains a valid DN.public LdapDN(byte[] bytes) throws InvalidNameException
<distinguishedName> ::= <name> | e
<name> ::= <name-component> <name-components>
<name-components> ::= <spaces> <separator>
<spaces> <name-component> <name-components> | e
bytes
- The byte buffer that contains the DN
A
- InvalidNameException is thrown if the buffer does not
contains a valid DN.
InvalidNameException
Method Detail |
---|
public String toNormName()
public String toString()
toString
in class Object
public int hashCode()
hashCode
in class Object
Object.hashCode()
public String getUpName()
public String getNormName()
public int size()
size
in interface Name
public static int getNbBytes(Name dn)
public static byte[] getBytes(LdapDN dn)
public boolean startsWith(Name name)
startsWith
in interface Name
name
- the name to check
public boolean endsWith(Name name)
endsWith
in interface Name
name
- the name to check
public boolean isEmpty()
isEmpty
in interface Name
public String get(int posn)
get
in interface Name
posn
- the 0-based index of the component to retrieve. Must be in the
range [0,size()).
ArrayIndexOutOfBoundsException
- if posn is outside the specified rangepublic Rdn getRdn(int posn)
posn
- the 0-based index of the component to retrieve. Must be in the
range [0,size()).
ArrayIndexOutOfBoundsException
- if posn is outside the specified rangepublic Rdn getRdn()
public List getRdns()
public Enumeration getAll()
getAll
in interface Name
public Enumeration getAllRdn()
public Name getPrefix(int posn)
getPrefix
in interface Name
posn
- the 0-based index of the component at which to stop. Must be
in the range [0,size()].
ArrayIndexOutOfBoundsException
- if posn is outside the specified rangepublic Name getSuffix(int posn)
getSuffix
in interface Name
posn
- the 0-based index of the component at which to start. Must be
in the range [0,size()].
ArrayIndexOutOfBoundsException
- if posn is outside the specified rangepublic Name addAll(Name suffix) throws InvalidNameException
addAll
in interface Name
suffix
- the components to add
InvalidNameException
- if suffix is not a valid name, or if the addition
of the components would violate the syntax rules of this namepublic Name addAll(int posn, Name name) throws InvalidNameException
addAll
in interface Name
name
- the components to addposn
- the index in this name at which to add the new components.
Must be in the range [0,size()].
ArrayIndexOutOfBoundsException
- if posn is outside the specified range
InvalidNameException
- if n is not a valid name, or if the addition of
the components would violate the syntax rules of this namepublic Name add(String comp) throws InvalidNameException
add
in interface Name
comp
- the component to add
InvalidNameException
- if adding comp would violate the syntax rules of
this namepublic Name add(Rdn newRdn) throws InvalidNameException
newRdn
- the RDN to add
InvalidNameException
- if adding RDN would violate the syntax rules of
this namepublic Name add(int posn, String comp) throws InvalidNameException
add
in interface Name
comp
- the component to addposn
- the index at which to add the new component. Must be in the
range [0,size()].
ArrayIndexOutOfBoundsException
- if posn is outside the specified range
InvalidNameException
- if adding comp would violate the syntax rules of
this namepublic Object remove(int posn) throws InvalidNameException
remove
in interface Name
posn
- the index of the component to remove. Must be in the range
[0,size()).
ArrayIndexOutOfBoundsException
- if posn is outside the specified range
InvalidNameException
- if deleting the component would violate the syntax rules of
the namepublic Object clone()
clone
in interface Name
clone
in class Object
Object.clone()
public boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
public int compareTo(Object obj)
As with Object.equals(), the notion of ordering for names depends on the class that implements this interface. For example, the ordering may be based on lexicographical ordering of the name components. Specific attributes of the name, such as how it treats case, may affect the ordering. In general, two names of different classes may not be compared.
compareTo
in interface Comparable<Object>
compareTo
in interface Name
obj
- the non-null object to compare against.
ClassCastException
- if obj is not a Name of a type that may be
compared with this nameComparable.compareTo(Object)
public static LdapDN normalize(LdapDN dn, Map oidsMap) throws InvalidNameException, NamingException
dn
- The DN to transformoidsMap
- The mapping between names and oids.
InvalidNameException
- If the DN is invalid
NamingException
public void normalize(Map oidsMap) throws InvalidNameException, NamingException
oidsMap
- The mapping between names and oids.
InvalidNameException
- If the DN is invalid
NamingException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |