org.opends.server.interop
Class LazyDN

java.lang.Object
  extended by org.opends.server.types.DN
      extended by org.opends.server.interop.LazyDN
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<DN>

@PublicAPI(stability=UNCOMMITTED,
           mayInstantiate=true,
           mayExtend=false,
           mayInvoke=true,
           notes="This is only intended for use if a DN will ever only be treated as a string and will not be transferred or processed in any way.")
public class LazyDN
extends DN

This class provides an implementation of a DN which is lazily initialized. It may be created using only a string representation and no decoding will be performed as long as only the string representation is accessed. If any methods are called which require the decoded DN, this class will attempt to decode the DN string as a DN and then invoke the corresponding method on the decoded version. If any error occurs while trying to decode the provided string as a DN, then a RuntimeException will be thrown.

Note that this implementation is only intended for use in cases in which the DN is only needed as a string representation (in particular, only the toString methods will be used). For cases in which any other methods will need to be invoked on the object, the org.opends.server.types.DN class should be used instead.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.opends.server.types.DN
NULL_DN
 
Constructor Summary
LazyDN(java.lang.String dnString)
          Creates a new lazily-initialized DN with the provided string representation.
 
Method Summary
 int compareTo(DN dn)
          Compares this DN with the provided DN based on a natural order.
 DN concat(DN relativeBaseDN)
          Creates a new DN that is a descendant of this DN, using the specified DN as a relative base DN.
 DN concat(RDN rdn)
          Creates a new DN that is a child of this DN, using the specified RDN.
 DN concat(RDN[] rdnComponents)
          Creates a new DN that is a descendant of this DN, using the specified RDN components.
 boolean equals(java.lang.Object o)
          Indicates whether the provided object is equal to this DN.
 int getNumComponents()
          Retrieves the number of RDN components for this DN.
 DN getParent()
          Retrieves the DN of the entry that is the immediate parent for this entry.
 DN getParentDNInSuffix()
          Retrieves the DN of the entry that is the immediate parent for this entry.
 RDN getRDN()
          Retrieves the outermost RDN component for this DN (i.e., the one that is furthest from the suffix).
 RDN getRDN(int pos)
          Retrieves the RDN component at the specified position in the set of components for this DN.
 int hashCode()
          Retrieves the hash code for this DN.
 boolean isAncestorOf(DN dn)
          Indicates whether this DN is an ancestor of the provided DN (i.e., that the RDN components of this DN are the same as the last RDN components for the provided DN).
 boolean isDescendantOf(DN dn)
          Indicates whether this DN is a descendant of the provided DN (i.e., that the RDN components of the provided DN are the same as the last RDN components for this DN).
 boolean isNullDN()
          Indicates whether this represents a null DN.
 boolean matchesBaseAndScope(DN baseDN, SearchScope scope)
          Indicates whether this entry falls within the range of the provided search base DN and scope.
 java.lang.String toNormalizedString()
          Retrieves a normalized string representation of this DN.
 void toNormalizedString(java.lang.StringBuilder buffer)
          Appends a normalized string representation of this DN to the provided buffer.
 java.lang.String toString()
          Retrieves a string representation of this DN.
 void toString(java.lang.StringBuilder buffer)
          Appends a string representation of this DN to the provided buffer.
 
Methods inherited from class org.opends.server.types.DN
decode, decode, nullDN
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LazyDN

public LazyDN(java.lang.String dnString)
Creates a new lazily-initialized DN with the provided string representation.

Parameters:
dnString - The string representation to use for this lazily-initialized DN.
Method Detail

isNullDN

public boolean isNullDN()
                 throws java.lang.RuntimeException
Indicates whether this represents a null DN. This could target the root DSE for the Directory Server, or the authorization DN for an anonymous or unauthenticated client.

Overrides:
isNullDN in class DN
Returns:
true if this does represent a null DN, or false if it does not.
Throws:
java.lang.RuntimeException

getNumComponents

public int getNumComponents()
                     throws java.lang.RuntimeException
Retrieves the number of RDN components for this DN.

Overrides:
getNumComponents in class DN
Returns:
The number of RDN components for this DN.
Throws:
java.lang.RuntimeException

getRDN

public RDN getRDN()
           throws java.lang.RuntimeException
Retrieves the outermost RDN component for this DN (i.e., the one that is furthest from the suffix).

Overrides:
getRDN in class DN
Returns:
The outermost RDN component for this DN, or null if there are no RDN components in the DN.
Throws:
java.lang.RuntimeException

getRDN

public RDN getRDN(int pos)
           throws java.lang.RuntimeException
Retrieves the RDN component at the specified position in the set of components for this DN.

Overrides:
getRDN in class DN
Parameters:
pos - The position of the RDN component to retrieve.
Returns:
The RDN component at the specified position in the set of components for this DN.
Throws:
java.lang.RuntimeException

getParent

public DN getParent()
             throws java.lang.RuntimeException
Retrieves the DN of the entry that is the immediate parent for this entry. Note that this method does not take the server's naming context configuration into account when making the determination.

Overrides:
getParent in class DN
Returns:
The DN of the entry that is the immediate parent for this entry, or null if the entry with this DN does not have a parent.
Throws:
java.lang.RuntimeException

getParentDNInSuffix

public DN getParentDNInSuffix()
                       throws java.lang.RuntimeException
Retrieves the DN of the entry that is the immediate parent for this entry. This method does take the server's naming context configuration into account, so if the current DN is a naming context for the server, then it will not be considered to have a parent.

Overrides:
getParentDNInSuffix in class DN
Returns:
The DN of the entry that is the immediate parent for this entry, or null if the entry with this DN does not have a parent (either because there is only a single RDN component or because this DN is a suffix defined in the server).
Throws:
java.lang.RuntimeException

concat

public DN concat(RDN rdn)
          throws java.lang.RuntimeException
Creates a new DN that is a child of this DN, using the specified RDN.

Overrides:
concat in class DN
Parameters:
rdn - The RDN for the child of this DN.
Returns:
A new DN that is a child of this DN, using the specified RDN.
Throws:
java.lang.RuntimeException

concat

public DN concat(RDN[] rdnComponents)
          throws java.lang.RuntimeException
Creates a new DN that is a descendant of this DN, using the specified RDN components.

Overrides:
concat in class DN
Parameters:
rdnComponents - The RDN components for the descendant of this DN.
Returns:
A new DN that is a descendant of this DN, using the specified RDN components.
Throws:
java.lang.RuntimeException

concat

public DN concat(DN relativeBaseDN)
          throws java.lang.RuntimeException
Creates a new DN that is a descendant of this DN, using the specified DN as a relative base DN. That is, the resulting DN will first have the components of the provided DN followed by the components of this DN.

Overrides:
concat in class DN
Parameters:
relativeBaseDN - The relative base DN to concatenate onto this DN.
Returns:
A new DN that is a descendant of this DN, using the specified DN as a relative base DN.
Throws:
java.lang.RuntimeException

isDescendantOf

public boolean isDescendantOf(DN dn)
                       throws java.lang.RuntimeException
Indicates whether this DN is a descendant of the provided DN (i.e., that the RDN components of the provided DN are the same as the last RDN components for this DN). Note that if this DN equals the provided DN it is still considered to be a descendant of the provided DN by this method as both then reside within the same subtree.

Overrides:
isDescendantOf in class DN
Parameters:
dn - The DN for which to make the determination.
Returns:
true if this DN is a descendant of the provided DN, or false if not.
Throws:
java.lang.RuntimeException

isAncestorOf

public boolean isAncestorOf(DN dn)
                     throws java.lang.RuntimeException
Indicates whether this DN is an ancestor of the provided DN (i.e., that the RDN components of this DN are the same as the last RDN components for the provided DN).

Overrides:
isAncestorOf in class DN
Parameters:
dn - The DN for which to make the determination.
Returns:
true if this DN is an ancestor of the provided DN, or false if not.
Throws:
java.lang.RuntimeException

matchesBaseAndScope

public boolean matchesBaseAndScope(DN baseDN,
                                   SearchScope scope)
                            throws java.lang.RuntimeException
Indicates whether this entry falls within the range of the provided search base DN and scope.

Overrides:
matchesBaseAndScope in class DN
Parameters:
baseDN - The base DN for which to make the determination.
scope - The search scope for which to make the determination.
Returns:
true if this entry is within the given base and scope, or false if it is not.
Throws:
java.lang.RuntimeException

equals

public boolean equals(java.lang.Object o)
               throws java.lang.RuntimeException
Indicates whether the provided object is equal to this DN. In order for the object to be considered equal, it must be a DN with the same number of RDN components and each corresponding RDN component must be equal.

Overrides:
equals in class DN
Parameters:
o - The object for which to make the determination.
Returns:
true if the provided object is a DN that is equal to this DN, or false if it is not.
Throws:
java.lang.RuntimeException

hashCode

public int hashCode()
             throws java.lang.RuntimeException
Retrieves the hash code for this DN. The hash code will be the sum of the hash codes for all the RDN components.

Overrides:
hashCode in class DN
Returns:
The hash code for this DN.
Throws:
java.lang.RuntimeException

toString

public java.lang.String toString()
Retrieves a string representation of this DN.

Overrides:
toString in class DN
Returns:
A string representation of this DN.

toString

public void toString(java.lang.StringBuilder buffer)
Appends a string representation of this DN to the provided buffer.

Overrides:
toString in class DN
Parameters:
buffer - The buffer to which the information should be appended.

toNormalizedString

public java.lang.String toNormalizedString()
                                    throws java.lang.RuntimeException
Retrieves a normalized string representation of this DN.

Overrides:
toNormalizedString in class DN
Returns:
A normalized string representation of this DN.
Throws:
java.lang.RuntimeException

toNormalizedString

public void toNormalizedString(java.lang.StringBuilder buffer)
                        throws java.lang.RuntimeException
Appends a normalized string representation of this DN to the provided buffer.

Overrides:
toNormalizedString in class DN
Parameters:
buffer - The buffer to which the information should be appended.
Throws:
java.lang.RuntimeException

compareTo

public int compareTo(DN dn)
              throws java.lang.RuntimeException
Compares this DN with the provided DN based on a natural order. This order will be first hierarchical (ancestors will come before descendants) and then alphabetical by attribute name(s) and value(s).

Specified by:
compareTo in interface java.lang.Comparable<DN>
Overrides:
compareTo in class DN
Parameters:
dn - The DN against which to compare this DN.
Returns:
A negative integer if this DN should come before the provided DN, a positive integer if this DN should come after the provided DN, or zero if there is no difference with regard to ordering.
Throws:
java.lang.RuntimeException