LDAP Classes
Implements Java LDAP

com.novell.ldap.util
Class DN

java.lang.Object
  extended bycom.novell.ldap.util.DN

public class DN
extends java.lang.Object

A DN encapsulates a Distinguished Name (an ldap name with context). A DN does not need to be fully distinguished, or extend to the Root of a directory. It provides methods to get information about the DN and to manipulate the DN.

The following are examples of valid DN:

Note: Multivalued attributes are all considered to be one component and are represented in one RDN (see RDN)

See Also:
RDN

Constructor Summary
DN()
           
DN(java.lang.String dnString)
          Constructs a new DN based on the specified string representation of a distinguished name.
 
Method Summary
 void addRDN(RDN rdn)
          Adds the RDN to the beginning of the current DN.
 void addRDNToBack(RDN rdn)
          Adds the RDN to the end of the current DN
 void addRDNToFront(RDN rdn)
          Adds the RDN to the beginning of the current DN.
 int countRDNs()
          Retrieves the count of RDNs, or individule names, in the Distinguished name
 boolean equals(DN toDN)
          Compares this DN to the specified DN to determine if they are equal.
 java.lang.String[] explodeDN(boolean noTypes)
          return a string array of the individual RDNs contained in the DN
 DN getParent()
          Returns the Parent of this DN
 java.util.Vector getRDNs()
          Retrieves a list of RDN Objects, or individual names of the DN
 boolean isDescendantOf(DN containerDN)
          Determines if this DN is contained by the DN passed in.
 java.lang.String toString()
          Creates and returns a string that represents this DN.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DN

public DN()

DN

public DN(java.lang.String dnString)
Constructs a new DN based on the specified string representation of a distinguished name. The syntax of the DN must conform to that specified in RFC 2253.

Parameters:
dnString - a string representation of the distinguished name
Throws:
java.lang.IllegalArgumentException - if the the value of the dnString parameter does not adhere to the syntax described in RFC 2253
Method Detail

toString

public java.lang.String toString()
Creates and returns a string that represents this DN. The string follows RFC 2253, which describes String representation of DN's and RDN's

Returns:
A DN string.

equals

public boolean equals(DN toDN)
Compares this DN to the specified DN to determine if they are equal.

Parameters:
toDN - the DN to compare to
Returns:
true if the DNs are equal; otherwise false

explodeDN

public java.lang.String[] explodeDN(boolean noTypes)
return a string array of the individual RDNs contained in the DN

Parameters:
noTypes - If true, returns only the values of the components, and not the names, e.g. "Babs Jensen", "Accounting", "Acme", "us" - instead of "cn=Babs Jensen", "ou=Accounting", "o=Acme", and "c=us".
Returns:
String[] containing the rdns in the DN with the leftmost rdn in the first element of the array

countRDNs

public int countRDNs()
Retrieves the count of RDNs, or individule names, in the Distinguished name

Returns:
the count of RDN

getRDNs

public java.util.Vector getRDNs()
Retrieves a list of RDN Objects, or individual names of the DN

Returns:
list of RDNs

isDescendantOf

public boolean isDescendantOf(DN containerDN)
Determines if this DN is contained by the DN passed in. For example: "cn=admin, ou=marketing, o=corporation" is contained by "o=corporation", "ou=marketing, o=corporation", and "ou=marketing" but not by "cn=admin" or "cn=admin,ou=marketing,o=corporation" Note: For users of Netscape's SDK this method is comparable to contains

Parameters:
containerDN - of a container
Returns:
true if containerDN contains this DN

getParent

public DN getParent()
Returns the Parent of this DN

Returns:
Parent DN

addRDN

public void addRDN(RDN rdn)
Adds the RDN to the beginning of the current DN.

Parameters:
rdn - an RDN to be added

addRDNToFront

public void addRDNToFront(RDN rdn)
Adds the RDN to the beginning of the current DN.

Parameters:
rdn - an RDN to be added

addRDNToBack

public void addRDNToBack(RDN rdn)
Adds the RDN to the end of the current DN

Parameters:
rdn - an RDN to be added

LDAP Classes
Implements Java LDAP

Copyright © 2002 Novell, Inc. All Rights Reserved.
Novell, Inc.
1800 South Novell Place
Provo, Ut 84606
Phone: (801) 861-5000