Package com.isode.dsapi
Class RDN
java.lang.Object
com.isode.dsapi.RDN
Class representing an RDN.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
clearAttributeList
(int cnt) Method called by native library to empty the Attribute list, and insert a number of null place-holdersboolean
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
finalize()
Releases any native structures associated with this object.getAttribute
(int pos) Returns an attribute from the RDN.int
Returns the number of attributes.int
hashCode()
Overrides Object.hashCode in order to be consistent with the equals(Object) method.boolean
isSameValue
(RDN value) Test whether this value is equivalent to another.iterator()
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
toString()
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 interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
RDN
Constructs an RDN from LDAP formatted string.- Parameters:
rdnStr
- String representation of RDN (notnull
).- Throws:
BadDNException
- in case of invalid RDN.NativeLibraryException
- if an unrecoverable error was detected by the native library
-
RDN
Constructs a new object based on a list of Attributes.- Parameters:
attrs
- list of Attributes (notnull
)- Throws:
BadDNException
- in case of invalid RDN, or if attrs is null.NativeLibraryException
- if an unrecoverable error was detected by the native library
-
RDN
public RDN(AttributeType attrType, String value) throws BadDNException, BadSyntaxException, BadValueException 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 (notnull
)value
- attribute value string (notnull
)- 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
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
Releases any native structures associated with this object. -
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
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
Iterate through all the Attributes in this RDN. -
isSameValue
Test whether this value is equivalent to another.- Parameters:
value
- Value to compare against (notnull
)- 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 libraryNullPointerException
-
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
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 classObject
- Returns:
- String representation of RDN (not
null
) - Throws:
NativeLibraryException
- if an unrecoverable error was detected by the native library- See Also:
-
equals
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 classObject
- Parameters:
anObject
- an object to compare this RDN against (null
allowed - will returnfalse
)- 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. -
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 displaycn=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:
-