org.pf.directory
Class DistinguishedName

java.lang.Object
  extended byorg.pf.directory.DistinguishedName

public class DistinguishedName
extends java.lang.Object

Contains a normalized form of a distinguished name that allows comparison.

Version:
1.3
Author:
Manfred Duchrow

Field Summary
static DistinguishedName EMPTY_DN
          This is a special DN with an empty string as name and no elements at all
 
Constructor Summary
DistinguishedName(java.lang.String dn)
          Initialize the new instance with a DN.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 DistinguishedName getParent()
          Returns the parent DN of this DN or EMPTY_DN if this DN has no parent.
 DistinguishedNameElement[] getParts()
          Returns a copy of the parts that build this DN.
 DistinguishedNameElement[] getPartsWithout(int skip)
          Returns a copy of the parts that build this DN without the number of elements given by the parameter.
 DistinguishedNameElement getRDN()
          Returns the relative distinguished name (i.e. the left most element) of this distinguished name.
 int hashCode()
           
 boolean isDirectParentOf(DistinguishedName dn)
          Returns true if the this distinguished name represents an object that is the direct parent of the given dn in the DIT.
static boolean isDistinguishedName(java.lang.String name)
          Returns true if the given name is a valid distinguished name.
 boolean isEmptyDN()
          Returns true if this object is the empty DN (i.e. the object specified by constant EMPTY_DN).
 boolean isEqual(java.lang.String dn)
          Returns true if the given dn is equal to this distinguished name after normalization
 boolean isParentOf(DistinguishedName dn)
          Returns true if the this distinguished name represents an object that is logically a parent of the given dn in the DIT.
static boolean looksLikeDistinguishedName(java.lang.String name)
          Returns true if the given name could be a distinguished (rather than a uid or a common name).
 DistinguishedName makeChild(DistinguishedNameElement rdn)
          Returns the new distinguished name that represents a child of this DN.
 int partCount()
          Returns how many parts this DN consists of
 java.lang.String toString()
          Returns the DN as string where all elements are separated by comma (',') without leading or trailing blanks.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_DN

public static final DistinguishedName EMPTY_DN
This is a special DN with an empty string as name and no elements at all

Constructor Detail

DistinguishedName

public DistinguishedName(java.lang.String dn)
Initialize the new instance with a DN.

Parameters:
dn - The DN that is internally used by the new instance (must not be null)
Throws:
java.lang.IllegalArgumentException - If the given DN is null or blank
Method Detail

looksLikeDistinguishedName

public static boolean looksLikeDistinguishedName(java.lang.String name)
Returns true if the given name could be a distinguished (rather than a uid or a common name). This method is much faster than isDistinguishedName() because it just checks if the given name contains an equals character ('=').


isDistinguishedName

public static boolean isDistinguishedName(java.lang.String name)
Returns true if the given name is a valid distinguished name. That is, it contains elements separated by ',' and matching the pattern: "*?=*?".


toString

public java.lang.String toString()
Returns the DN as string where all elements are separated by comma (',') without leading or trailing blanks.


equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()

isEqual

public boolean isEqual(java.lang.String dn)
Returns true if the given dn is equal to this distinguished name after normalization


isEmptyDN

public boolean isEmptyDN()
Returns true if this object is the empty DN (i.e. the object specified by constant EMPTY_DN).


isParentOf

public boolean isParentOf(DistinguishedName dn)
Returns true if the this distinguished name represents an object that is logically a parent of the given dn in the DIT. This is not necessarily the direct parent of the given DN. It might be any parent up the DIT hierarchy.

Be aware that the EMPTY_DN is NOT parent of any other DN and therefore always returns false here.

Parameters:
dn - The DN to be checked.
See Also:
isDirectParentOf(DistinguishedName)

isDirectParentOf

public boolean isDirectParentOf(DistinguishedName dn)
Returns true if the this distinguished name represents an object that is the direct parent of the given dn in the DIT.

Parameters:
dn - The DN to be checked.

getParts

public DistinguishedNameElement[] getParts()
Returns a copy of the parts that build this DN.


getPartsWithout

public DistinguishedNameElement[] getPartsWithout(int skip)
Returns a copy of the parts that build this DN without the number of elements given by the parameter.

Parameters:
skip - defines how many parts from the right not to return

getRDN

public DistinguishedNameElement getRDN()
Returns the relative distinguished name (i.e. the left most element) of this distinguished name.


partCount

public int partCount()
Returns how many parts this DN consists of


getParent

public DistinguishedName getParent()
Returns the parent DN of this DN or EMPTY_DN if this DN has no parent.


makeChild

public DistinguishedName makeChild(DistinguishedNameElement rdn)
Returns the new distinguished name that represents a child of this DN.

Parameters:
rdn - The relative distinguished name to be added as child element