Package com.isode.dsapi
Class RDN
- java.lang.Object
-
- com.isode.dsapi.RDN
-
-
Constructor Summary
Constructors Constructor Description RDN(Attribute... attrs)
Constructs a new object based on a list of Attributes.RDN(AttributeType attrType, java.lang.String value)
Constructs an RDN based on a single attribute value.RDN(java.lang.String rdnStr)
Constructs an RDN from LDAP formatted string.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
clearAttributeList(int cnt)
Method called by native library to empty the Attribute list, and insert a number of null place-holdersboolean
equals(java.lang.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
finalize()
Releases any native structures associated with this object.Attribute
getAttribute(int pos)
Returns an attribute from the RDN.int
getAttributeCount()
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.java.util.Iterator<Attribute>
iterator()
Iterate through all the Attributes in this RDN.protected void
jni_dispose()
Native function used to clean up any C data structures attached to this object when it is destroyed in finalisation.java.lang.String
toOIDString()
Generate a String representation of the RDN, including dotted OID values instead of attribute names.java.lang.String
toString()
Returns a String representation of the RDN, containing its attribute name(s) and value(s).java.lang.String
toUIString()
Return a friendly string representation of the RDN (in other words, one that contains no attribute type names).
-
-
-
Constructor Detail
-
RDN
public RDN(java.lang.String rdnStr) throws BadDNException
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
public RDN(Attribute... attrs) throws BadDNException
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, java.lang.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 Detail
-
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 java.lang.Throwable
Releases any native structures associated with this object.- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.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:
java.lang.ArrayIndexOutOfBoundsException
- if pos out of range.
-
iterator
public java.util.Iterator<Attribute> iterator()
Iterate through all the Attributes in this RDN.- Specified by:
iterator
in interfacejava.lang.Iterable<Attribute>
-
isSameValue
public boolean isSameValue(RDN value) throws NativeLibraryException, java.lang.NullPointerException
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 libraryjava.lang.NullPointerException
-
toUIString
public final java.lang.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()
-
toString
public final java.lang.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 classjava.lang.Object
- Returns:
- String representation of RDN (not
null
) - Throws:
NativeLibraryException
- if an unrecoverable error was detected by the native library- See Also:
RDN(String)
,toUIString()
,toOIDString()
-
equals
public boolean equals(java.lang.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 classjava.lang.Object
- 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.- Overrides:
hashCode
in classjava.lang.Object
-
toOIDString
public java.lang.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 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:
toString()
,toUIString()
,DN.toOIDString()
-
-