Skip navigation links

Oracle Internet Directory API Reference
11g Release 1 (11.1.1)

E10664-01


oracle.ldap.util
Class DistinguishedName

java.lang.Object
  extended by oracle.ldap.util.DistinguishedName

All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<java.lang.Object>, javax.naming.Name

public class DistinguishedName
extends java.lang.Object
implements javax.naming.Name

This class represents a distinguished name. The underlying implementation uses clases in Sun's LDAP provider which is based on RFC 2253.

See Also:
Serialized Form

Field Summary

 

Fields inherited from interface javax.naming.Name
serialVersionUID

 

Constructor Summary
DistinguishedName(java.lang.String dnString)
          Constructs a Distinguished Name from the given DN value

 

Method Summary
 javax.naming.Name add(int posn, java.lang.String comp)
          Adds a single component at a specified position within this name.
 javax.naming.Name add(java.lang.String comp)
          Adds a single component to the end of this name.
 javax.naming.Name addAll(int posn, javax.naming.Name n)
          Adds the components of a name (in order) at a specified position within this name.
 javax.naming.Name addAll(javax.naming.Name suffix)
          Adds the components of a name (in order) to the end of this name
 java.lang.Object clone()
          Creates a clone of this Distinguished Name.
 int compareTo(java.lang.Object obj)
          Compares this Distinguished Name with the specified Object for order.
 boolean endsWith(javax.naming.Name n)
          Determines whether this name ends with a specified suffix.
 boolean equals(java.lang.Object obj)
          Determines whether two distinguished names are equal.
 java.lang.String get(int posn)
          Retrieves a component of this name
 java.util.Enumeration getAll()
          Retrieves the componnets of this name as an enumeration of Strings.
 javax.naming.ldap.LdapName getLdapName()
          Returns an LdapName equivalent to this name
 java.lang.String getNormalizedDN()
          Returns the normalized version of this name.
 DistinguishedName getParentDN()
          Returns the parent of this distinguished name.
 javax.naming.Name getPrefix(int posn)
          Creates a name whose components consist of a prefix of the components of this name.
 DistinguishedName getRDN()
          Returns the RDN portion of this distinguished name.
 javax.naming.Name getSuffix(int posn)
          Creates a name whose components consist of a suffix of the components in this name.
 boolean isEmpty()
          Determines whether this name is empty.
static void main(java.lang.String[] args)
           
 java.lang.Object remove(int posn)
          Removes a component from this name.
 int size()
          Returns the number of components in this name.
 boolean startsWith(javax.naming.Name n)
          Determines whether this name starts with a specified prefix.
 java.lang.String toString()
          Returns the string representation of this name.

 

Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

 

Constructor Detail

DistinguishedName

public DistinguishedName(java.lang.String dnString)
                  throws javax.naming.InvalidNameException
Constructs a Distinguished Name from the given DN value
Parameters:
dnString - the DN value
Throws:
javax.naming.InvalidNameException - if syntax error is encountered

Method Detail

clone

public java.lang.Object clone()
Creates a clone of this Distinguished Name. Changes to this name will not affect the new copy and vice versa.
Specified by:
clone in interface javax.naming.Name
Overrides:
clone in class java.lang.Object
Returns:
A clone of this Distinguished Name.

equals

public boolean equals(java.lang.Object obj)
Determines whether two distinguished names are equal. If obj is null or not a DistinguishedName, false is returned
Overrides:
equals in class java.lang.Object
Parameters:
obj - the possibly null object to compare against.
Returns:
true if obj is equal to this DistinguishedName, false otherwise.

compareTo

public int compareTo(java.lang.Object obj)
Compares this Distinguished Name with the specified Object for order. Returns a negative integer, zero, or a positive integer as this name is less than, equal to, or greater than the given name.
Specified by:
compareTo in interface java.lang.Comparable<java.lang.Object>
Specified by:
compareTo in interface javax.naming.Name
Parameters:
obj - the non-null object to compare against
Returns:
a negative integer, zero, or a positive integer as this name is less than, equal to, or greater than the given name.
Throws:
java.lang.ClassCastException - if obj is not a Name of a type that may be compared with this name

size

public int size()
Returns the number of components in this name.
Specified by:
size in interface javax.naming.Name
Returns:
the number of components in this name.

isEmpty

public boolean isEmpty()
Determines whether this name is empty. An empty name has zero components.
Specified by:
isEmpty in interface javax.naming.Name
Returns:
true if this name is empty, false otherwise.

getAll

public java.util.Enumeration getAll()
Retrieves the componnets of this name as an enumeration of Strings. If the name has zero components, an empty (non-null) enumeration is returned.
Specified by:
getAll in interface javax.naming.Name

get

public java.lang.String get(int posn)
Retrieves a component of this name
Specified by:
get in interface javax.naming.Name
Parameters:
posn - the 0-based index of the component to retrieve. Must be in the range [0,size()].
Returns:
the component at index posn
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is outside the specified range

getPrefix

public javax.naming.Name getPrefix(int posn)
Creates a name whose components consist of a prefix of the components of this name. Subsequent changes to this name will not affect the name that is returned and vice versa
Specified by:
getPrefix in interface javax.naming.Name
Parameters:
posn - the 0-based index of the component to retrieve. Must be in the range [0,size()).
Returns:
a name consisting of the components at indexes in the range [0,posn)

getSuffix

public javax.naming.Name getSuffix(int posn)
Creates a name whose components consist of a suffix of the components in this name. Subsequent changes to this name do not affect the name that is returned and vice versa.
Specified by:
getSuffix in interface javax.naming.Name
Parameters:
posn - the 0-based index of the component at which to start. Must be in the range [0,size()].
Returns:
a name consisting of the components at indexes in the range [posn,size()). If posn is equal to size(), an empty name is returned.

startsWith

public boolean startsWith(javax.naming.Name n)
Determines whether this name starts with a specified prefix. A name n is a prefix if it is equal to getPrefix(n.size()).
Specified by:
startsWith in interface javax.naming.Name
Parameters:
n - the name to check.
Returns:
true if n is a prefix of this name, false otherwise.

endsWith

public boolean endsWith(javax.naming.Name n)
Determines whether this name ends with a specified suffix. A name n is a suffix if it is equal to getSuffix(size()-n.size()).
Specified by:
endsWith in interface javax.naming.Name
Parameters:
n - the name to check
Returns:
true if n is a suffix of this name, false otherwise.

addAll

public javax.naming.Name addAll(javax.naming.Name suffix)
                         throws javax.naming.InvalidNameException
Adds the components of a name (in order) to the end of this name
Specified by:
addAll in interface javax.naming.Name
Parameters:
suffix - the components to add
Returns:
the updated name (not a new one)
Throws:
javax.naming.InvalidNameException - if suffix is not a valid name, or if the addition of the components would violate the syntax rules of this name

addAll

public javax.naming.Name addAll(int posn,
                                javax.naming.Name n)
                         throws javax.naming.InvalidNameException
Adds the components of a name (in order) at a specified position within this name. Components of ths name at or after the index of the first new component are shifted up (away from 0) to accommodate the new components.
Specified by:
addAll in interface javax.naming.Name
Parameters:
n - the components to add
posn - the index in this name at which to add the new components. Must be in the range [0,size()].
Returns:
the updated name (not a new one)
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is ouside of the specified range.
javax.naming.InvalidNameException - if n is not valid name, or if the addtion of the components would violate the syntax rules of this name.

add

public javax.naming.Name add(java.lang.String comp)
                      throws javax.naming.InvalidNameException
Adds a single component to the end of this name.
Specified by:
add in interface javax.naming.Name
Parameters:
comp - the component to add
Returns:
the updated name (not a new one)
Throws:
javax.naming.InvalidNameException - if adding comp would violate the syntax rules of this name

add

public javax.naming.Name add(int posn,
                             java.lang.String comp)
                      throws javax.naming.InvalidNameException
Adds a single component at a specified position within this name. Components of this name at or after the index of the new component are shifted up by one (away from index0) to accommodate the new component.
Specified by:
add in interface javax.naming.Name
Parameters:
comp - the component to add
posn - the index at which to add the new component. Must be in the range [0,size()].
Returns:
the updated name (not a new one)
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is ouside of the specified range.
javax.naming.InvalidNameException - if n is not valid name, or if the addtion of the components would violate the syntax rules of this name.

remove

public java.lang.Object remove(int posn)
                        throws javax.naming.InvalidNameException
Removes a component from this name. The component of this name at the specified position is removed. Components with indexes greater than this position are shifted down (toward index 0) by one.
Specified by:
remove in interface javax.naming.Name
Parameters:
posn - the index of the component to remove. Must be in the range [0,size()).
Returns:
the component removed (a String)
Throws:
java.lang.ArrayIndexOutOfBoundsException - if posn is ouside of the specified range.
javax.naming.InvalidNameException - if deleting the component would violate the syntax rules of this name.

getNormalizedDN

public java.lang.String getNormalizedDN()
Returns the normalized version of this name.
Returns:
the noramlized version of this name.

getParentDN

public DistinguishedName getParentDN()
                              throws javax.naming.InvalidNameException
Returns the parent of this distinguished name.
Returns:
a new name which is the parent of this distinguished name.
Throws:
javax.naming.InvalidNameException

getRDN

public DistinguishedName getRDN()
                         throws javax.naming.InvalidNameException
Returns the RDN portion of this distinguished name.
Returns:
a new name which is the RDN of this distinguished name.
Throws:
javax.naming.InvalidNameException

toString

public java.lang.String toString()
Returns the string representation of this name.
Overrides:
toString in class java.lang.Object
Returns:
the string representation of this name.

getLdapName

public javax.naming.ldap.LdapName getLdapName()
Returns an LdapName equivalent to this name
Returns:
a new LdapName equivalent to this name

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

Skip navigation links

Oracle Internet Directory API Reference
11g Release 1 (11.1.1)

E10664-01


Copyright © 1999, 2009 Oracle. All Rights Reserved.