All LDAP Classes
Internal LDAP Classes

com.novell.ldap.util
Class DN

java.lang.Object
  extended by com.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

Field Summary
private static int ALPHA_ATTR_TYPE
           
private static int HEX_RDN_VALUE
           
private static int LOOK_FOR_RDN_ATTR_TYPE
           
private static int LOOK_FOR_RDN_VALUE
           
private static int OID_ATTR_TYPE
           
private static int QUOTED_RDN_VALUE
           
private  java.util.ArrayList rdnList
           
private static int UNQUOTED_RDN_VALUE
           
 
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
private static char hexToChar(char hex1, char hex0)
          Converts two valid hex digit characters that form the string representation of an ascii character value to the actual ascii character.
private  boolean isAlpha(char ch)
          Checks a character to see if it is an ascii alphabetic character in ranges 65-90 or 97-122.
 boolean isDescendantOf(DN containerDN)
          Determines if this DN is contained by the DN passed in.
private  boolean isDigit(char ch)
          Checks a character to see if it is an ascii digit (0-9) character in the ascii value range 48-57.
private static boolean isHexDigit(char ch)
          Checks a character to see if it is valid hex digit 0-9, a-f, or A-F (ASCII value ranges 48-47, 65-70, 97-102).
private  boolean needsEscape(char ch)
          Checks a character to see if it must always be escaped in the string representation of a DN.
 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
 

Field Detail

LOOK_FOR_RDN_ATTR_TYPE

private static final int LOOK_FOR_RDN_ATTR_TYPE
See Also:
Constant Field Values

ALPHA_ATTR_TYPE

private static final int ALPHA_ATTR_TYPE
See Also:
Constant Field Values

OID_ATTR_TYPE

private static final int OID_ATTR_TYPE
See Also:
Constant Field Values

LOOK_FOR_RDN_VALUE

private static final int LOOK_FOR_RDN_VALUE
See Also:
Constant Field Values

QUOTED_RDN_VALUE

private static final int QUOTED_RDN_VALUE
See Also:
Constant Field Values

HEX_RDN_VALUE

private static final int HEX_RDN_VALUE
See Also:
Constant Field Values

UNQUOTED_RDN_VALUE

private static final int UNQUOTED_RDN_VALUE
See Also:
Constant Field Values

rdnList

private java.util.ArrayList rdnList
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

isAlpha

private boolean isAlpha(char ch)
Checks a character to see if it is an ascii alphabetic character in ranges 65-90 or 97-122.

Parameters:
ch - the character to be tested.
Returns:
true if the character is an ascii alphabetic character

isDigit

private boolean isDigit(char ch)
Checks a character to see if it is an ascii digit (0-9) character in the ascii value range 48-57.

Parameters:
ch - the character to be tested.
Returns:
true if the character is an ascii alphabetic character

isHexDigit

private static boolean isHexDigit(char ch)
Checks a character to see if it is valid hex digit 0-9, a-f, or A-F (ASCII value ranges 48-47, 65-70, 97-102).

Parameters:
ch - the character to be tested.
Returns:
true if the character is a valid hex digit

needsEscape

private boolean needsEscape(char ch)
Checks a character to see if it must always be escaped in the string representation of a DN. We must tests for space, sharp, and equals individually.

Parameters:
ch - the character to be tested.
Returns:
true if the character needs to be escaped in at least some instances.

hexToChar

private static char hexToChar(char hex1,
                              char hex0)
                       throws java.lang.IllegalArgumentException
Converts two valid hex digit characters that form the string representation of an ascii character value to the actual ascii character.

Parameters:
hex1 - the hex digit for the high order byte.
hex0 - the hex digit for the low order byte.
Returns:
the character whose value is represented by the parameters.
Throws:
java.lang.IllegalArgumentException

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

Overrides:
toString in class java.lang.Object
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

All LDAP Classes
Internal LDAP Classes

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