|
||||||||||
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 |
EQUAL
Value returned by the compareTo method if values are equals |
protected static org.slf4j.Logger |
LOG
The LoggerFactory used by this class |
static int |
NOT_EQUAL
Value returned by the compareTo method if values are not equals |
protected java.util.List<Rdn> |
rdns
The RDNs that are elements of the DN NOTE THAT THESE ARE IN THE OPPOSITE ORDER FROM THAT IMPLIED BY THE JAVADOC! Rdn[0] is rdns.get(n) and Rdn[n] is rdns.get(0) |
Constructor Summary | |
---|---|
LdapDN()
Construct an empty LdapDN object |
|
LdapDN(byte[] bytes)
Parse a buffer and checks that it is a valid DN |
|
LdapDN(java.util.Iterator<java.lang.String> nameComponents)
Creates an ldap name using a list of name components. |
|
LdapDN(java.util.List<java.lang.String> list)
Creates an ldap name using a list of NameComponents. |
|
LdapDN(javax.naming.Name name)
Transduces, or copies a Name to an LdapDN. |
|
LdapDN(java.lang.String upName)
Parse a String and checks that it is a valid DN |
Method Summary | |
---|---|
javax.naming.Name |
add(int pos,
Rdn newRdn)
Adds a single RDN to a specific position. |
javax.naming.Name |
add(int posn,
java.lang.String comp)
|
javax.naming.Name |
add(Rdn newRdn)
Adds a single RDN to the (leaf) end of this name. |
javax.naming.Name |
add(java.lang.String comp)
|
javax.naming.Name |
addAll(int posn,
javax.naming.Name name)
|
javax.naming.Name |
addAll(javax.naming.Name suffix)
|
javax.naming.Name |
addAllNormalized(int posn,
javax.naming.Name name)
Adds the components of a name -- in order -- at a specified position within this name. |
javax.naming.Name |
addNormalized(Rdn newRdn)
Adds a single normalized RDN to the (leaf) end of this name. |
java.lang.Object |
clone()
|
int |
compareTo(java.lang.Object obj)
|
boolean |
endsWith(javax.naming.Name name)
|
boolean |
equals(java.lang.Object obj)
|
java.lang.String |
get(int posn)
|
java.util.Enumeration<java.lang.String> |
getAll()
|
java.util.Enumeration<Rdn> |
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(javax.naming.Name dn)
Get the number of bytes necessary to store this DN |
java.lang.String |
getNormName()
Get the initial DN (without normalization) |
javax.naming.Name |
getPrefix(int posn)
|
Rdn |
getRdn()
Retrieves the last (leaf) component of this name. |
Rdn |
getRdn(int posn)
Retrieves a component of this name. |
java.util.List<Rdn> |
getRdns()
Retrieves all the components of this name. |
javax.naming.Name |
getSuffix(int posn)
|
java.lang.String |
getUpName()
Get the initial DN (without normalization) |
int |
hashCode()
Gets the hash code of this name. |
boolean |
isEmpty()
|
boolean |
isNormalized()
Tells if the DN has already been normalized or not |
static boolean |
isValid(java.lang.String dn)
Check if a DistinguishedName is syntactically valid. |
static LdapDN |
normalize(LdapDN dn,
java.util.Map<java.lang.String,OidNormalizer> oidsMap)
Change the internal DN, using the OID instead of the first name or other aliases. |
LdapDN |
normalize(java.util.Map<java.lang.String,OidNormalizer> oidsMap)
Change the internal DN, using the OID instead of the first name or other aliases. |
static javax.naming.Name |
normalize(java.lang.String name,
java.util.Map<java.lang.String,OidNormalizer> oidsMap)
Static factory which creates a normalized DN from a String and a Map of OIDs. |
void |
readExternal(java.io.ObjectInput in)
|
java.lang.Object |
remove(int posn)
|
int |
size()
|
boolean |
startsWith(javax.naming.Name name)
|
java.lang.String |
toNormName()
Build the normalized DN as a String, |
java.lang.String |
toString()
Return the normalized DN as a String. |
void |
writeExternal(java.io.ObjectOutput out)
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final org.slf4j.Logger LOG
public static final int NOT_EQUAL
public static final int EQUAL
protected java.util.List<Rdn> rdns
public static final LdapDN EMPTY_LDAPDN
Constructor Detail |
---|
public LdapDN()
public LdapDN(javax.naming.Name name) throws javax.naming.InvalidNameException
name
- composed of String name components.
javax.naming.InvalidNameException
- If the Name is invalid.public LdapDN(java.util.List<java.lang.String> list) throws javax.naming.InvalidNameException
list
- of String name components.
javax.naming.InvalidNameException
- If the nameComponent is incorrectpublic LdapDN(java.util.Iterator<java.lang.String> nameComponents) throws javax.naming.InvalidNameException
nameComponents
- List of String name components.
javax.naming.InvalidNameException
- If the nameComponent is incorrectpublic LdapDN(java.lang.String upName) throws javax.naming.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.
javax.naming.InvalidNameException
- if the String does not contain a valid DN.public LdapDN(byte[] bytes) throws javax.naming.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.
javax.naming.InvalidNameException
- if the buffer does not contains a valid DN.Method Detail |
---|
public static javax.naming.Name normalize(java.lang.String name, java.util.Map<java.lang.String,OidNormalizer> oidsMap) throws javax.naming.InvalidNameException, javax.naming.NamingException
name
- The DN as a StringoidsMap
- The OID mapping
javax.naming.InvalidNameException
- If the DN is invalid.
javax.naming.NamingException
- If something went wrong.public java.lang.String toNormName()
public java.lang.String toString()
toString
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
Object.hashCode()
public java.lang.String getUpName()
public java.lang.String getNormName()
public int size()
size
in interface javax.naming.Name
public static int getNbBytes(javax.naming.Name dn)
dn
- The DN.
public static byte[] getBytes(LdapDN dn)
dn
- The DN.
public boolean startsWith(javax.naming.Name name)
startsWith
in interface javax.naming.Name
public boolean endsWith(javax.naming.Name name)
endsWith
in interface javax.naming.Name
public boolean isEmpty()
isEmpty
in interface javax.naming.Name
public java.lang.String get(int posn)
get
in interface javax.naming.Name
public Rdn getRdn(int posn)
posn
- the 0-based index of the component to retrieve. Must be in the
range [0,size()).
java.lang.ArrayIndexOutOfBoundsException
- if posn is outside the specified rangepublic Rdn getRdn()
public java.util.List<Rdn> getRdns()
public java.util.Enumeration<java.lang.String> getAll()
getAll
in interface javax.naming.Name
public java.util.Enumeration<Rdn> getAllRdn()
public javax.naming.Name getPrefix(int posn)
getPrefix
in interface javax.naming.Name
public javax.naming.Name getSuffix(int posn)
getSuffix
in interface javax.naming.Name
public javax.naming.Name addAllNormalized(int posn, javax.naming.Name name) throws javax.naming.InvalidNameException
posn
- the index in this name at which to add the new components.
Must be in the range [0,size()]. Note this is from the opposite end as rnds.get(posn)name
- the components to add
java.lang.ArrayIndexOutOfBoundsException
- if posn is outside the specified range
javax.naming.InvalidNameException
- if n is not a valid name, or if the addition of
the components would violate the syntax rules of this namepublic javax.naming.Name addAll(javax.naming.Name suffix) throws javax.naming.InvalidNameException
addAll
in interface javax.naming.Name
javax.naming.InvalidNameException
public javax.naming.Name addAll(int posn, javax.naming.Name name) throws javax.naming.InvalidNameException
addAll
in interface javax.naming.Name
javax.naming.InvalidNameException
public javax.naming.Name add(java.lang.String comp) throws javax.naming.InvalidNameException
add
in interface javax.naming.Name
javax.naming.InvalidNameException
public javax.naming.Name add(Rdn newRdn)
newRdn
- the RDN to add
public javax.naming.Name add(int pos, Rdn newRdn)
newRdn
- the RDN to addpos
- The position where we want to add the Rdn
public javax.naming.Name addNormalized(Rdn newRdn)
newRdn
- the RDN to add
public javax.naming.Name add(int posn, java.lang.String comp) throws javax.naming.InvalidNameException
add
in interface javax.naming.Name
javax.naming.InvalidNameException
public java.lang.Object remove(int posn) throws javax.naming.InvalidNameException
remove
in interface javax.naming.Name
javax.naming.InvalidNameException
public java.lang.Object clone()
clone
in interface javax.naming.Name
clone
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
true
if the two instances are equalsObject.equals(java.lang.Object)
public int compareTo(java.lang.Object obj)
compareTo
in interface java.lang.Comparable<java.lang.Object>
compareTo
in interface javax.naming.Name
public static LdapDN normalize(LdapDN dn, java.util.Map<java.lang.String,OidNormalizer> oidsMap) throws javax.naming.NamingException
dn
- The DN to transform.oidsMap
- The mapping between names and oids.
javax.naming.NamingException
- If something went wrong.public LdapDN normalize(java.util.Map<java.lang.String,OidNormalizer> oidsMap) throws javax.naming.NamingException
oidsMap
- The mapping between names and oids.
javax.naming.NamingException
- If something went wrong.public static boolean isValid(java.lang.String dn)
dn
- The DN to validate
true>
if the DN is valid, false
otherwisepublic boolean isNormalized()
true
if the DN is already normalized.public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
out
- The stream in which the DN will be serialized
java.io.IOException
- If the serialization failWe have to store a DN data efficiently. Here is the structure :
- upName
The User provided DN
- normName
May be null if the normName is equaivalent to
the upName
- rdns
The rdn's List.
for each rdn :
- call the RDN write method
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
in
- The stream from which the DN is read
java.io.IOException
- If the stream can't be read
java.lang.ClassNotFoundException
- If the RDN can't be createdWe read back the data to create a new LdapDN. The structure
read is exposed in the {@link LdapDN#writeExternal(ObjectOutput)}
method
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |