Package netscape.ldap.util
Class DN
java.lang.Object
netscape.ldap.util.DN
- All Implemented Interfaces:
Serializable
Objects of this class represent distinguished names (DN). A
distinguished name is used to identify an entry in a directory.
The netscape.ldap.LDAPDN class uses this class
internally. In most cases, when working with DNs in the
LDAP Java classes, you should use the
netscape.ldap.LDAPDN class.
The following DNs are examples of the different formats for DNs that may appear:
- uid=bjensen, ou=People, o=Airius.com (RFC 1485 format)
- o=Airius.com/ou=People/uid=bjensen (OSF format)
- Version:
- 1.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final char[]Array of the characters that may be escaped in a DN.private intList of RDNs.static intType specifying a DN in the OSF format.static intType specifying a DN in the RFC format.(package private) static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the specified relative distinguished name (RDN) to the current DN.voidaddRDNToBack(RDN rdn) Adds the specified relative distinguished name (RDN) to the end of the current DN.voidaddRDNToFront(RDN rdn) Adds the specified relative distinguished name (RDN) to the beginning of the current DN.booleanDeprecated.Please use isDescendantOf() instead.intReturns the number of components that make up the current DN.booleanDetermines if the current DN is equal to the specified DN.String[]explodeDN(boolean noTypes) Returns an array of the individual components that make up the current distinguished name.intGets the type of format used for the DN (RFC format or OSF format).Gets the parent DN for this DN.getRDNs()Returns a list of the components (RDNobjects) that make up the current DN.booleanisDescendantOf(DN dn) Determines if this DN is a descendant of the given DN.static booleanDetermines if the given string is an distinguished name or not.booleanisRFC()Determines if the DN is in RFC 1485 format.private StringNeutralize backslash escapes and quoted sequences for easy parsing.private voidParse RDNs in the DNvoidsetDNType(int type) Sets the type of format used for the DN (RFC format or OSF format).Returns the DN in OSF format.Returns the DN in RFC 1485 format.toString()Returns the string representation of the DN in its original format.
-
Field Details
-
m_rdns
List of RDNs. DN consists of one or more RDNs. RDNs follow RFC1485 order. -
RFC
public static int RFCType specifying a DN in the RFC format.- See Also:
-
OSF
public static int OSFType specifying a DN in the OSF format.- See Also:
-
m_dnType
private int m_dnType -
serialVersionUID
static final long serialVersionUID- See Also:
-
ESCAPED_CHAR
public static final char[] ESCAPED_CHARArray of the characters that may be escaped in a DN.
-
-
Constructor Details
-
DN
public DN()Constructs an emptyDNobject. -
DN
Constructs aDNobject from the specified distinguished name. The string representation of the DN can be in RFC 1485 or OSF format.- Parameters:
dn- string representation of the distinguished name
-
-
Method Details
-
neutralizeEscapes
Neutralize backslash escapes and quoted sequences for easy parsing.- Returns:
- dn string with disabled escapes or null if malformed dn
-
parseRDNs
Parse RDNs in the DN -
addRDNToFront
Adds the specified relative distinguished name (RDN) to the beginning of the current DN.- Parameters:
rdn- the relative distinguished name to add to the beginning of the current DN- See Also:
-
addRDNToBack
Adds the specified relative distinguished name (RDN) to the end of the current DN.- Parameters:
rdn- the relative distinguished name to append to the current DN- See Also:
-
addRDN
Adds the specified relative distinguished name (RDN) to the current DN. If the DN is in RFC 1485 format, the RDN is added to the beginning of the DN. If the DN is in OSF format, the RDN is appended to the end of the DN.- Parameters:
rdn- the relative distinguished name to add to the current DN- See Also:
-
setDNType
public void setDNType(int type) Sets the type of format used for the DN (RFC format or OSF format).- Parameters:
type- one of the following constants:DN.RFC(to use the RFC format) orDN.OSF(to use the OSF format)- See Also:
-
getDNType
public int getDNType()Gets the type of format used for the DN (RFC format or OSF format).- Returns:
- one of the following constants:
DN.RFC(if the DN is in RFC format) orDN.OSF(if the DN is in OSF format). - See Also:
-
countRDNs
public int countRDNs()Returns the number of components that make up the current DN.- Returns:
- the number of components in this DN.
-
getRDNs
Returns a list of the components (RDNobjects) that make up the current DN.- Returns:
- a list of the components of this DN.
- See Also:
-
explodeDN
Returns an array of the individual components that make up the current distinguished name.- Parameters:
noTypes- specifytrueto remove the attribute type and equals sign (for example, "cn=") from each component
-
isRFC
public boolean isRFC()Determines if the DN is in RFC 1485 format.- Returns:
trueif the DN is in RFC 1485 format.
-
toRFCString
Returns the DN in RFC 1485 format.- Returns:
- the DN in RFC 1485 format.
-
toOSFString
Returns the DN in OSF format.- Returns:
- the DN in OSF format.
-
toString
Returns the string representation of the DN in its original format. (For example, if theDNobject was constructed from a DN in RFC 1485 format, this method returns the DN in RFC 1485 format. -
isDN
Determines if the given string is an distinguished name or not.- Parameters:
dn- distinguished name- Returns:
trueorfalse.
-
equals
Determines if the current DN is equal to the specified DN.- Parameters:
dn- DN to compare against the current DN- Returns:
trueif the two DNs are the same.
-
getParent
Gets the parent DN for this DN.For example, the following section of code gets the parent DN of "uid=bjensen, ou=People, o=Airius.com."
DN dn = new DN("uid=bjensen, ou=People, o=Airius.com"); DN parent = dn.getParent();The parent DN in this example is "ou=People, o=Airius.com".- Returns:
- DN of the parent of this DN.
-
contains
Deprecated.Please use isDescendantOf() instead.Determines if the given DN is under the subtree defined by this DN.For example, the following section of code determines if the DN specified by
dn1is under the subtree specified bydn2.DN dn1 = new DN("uid=bjensen, ou=People, o=Airius.com"); DN dn2 = new DN("ou=People, o=Airius.com"); boolean isContain = dn1.contains(dn2)In this case, since "uid=bjensen, ou=People, o=Airius.com" is an entry under the subtree "ou=People, o=Airius.com", the value ofisContainis true.- Parameters:
dn- the DN of a subtree to check- Returns:
trueif the current DN belongs to the subtree specified bydn.
-
isDescendantOf
Determines if this DN is a descendant of the given DN.For example, the following section of code determines if the DN specified by
dn1is a descendant of the DN specified bydn2.DN dn1 = new DN("uid=bjensen, ou=People, o=Airius.com"); DN dn2 = new DN("ou=People, o=Airius.com"); boolean isDescendant = dn1.isDescendantOf(dn2)In this case, since "uid=bjensen, ou=People, o=Airius.com" is an entry under the subtree "ou=People, o=Airius.com", the value ofisDescendantis true.In the case where the given DN is equal to this DN it returns false.
- Parameters:
dn- the DN of a subtree to check- Returns:
trueif the current DN is a descendant of the DN specified bydn.
-