|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.springframework.ldap.core.DistinguishedName
public class DistinguishedName
Default implementation of a Name corresponding to an LDAP path. A
Distinguished Name manipulation implementation is included in JDK1.5
(LdapName), but not in prior releases.
A DistinguishedName is particularly useful when building or
modifying an LDAP path dynamically, as escaping will be taken care of.
A path is split into several names. The Name interface specifies that
the most significant part be in position 0.
Example:
Name instances, and consequently DistinguishedName
instances are naturally mutable, which is useful when constructing
DistinguishedNames. Example:
DistinguishedName path = new DistinguishedName("dc=jayway,dc=se");
path.add("ou", "People");
path.add("uid", "adam.skogman");
String dn = path.toString();
will render uid=adam.skogman,ou=People,dc=jayway,dc=se.
NOTE: The fact that DistinguishedName instances are mutable needs to
be taken into careful account, as this means that they may be modified
involuntarily. This means that whenever a DistinguishedName
instance is kept for reference (e.g. for identification of a domain entry) or
as a constant, you should consider getting an immutable copy of the instance
using immutableDistinguishedName() or
immutableDistinguishedName(String).
NB:As of version 1.3 the default toString representation of
DistinguishedName now defaults to a compact one, without spaces between the
respective RDNs. For backward compatibility, set the
SPACED_DN_FORMAT_PROPERTY ("org.springframework.ldap.core.spacedDnFormat") to
true.
| Field Summary | |
|---|---|
static DistinguishedName |
EMPTY_PATH
An empty, unmodifiable DistinguishedName. |
static java.lang.String |
SPACED_DN_FORMAT_PROPERTY
System property that will be inspected to determine whether toString will format the DN with spaces after each comma or use a more compact representation, i.e.: uid=adam.skogman, ou=People, dc=jayway, dc=se rather than
uid=adam.skogman,ou=People,dc=jayway,dc=se. |
| Constructor Summary | |
|---|---|
DistinguishedName()
Construct a new DistinguishedName with no components. |
|
DistinguishedName(java.util.List list)
Construct a new DistinguishedName from the supplied
List of LdapRdn objects. |
|
DistinguishedName(javax.naming.Name name)
Construct a new DistinguishedName from the supplied
Name. |
|
DistinguishedName(java.lang.String path)
Construct a new DistinguishedName from a String. |
|
| Method Summary | |
|---|---|
void |
add(int idx,
LdapRdn rdn)
Add the supplied LdapRdn att the specified index. |
javax.naming.Name |
add(int index,
java.lang.String string)
|
void |
add(LdapRdn rdn)
Add the supplied LdapRdn last in the list of Rdns. |
javax.naming.Name |
add(java.lang.String string)
|
void |
add(java.lang.String key,
java.lang.String value)
Add a new LdapRdn using the supplied key and value. |
javax.naming.Name |
addAll(int arg0,
javax.naming.Name name)
|
javax.naming.Name |
addAll(javax.naming.Name name)
|
DistinguishedName |
append(DistinguishedName path)
Add an LDAP path last in this DistinguishedName. |
DistinguishedName |
append(java.lang.String key,
java.lang.String value)
Append a new LdapRdn using the supplied key and value. |
java.lang.Object |
clone()
|
int |
compareTo(java.lang.Object obj)
Compare this instance to another object. |
boolean |
contains(DistinguishedName path)
Determines if this DistinguishedName path contains another
path. |
java.lang.String |
encode()
Builds a complete LDAP path, ldap encoded, useful as a DN. |
boolean |
endsWith(javax.naming.Name name)
Determines if this DistinguishedName ends with a certian
path. |
boolean |
equals(java.lang.Object obj)
|
java.lang.String |
get(int index)
|
java.util.Enumeration |
getAll()
|
LdapRdn |
getLdapRdn(int index)
Get the LdapRdn at a specified position. |
LdapRdn |
getLdapRdn(java.lang.String key)
Get the LdapRdn with the specified key. |
java.util.List |
getNames()
Get the name List. |
javax.naming.Name |
getPrefix(int index)
|
javax.naming.Name |
getSuffix(int index)
|
java.lang.String |
getValue(java.lang.String key)
Get the value of the LdapRdnComponent with the specified key
(Attribute value). |
int |
hashCode()
|
DistinguishedName |
immutableDistinguishedName()
Return an immutable copy of this instance. |
static DistinguishedName |
immutableDistinguishedName(java.lang.String dnString)
Create an immutable DistinguishedName instance, suitable as a constant. |
boolean |
isEmpty()
|
protected void |
parse(java.lang.String path)
Parse the supplied String and make this instance represent the corresponding distinguished name. |
void |
prepend(DistinguishedName path)
Add an LDAP path first in this DistinguishedName. |
java.lang.Object |
remove(int arg0)
|
LdapRdn |
removeFirst()
Remove the first part of this DistinguishedName. |
void |
removeFirst(javax.naming.Name path)
Remove the supplied path from the beginning of this DistinguishedName if this instance starts with
path. |
LdapRdn |
removeLast()
Remove the last part of this DistinguishedName. |
int |
size()
|
boolean |
startsWith(javax.naming.Name name)
|
java.lang.String |
toCompactString()
Get the compact String representation of this DistinguishedName. |
java.lang.String |
toString()
Get the String representation of this DistinguishedName. |
java.lang.String |
toUrl()
Builds a complete LDAP path, ldap and url encoded. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String SPACED_DN_FORMAT_PROPERTY
uid=adam.skogman, ou=People, dc=jayway, dc=se rather than
uid=adam.skogman,ou=People,dc=jayway,dc=se. Default is
compact representation.
public static final DistinguishedName EMPTY_PATH
| Constructor Detail |
|---|
public DistinguishedName()
public DistinguishedName(java.lang.String path)
DistinguishedName from a String.
path - a String corresponding to a (syntactically) valid LDAP path.public DistinguishedName(java.util.List list)
DistinguishedName from the supplied
List of LdapRdn objects.
list - the components that this instance will consist of.public DistinguishedName(javax.naming.Name name)
DistinguishedName from the supplied
Name. The parts of the supplied Name must be
syntactically correct LdapRdns.
name - the Name to construct a new
DistinguishedName from.| Method Detail |
|---|
protected void parse(java.lang.String path)
path - the LDAP path to parse.public LdapRdn getLdapRdn(int index)
LdapRdn at a specified position.
index - the LdapRdn to retrieve.
LdapRdn at the requested position.public LdapRdn getLdapRdn(java.lang.String key)
LdapRdn with the specified key. If there are several
Rdns with the same key, the first one found (in order of
significance) will be returned.
key - Attribute name of the LdapRdn to retrieve.
LdapRdn with the requested key.
java.lang.IllegalArgumentException - if no Rdn matches the given key.public java.lang.String getValue(java.lang.String key)
LdapRdnComponent with the specified key
(Attribute value). If there are several Rdns with the same key, the value
of the first one found (in order of significance) will be returned.
key - Attribute name of the LdapRdn to retrieve.
java.lang.IllegalArgumentException - if no Rdn matches the given key.public java.util.List getNames()
List.
LdapRdns that this
DistinguishedName consists of.public java.lang.String toString()
DistinguishedName.
Depending on the setting of property
org.springframework.ldap.core.spacedDnFormat a space will be
added after each comma, to make the result more readable. Default is
compact representation, i.e. without any spaces.
toString in class java.lang.ObjectDistinguishedName.SPACED_DN_FORMAT_PROPERTYpublic java.lang.String toCompactString()
DistinguishedName. Add no space after each comma, to make it
compact.
DistinguishedName.public java.lang.String encode()
public java.lang.String toUrl()
public boolean contains(DistinguishedName path)
DistinguishedName path contains another
path.
path - the path to check.
true if the supplied path is conained in this
instance, false otherwise.public DistinguishedName append(DistinguishedName path)
DistinguishedName name1 = new DistinguishedName("c=SE, dc=jayway, dc=se");
DistinguishedName name2 = new DistinguishedName("ou=people");
name1.append(name2);
will result in ou=people, c=SE, dc=jayway, dc=se
path - the path to append.
public DistinguishedName append(java.lang.String key,
java.lang.String value)
LdapRdn using the supplied key and value.
key - the key of the LdapRdn.value - the value of the LdapRdn.
public void prepend(DistinguishedName path)
DistinguishedName name1 = new DistinguishedName("ou=people");
DistinguishedName name2 = new DistinguishedName("c=SE, dc=jayway, dc=se");
name1.prepend(name2);
will result in ou=people, c=SE, dc=jayway, dc=se
path - the path to prepend.public LdapRdn removeFirst()
DistinguishedName.
public void removeFirst(javax.naming.Name path)
DistinguishedName if this instance starts with
path. Useful for stripping base path suffix from a
DistinguishedName.
path - the path to remove from the beginning of this instance.public java.lang.Object clone()
clone in interface javax.naming.Nameclone in class java.lang.ObjectObject.clone()public boolean equals(java.lang.Object obj)
equals in class java.lang.ObjectObject.equals(java.lang.Object)public int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()public int compareTo(java.lang.Object obj)
compareTo in interface java.lang.Comparable<java.lang.Object>compareTo in interface javax.naming.NameName.compareTo(java.lang.Object)public int size()
size in interface javax.naming.Namepublic boolean isEmpty()
isEmpty in interface javax.naming.Namepublic java.util.Enumeration getAll()
getAll in interface javax.naming.Namepublic java.lang.String get(int index)
get in interface javax.naming.Namepublic javax.naming.Name getPrefix(int index)
getPrefix in interface javax.naming.Namepublic javax.naming.Name getSuffix(int index)
getSuffix in interface javax.naming.Namepublic boolean startsWith(javax.naming.Name name)
startsWith in interface javax.naming.Namepublic boolean endsWith(javax.naming.Name name)
DistinguishedName ends with a certian
path.
If the argument path is empty (no names in path) this method will return
false.
endsWith in interface javax.naming.Namename - The suffix to check for.
public javax.naming.Name addAll(javax.naming.Name name)
throws javax.naming.InvalidNameException
addAll in interface javax.naming.Namejavax.naming.InvalidNameException
public javax.naming.Name addAll(int arg0,
javax.naming.Name name)
throws javax.naming.InvalidNameException
addAll in interface javax.naming.Namejavax.naming.InvalidNameException
public javax.naming.Name add(java.lang.String string)
throws javax.naming.InvalidNameException
add in interface javax.naming.Namejavax.naming.InvalidNameException
public javax.naming.Name add(int index,
java.lang.String string)
throws javax.naming.InvalidNameException
add in interface javax.naming.Namejavax.naming.InvalidNameException
public java.lang.Object remove(int arg0)
throws javax.naming.InvalidNameException
remove in interface javax.naming.Namejavax.naming.InvalidNameExceptionpublic LdapRdn removeLast()
DistinguishedName.
LdapRdn.
public void add(java.lang.String key,
java.lang.String value)
LdapRdn using the supplied key and value.
key - the key of the LdapRdn.value - the value of the LdapRdn.public void add(LdapRdn rdn)
LdapRdn last in the list of Rdns.
rdn - the LdapRdn to add.
public void add(int idx,
LdapRdn rdn)
LdapRdn att the specified index.
idx - the index at which to add the LdapRdn.rdn - the LdapRdn to add.public DistinguishedName immutableDistinguishedName()
public static final DistinguishedName immutableDistinguishedName(java.lang.String dnString)
dnString - the DN string to parse.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||