|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.directory.shared.ldap.name.DN
public class DN
The DN 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 representation, 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 DN |
EMPTY_DN
A null DN |
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 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 | |
|---|---|
DN()
Construct an empty DN object |
|
DN(Name name)
Transduces, or copies a Name to an DN. |
|
DN(String... upRdns)
Creates a new instance of DN, using varargs to declare the RDNs. |
|
DN(String upName)
Parse a String and checks that it is a valid DN |
|
| Method Summary | |
|---|---|
Name |
add(int pos,
RDN newRdn)
Adds a single RDN to a specific position. |
Name |
add(int posn,
String comp)
|
Name |
add(RDN newRdn)
Adds a single RDN to the (leaf) end of this name. |
Name |
add(String comp)
|
Name |
addAll(int posn,
Name name)
|
Name |
addAll(Name suffix)
|
Name |
addAllNormalized(int posn,
Name name)
Adds the components of a name -- in order -- at a specified position within this name. |
Name |
addNormalized(RDN newRdn)
Adds a single normalized RDN to the (leaf) end of this name. |
Object |
clone()
|
int |
compareTo(Object obj)
|
boolean |
endsWith(Name name)
|
boolean |
equals(Object obj)
|
String |
get(int posn)
|
Enumeration<String> |
getAll()
|
Enumeration<RDN> |
getAllRdn()
Retrieves the components of this name as an enumeration of strings. |
static byte[] |
getBytes(DN dn)
Get an UTF-8 representation of the normalized form of the DN |
String |
getName()
Get the initial 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)
|
RDN |
getRdn()
Retrieves the last (leaf) component of this name. |
RDN |
getRdn(int posn)
Retrieves a component of this name. |
List<RDN> |
getRdns()
Retrieves all the components of this name. |
Name |
getSuffix(int posn)
|
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(String dn)
Check if a DistinguishedName is syntactically valid. |
static DN |
normalize(DN dn,
Map<String,OidNormalizer> oidsMap)
Change the internal DN, using the OID instead of the first name or other aliases. |
DN |
normalize(Map<String,OidNormalizer> oidsMap)
Change the internal DN, using the OID instead of the first name or other aliases. |
static Name |
normalize(String name,
Map<String,OidNormalizer> oidsMap)
Static factory which creates a normalized DN from a String and a Map of OIDs. |
void |
readExternal(ObjectInput in)
|
Object |
remove(int posn)
|
int |
size()
|
boolean |
startsWith(Name name)
|
String |
toNormName()
Build the normalized DN as a String, |
String |
toString()
Return the normalized DN as a String. |
void |
writeExternal(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 List<RDN> rdns
public static final DN EMPTY_DN
| Constructor Detail |
|---|
public DN()
public DN(Name name) throws InvalidNameException
name - composed of String name components.
InvalidNameException - If the Name is invalid.public DN(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 - if the String does not contain a valid DN.public DN(String... upRdns) throws InvalidNameException
String exampleName = "example";
String baseDn = "dc=apache,dc=org";
DN dn = new DN(
"cn=Test",
"ou", exampleName,
baseDn);
upNames -
InvalidNameException| Method Detail |
|---|
public static Name normalize(String name,
Map<String,OidNormalizer> oidsMap)
throws InvalidNameException,
NamingException
name - The DN as a StringoidsMap - The OID mapping
InvalidNameException - If the DN is invalid.
NamingException - If something went wrong.public String toNormName()
public String toString()
toString in class Objectpublic int hashCode()
hashCode in class ObjectObject.hashCode()public String getName()
public String getNormName()
public int size()
size in interface Namepublic static int getNbBytes(Name dn)
dn - The DN.
public static byte[] getBytes(DN dn)
dn - The DN.
public boolean startsWith(Name name)
startsWith in interface Namepublic boolean endsWith(Name name)
endsWith in interface Namepublic boolean isEmpty()
isEmpty in interface Namepublic String get(int posn)
get in interface Namepublic 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<RDN> getRdns()
public Enumeration<String> getAll()
getAll in interface Namepublic Enumeration<RDN> getAllRdn()
public Name getPrefix(int posn)
getPrefix in interface Namepublic Name getSuffix(int posn)
getSuffix in interface Name
public Name addAllNormalized(int posn,
Name name)
throws 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
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 name
public Name addAll(Name suffix)
throws InvalidNameException
addAll in interface NameInvalidNameException
public Name addAll(int posn,
Name name)
throws InvalidNameException
addAll in interface NameInvalidNameException
public Name add(String comp)
throws InvalidNameException
add in interface NameInvalidNameExceptionpublic Name add(RDN newRdn)
newRdn - the RDN to add
public Name add(int pos,
RDN newRdn)
newRdn - the RDN to addpos - The position where we want to add the Rdn
public Name addNormalized(RDN newRdn)
newRdn - the RDN to add
public Name add(int posn,
String comp)
throws InvalidNameException
add in interface NameInvalidNameException
public Object remove(int posn)
throws InvalidNameException
remove in interface NameInvalidNameExceptionpublic Object clone()
clone in interface Nameclone in class Objectpublic boolean equals(Object obj)
equals in class Objecttrue if the two instances are equalsObject.equals(java.lang.Object)public int compareTo(Object obj)
compareTo in interface Comparable<Object>compareTo in interface Name
public static DN normalize(DN dn,
Map<String,OidNormalizer> oidsMap)
throws NamingException
dn - The DN to transform.oidsMap - The mapping between names and oids.
NamingException - If something went wrong.
public DN normalize(Map<String,OidNormalizer> oidsMap)
throws NamingException
oidsMap - The mapping between names and oids.
NamingException - If something went wrong.public static boolean isValid(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(ObjectOutput out)
throws IOException
writeExternal in interface Externalizableout - The stream in which the DN will be serialized
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(ObjectInput in)
throws IOException,
ClassNotFoundException
readExternal in interface Externalizablein - The stream from which the DN is read
IOException - If the stream can't be read
ClassNotFoundException - If the RDN can't be createdWe read back the data to create a new DN. The structure
read is exposed in the {@link DN#writeExternal(ObjectOutput)}
method
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||