Package com.unboundid.ldap.sdk
Class RDN
java.lang.Object
com.unboundid.ldap.sdk.RDN
- All Implemented Interfaces:
Serializable,Comparable<RDN>,Comparator<RDN>
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class RDN
extends Object
implements Comparable<RDN>, Comparator<RDN>, Serializable
This class provides a data structure for holding information about an LDAP
relative distinguished name (RDN). An RDN consists of one or more
attribute name-value pairs. See
RFC 4514 for more
information about representing DNs and RDNs as strings. See the
documentation in the
DN class for more information about DNs and
RDNs.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new RDN from the provided string representation.Creates a new (potentially multivalued) RDN.Creates a new (potentially multivalued) RDN.Creates a new (potentially multivalued) RDN.Creates a new (potentially multivalued) RDN.Creates a new single-valued RDN with the provided information.Creates a new single-valued RDN with the provided information.Creates a new RDN from the provided string representation.Creates a new RDN from the provided string representation.Creates a new single-valued RDN with the provided information.Creates a new single-valued RDN with the provided information. -
Method Summary
Modifier and TypeMethodDescriptionintCompares the provided RDN values to determine their relative order in a sorted list.static intCompares the RDN values with the provided string representations to determine their relative order in a sorted list.static intCompares the RDN values with the provided string representations to determine their relative order in a sorted list.intCompares the provided RDN to this RDN to determine their relative order in a sorted list.booleanIndicates whether this RDN is equal to the provided object.booleanIndicates whether the RDN with the provided string representation is equal to this RDN.static booleanIndicates whether the two provided strings represent the same RDN.String[]Retrieves the set of attribute names for this RDN.Retrieves an array of the attributes that comprise this RDN.String[]Retrieves the set of attribute values for this RDN.byte[][]Retrieves the set of attribute values for this RDN.Retrieves a sorted set of the name-value pairs that comprise this RDN.intRetrieves the number of values for this RDN.booleanhasAttribute(String attributeName) Indicates whether this RDN contains the specified attribute.booleanhasAttributeValue(String attributeName, byte[] attributeValue) Indicates whether this RDN contains the specified attribute value.booleanhasAttributeValue(String attributeName, String attributeValue) Indicates whether this RDN contains the specified attribute value.inthashCode()Retrieves a hash code for this RDN.booleanIndicates whether this RDN contains multiple values.static booleanisValidRDN(String s) Indicates whether the provided string represents a valid RDN.static booleanisValidRDN(String s, boolean strictNameChecking) Indicates whether the provided string represents a valid RDN.static StringRetrieves a normalized string representation of the RDN with the provided string representation.static StringRetrieves a normalized string representation of the RDN with the provided string representation.Retrieves a string representation of this RDN with minimal encoding for special characters.Retrieves a normalized string representation of this RDN.voidtoNormalizedString(StringBuilder buffer) Appends a normalized string representation of this RDN to the provided buffer.toString()Retrieves a string representation of this RDN.voidtoString(ByteStringBuffer buffer, DNEscapingStrategy escapingStrategy) Appends a string representation of this RDN to the provided buffer.voidtoString(StringBuilder buffer) Appends a string representation of this RDN to the provided buffer.voidtoString(StringBuilder buffer, boolean minimizeEncoding) Appends a string representation of this RDN to the provided buffer.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
RDN
Creates a new single-valued RDN with the provided information.- Parameters:
attributeName- The attribute name for this RDN. It must not benull.attributeValue- The attribute value for this RDN. It must not benull.
-
RDN
Creates a new single-valued RDN with the provided information.- Parameters:
attributeName- The attribute name for this RDN. It must not benull.attributeValue- The attribute value for this RDN. It must not benull.schema- The schema to use to generate the normalized string representation of this RDN. It may benullif no schema is available.
-
RDN
Creates a new single-valued RDN with the provided information.- Parameters:
attributeName- The attribute name for this RDN. It must not benull.attributeValue- The attribute value for this RDN. It must not benull.
-
RDN
Creates a new single-valued RDN with the provided information.- Parameters:
attributeName- The attribute name for this RDN. It must not benull.attributeValue- The attribute value for this RDN. It must not benull.schema- The schema to use to generate the normalized string representation of this RDN. It may benullif no schema is available.
-
RDN
Creates a new (potentially multivalued) RDN. The set of names must have the same number of elements as the set of values, and there must be at least one element in each array.- Parameters:
attributeNames- The set of attribute names for this RDN. It must not benullor empty.attributeValues- The set of attribute values for this RDN. It must not benullor empty.
-
RDN
public RDN(@NotNull String[] attributeNames, @NotNull String[] attributeValues, @Nullable Schema schema) Creates a new (potentially multivalued) RDN. The set of names must have the same number of elements as the set of values, and there must be at least one element in each array.- Parameters:
attributeNames- The set of attribute names for this RDN. It must not benullor empty.attributeValues- The set of attribute values for this RDN. It must not benullor empty.schema- The schema to use to generate the normalized string representation of this RDN. It may benullif no schema is available.
-
RDN
Creates a new (potentially multivalued) RDN. The set of names must have the same number of elements as the set of values, and there must be at least one element in each array.- Parameters:
attributeNames- The set of attribute names for this RDN. It must not benullor empty.attributeValues- The set of attribute values for this RDN. It must not benullor empty.
-
RDN
public RDN(@NotNull String[] attributeNames, @NotNull byte[][] attributeValues, @Nullable Schema schema) Creates a new (potentially multivalued) RDN. The set of names must have the same number of elements as the set of values, and there must be at least one element in each array.- Parameters:
attributeNames- The set of attribute names for this RDN. It must not benullor empty.attributeValues- The set of attribute values for this RDN. It must not benullor empty.schema- The schema to use to generate the normalized string representation of this RDN. It may benullif no schema is available.
-
RDN
Creates a new RDN from the provided string representation.- Parameters:
rdnString- The string representation to use for this RDN. It must not be empty ornull.- Throws:
LDAPException- If the provided string cannot be parsed as a valid RDN.
-
RDN
Creates a new RDN from the provided string representation.- Parameters:
rdnString- The string representation to use for this RDN. It must not be empty ornull.schema- The schema to use to generate the normalized string representation of this RDN. It may benullif no schema is available.- Throws:
LDAPException- If the provided string cannot be parsed as a valid RDN.
-
RDN
public RDN(@NotNull String rdnString, @Nullable Schema schema, boolean strictNameChecking) throws LDAPException Creates a new RDN from the provided string representation.- Parameters:
rdnString- The string representation to use for this RDN. It must not be empty ornull.schema- The schema to use to generate the normalized string representation of this RDN. It may benullif no schema is available.strictNameChecking- Indicates whether to verify that all attribute type names are valid as per RFC 4514. If this isfalse, then some technically invalid characters may be accepted in attribute type names. If this istrue, then names must be strictly compliant.- Throws:
LDAPException- If the provided string cannot be parsed as a valid RDN.
-
-
Method Details
-
isValidRDN
Indicates whether the provided string represents a valid RDN.- Parameters:
s- The string for which to make the determination. It must not benull.- Returns:
trueif the provided string represents a valid RDN, orfalseif not.
-
isValidRDN
Indicates whether the provided string represents a valid RDN.- Parameters:
s- The string for which to make the determination. It must not benull.strictNameChecking- Indicates whether to verify that all attribute type names are valid as per RFC 4514. If this isfalse, then some technically invalid characters may be accepted in attribute type names. If this istrue, then names must be strictly compliant.- Returns:
trueif the provided string represents a valid RDN, orfalseif not.
-
isMultiValued
Indicates whether this RDN contains multiple values.- Returns:
trueif this RDN contains multiple values, orfalseif not.
-
getValueCount
Retrieves the number of values for this RDN.- Returns:
- The number of values for this RDN.
-
getAttributes
Retrieves an array of the attributes that comprise this RDN.- Returns:
- An array of the attributes that comprise this RDN.
-
getAttributeNames
Retrieves the set of attribute names for this RDN.- Returns:
- The set of attribute names for this RDN.
-
getAttributeValues
Retrieves the set of attribute values for this RDN.- Returns:
- The set of attribute values for this RDN.
-
getByteArrayAttributeValues
Retrieves the set of attribute values for this RDN.- Returns:
- The set of attribute values for this RDN.
-
getNameValuePairs
Retrieves a sorted set of the name-value pairs that comprise this RDN.- Returns:
- A sorted set of the name-value pairs that comprise this RDN.
-
hasAttribute
Indicates whether this RDN contains the specified attribute.- Parameters:
attributeName- The name of the attribute for which to make the determination.- Returns:
trueif RDN contains the specified attribute, orfalseif not.
-
hasAttributeValue
Indicates whether this RDN contains the specified attribute value.- Parameters:
attributeName- The name of the attribute for which to make the determination.attributeValue- The attribute value for which to make the determination.- Returns:
trueif RDN contains the specified attribute, orfalseif not.
-
hasAttributeValue
Indicates whether this RDN contains the specified attribute value.- Parameters:
attributeName- The name of the attribute for which to make the determination.attributeValue- The attribute value for which to make the determination.- Returns:
trueif RDN contains the specified attribute, orfalseif not.
-
toString
Retrieves a string representation of this RDN. -
toMinimallyEncodedString
Retrieves a string representation of this RDN with minimal encoding for special characters. Only those characters specified in RFC 4514 section 2.4 will be escaped. No escaping will be used for non-ASCII characters or non-printable ASCII characters.- Returns:
- A string representation of this RDN with minimal encoding for special characters.
-
toString
Appends a string representation of this RDN to the provided buffer.- Parameters:
buffer- The buffer to which the string representation is to be appended.
-
toString
Appends a string representation of this RDN to the provided buffer.- Parameters:
buffer- The buffer to which the string representation is to be appended.minimizeEncoding- Indicates whether to restrict the encoding of special characters to the bare minimum required by LDAP (as per RFC 4514 section 2.4). If this istrue, then only leading and trailing spaces, double quotes, plus signs, commas, semicolons, greater-than, less-than, and backslash characters will be encoded.
-
toString
public void toString(@NotNull ByteStringBuffer buffer, @NotNull DNEscapingStrategy escapingStrategy) Appends a string representation of this RDN to the provided buffer.- Parameters:
buffer- The buffer to which the string representation is to be appended. It must not benull.escapingStrategy- The strategy to use to determine which types of optional escaping should be used for values. It must not benull.
-
toNormalizedString
Retrieves a normalized string representation of this RDN.- Returns:
- A normalized string representation of this RDN.
-
toNormalizedString
Appends a normalized string representation of this RDN to the provided buffer.- Parameters:
buffer- The buffer to which the normalized string representation is to be appended.
-
normalize
Retrieves a normalized string representation of the RDN with the provided string representation.- Parameters:
s- The string representation of the RDN to normalize. It must not benull.- Returns:
- The normalized string representation of the RDN with the provided string representation.
- Throws:
LDAPException- If the provided string cannot be parsed as an RDN.
-
normalize
@NotNull public static String normalize(@NotNull String s, @Nullable Schema schema) throws LDAPException Retrieves a normalized string representation of the RDN with the provided string representation.- Parameters:
s- The string representation of the RDN to normalize. It must not benull.schema- The schema to use to generate the normalized string representation of the RDN. It may benullif no schema is available.- Returns:
- The normalized string representation of the RDN with the provided string representation.
- Throws:
LDAPException- If the provided string cannot be parsed as an RDN.
-
hashCode
Retrieves a hash code for this RDN. -
equals
Indicates whether this RDN is equal to the provided object. The given object will only be considered equal to this RDN if it is also an RDN with the same set of names and values.- Specified by:
equalsin interfaceComparator<RDN>- Overrides:
equalsin classObject- Parameters:
o- The object for which to make the determination.- Returns:
trueif the provided object can be considered equal to this RDN, orfalseif not.
-
equals
Indicates whether the RDN with the provided string representation is equal to this RDN.- Parameters:
s- The string representation of the DN to compare with this RDN.- Returns:
trueif the DN with the provided string representation is equal to this RDN, orfalseif not.- Throws:
LDAPException- If the provided string cannot be parsed as an RDN.
-
equals
Indicates whether the two provided strings represent the same RDN.- Parameters:
s1- The string representation of the first RDN for which to make the determination. It must not benull.s2- The string representation of the second RDN for which to make the determination. It must not benull.- Returns:
trueif the provided strings represent the same RDN, orfalseif not.- Throws:
LDAPException- If either of the provided strings cannot be parsed as an RDN.
-
compareTo
Compares the provided RDN to this RDN to determine their relative order in a sorted list.- Specified by:
compareToin interfaceComparable<RDN>- Parameters:
rdn- The RDN to compare against this RDN. It must not benull.- Returns:
- A negative integer if this RDN should come before the provided RDN in a sorted list, a positive integer if this RDN should come after the provided RDN in a sorted list, or zero if the provided RDN can be considered equal to this RDN.
-
compare
Compares the provided RDN values to determine their relative order in a sorted list.- Specified by:
comparein interfaceComparator<RDN>- Parameters:
rdn1- The first RDN to be compared. It must not benull.rdn2- The second RDN to be compared. It must not benull.- Returns:
- A negative integer if the first RDN should come before the second RDN in a sorted list, a positive integer if the first RDN should come after the second RDN in a sorted list, or zero if the two RDN values can be considered equal.
-
compare
Compares the RDN values with the provided string representations to determine their relative order in a sorted list.- Parameters:
s1- The string representation of the first RDN to be compared. It must not benull.s2- The string representation of the second RDN to be compared. It must not benull.- Returns:
- A negative integer if the first RDN should come before the second RDN in a sorted list, a positive integer if the first RDN should come after the second RDN in a sorted list, or zero if the two RDN values can be considered equal.
- Throws:
LDAPException- If either of the provided strings cannot be parsed as an RDN.
-
compare
public static int compare(@NotNull String s1, @NotNull String s2, @Nullable Schema schema) throws LDAPException Compares the RDN values with the provided string representations to determine their relative order in a sorted list.- Parameters:
s1- The string representation of the first RDN to be compared. It must not benull.s2- The string representation of the second RDN to be compared. It must not benull.schema- The schema to use to generate the normalized string representations of the RDNs. It may benullif no schema is available.- Returns:
- A negative integer if the first RDN should come before the second RDN in a sorted list, a positive integer if the first RDN should come after the second RDN in a sorted list, or zero if the two RDN values can be considered equal.
- Throws:
LDAPException- If either of the provided strings cannot be parsed as an RDN.
-