Class RDN

java.lang.Object
com.isode.dsapi.RDN
All Implemented Interfaces:
Iterable<Attribute>

public class RDN extends Object implements Iterable<Attribute>
Class representing an RDN.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RDN(Attribute... attrs)
    Constructs a new object based on a list of Attributes.
    RDN(AttributeType attrType, String value)
    Constructs an RDN based on a single attribute value.
    RDN(String rdnStr)
    Constructs an RDN from LDAP formatted string.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Method called by native library to empty the Attribute list, and insert a number of null place-holders
    boolean
    equals(Object anObject)
    Compare this RDN to the specified object, and return true if the argument is a RDN that represents the same value as this object.
    protected void
    Releases any native structures associated with this object.
    getAttribute(int pos)
    Returns an attribute from the RDN.
    int
    Returns the number of attributes.
    int
    Overrides Object.hashCode in order to be consistent with the equals(Object) method.
    boolean
    Test whether this value is equivalent to another.
    Iterate through all the Attributes in this RDN.
    protected void
    Native function used to clean up any C data structures attached to this object when it is destroyed in finalisation.
    Generate a String representation of the RDN, including dotted OID values instead of attribute names.
    final String
    Returns a String representation of the RDN, containing its attribute name(s) and value(s).
    final String
    Return a friendly string representation of the RDN (in other words, one that contains no attribute type names).

    Methods inherited from class java.lang.Object

    clone, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • RDN

      public RDN(String rdnStr) throws BadDNException
      Constructs an RDN from LDAP formatted string.
      Parameters:
      rdnStr - String representation of RDN (not null).
      Throws:
      BadDNException - in case of invalid RDN.
      NativeLibraryException - if an unrecoverable error was detected by the native library
    • RDN

      public RDN(Attribute... attrs) throws BadDNException
      Constructs a new object based on a list of Attributes.
      Parameters:
      attrs - list of Attributes (not null)
      Throws:
      BadDNException - in case of invalid RDN, or if attrs is null.
      NativeLibraryException - if an unrecoverable error was detected by the native library
    • RDN

      Constructs an RDN based on a single attribute value. For example:
         AttributeType snType = new AttributeType("sn");
         RDN rdn = new RDN(snType, "Smith");
      will create an RDN for "sn=Smith"
      Parameters:
      attrType - an AttributeType (not null)
      value - attribute value string (not null)
      Throws:
      BadDNException - in case of invalid RDN.
      BadSyntaxException - if the syntax of value is not valid for this attribute.
      BadValueException - if value is not a valid LDAP string representation of an attrType.
      NativeLibraryException - if an unrecoverable error was detected by the native library.
      Since:
      16.0
  • Method Details

    • jni_dispose

      protected void jni_dispose() throws NativeLibraryException
      Native function used to clean up any C data structures attached to this object when it is destroyed in finalisation.
      Throws:
      NativeLibraryException - if an unrecoverable error was detected by the native library
    • finalize

      protected void finalize() throws Throwable
      Releases any native structures associated with this object.
      Overrides:
      finalize in class Object
      Throws:
      Throwable
    • clearAttributeList

      protected void clearAttributeList(int cnt)
      Method called by native library to empty the Attribute list, and insert a number of null place-holders
    • getAttributeCount

      public int getAttributeCount()
      Returns the number of attributes.
      Returns:
      the number of Attributes
    • getAttribute

      public Attribute getAttribute(int pos)
      Returns an attribute from the RDN.
      Parameters:
      pos - Position in (unordered) list of RDNs.
      Returns:
      RDN at given position (not null).
      Throws:
      ArrayIndexOutOfBoundsException - if pos out of range.
    • iterator

      public Iterator<Attribute> iterator()
      Iterate through all the Attributes in this RDN.
      Specified by:
      iterator in interface Iterable<Attribute>
    • isSameValue

      public boolean isSameValue(RDN value) throws NativeLibraryException, NullPointerException
      Test whether this value is equivalent to another.
      Parameters:
      value - Value to compare against (not null)
      Returns:
      true if the given object represents the same value as this one, false otherwise.
      Throws:
      NativeLibraryException - if an unrecoverable error was detected by the native library
      NullPointerException
    • toUIString

      public final String toUIString()
      Return a friendly string representation of the RDN (in other words, one that contains no attribute type names).

      Thus an RDN of "cn=Mister Magoo" gives "Mister Magoo".

      Multiple values are separated by non-delimited plus signs, for example "sales+J. Smith". Unlike the toString() method, no escaping of special characters within the values takes place; so an RDN representing the common name "harry, fred, ginger + marty" will be returned as "harry, fred, ginger + marty".

      Returns:
      "UI-friendly" string representation of RDN (not null)
      See Also:
    • toString

      public final String toString() throws NativeLibraryException
      Returns a String representation of the RDN, containing its attribute name(s) and value(s). Multiple values are separated by non-delimited plus signs, for example "ou=sales+cn=J. Smith". Any special characters within the attribute values will be escaped with a "\". For example an RDN representing a common name of "harry, fred, ginger + marty" will be returned as "cn=harry\, fred\, ginger \+ marty". The String returned is suitable for using in the RDN(String) constructor.
      Overrides:
      toString in class Object
      Returns:
      String representation of RDN (not null)
      Throws:
      NativeLibraryException - if an unrecoverable error was detected by the native library
      See Also:
    • equals

      public boolean equals(Object anObject)
      Compare this RDN to the specified object, and return true if the argument is a RDN that represents the same value as this object.
      Overrides:
      equals in class Object
      Parameters:
      anObject - an object to compare this RDN against (null allowed - will return false)
      Returns:
      true if the values are equal, false otherwise.
      Throws:
      NativeLibraryException - if an unrecoverable error was detected by the native library
    • hashCode

      public int hashCode()
      Overrides Object.hashCode in order to be consistent with the equals(Object) method.
      Overrides:
      hashCode in class Object
    • toOIDString

      public String toOIDString()
      Generate a String representation of the RDN, including dotted OID values instead of attribute names.

      String values returned by this method may be used when constructing new RDNs, in which case they are considered equivalent to their "non OID" forms.

      For example

           RDN rdn = new RDN("cn=Mister Magoo");
           String str = rdn.toString();
           String oid = rdn.toOIDString();
           System.out.println(str);
           System.out.println(oid);
           RDN rdn2 = new RDN(oid);
           System.out.println(rdn.equals(rdn2));
       
      will display
         cn=Mister Magoo
         2.5.4.3=Mister Magoo
         true
       
      Returns:
      a String representation with OIDs being used for attribute names
      Since:
      14.6
      See Also: