public class LdapAttribute extends AbstractLdapBean
| Modifier and Type | Class and Description |
|---|---|
private class |
LdapAttribute.LdapAttributeValues<T>
Simple bean for ldap attribute values.
|
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
attributeName
Name for this attribute.
|
private LdapAttribute.LdapAttributeValues<?> |
attributeValues
Values for this attribute.
|
private static int |
HASH_CODE_SEED
hash code seed.
|
private static long |
serialVersionUID
serial version uid.
|
| Constructor and Description |
|---|
LdapAttribute()
Default constructor.
|
LdapAttribute(boolean binary)
Creates a new ldap attribute.
|
LdapAttribute(SortBehavior sb)
Creates a new ldap attribute.
|
LdapAttribute(SortBehavior sb,
boolean binary)
Creates a new ldap attribute.
|
LdapAttribute(java.lang.String name)
Creates a new ldap attribute.
|
LdapAttribute(java.lang.String name,
byte[]... values)
Creates a new ldap attribute.
|
LdapAttribute(java.lang.String name,
java.lang.String... values)
Creates a new ldap attribute.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBinaryValue(byte[]... value)
Adds the supplied byte array as a value for this attribute.
|
void |
addBinaryValues(java.util.Collection<byte[]> values)
Adds all the byte arrays in the supplied collection as values for this attribute.
|
void |
addStringValue(java.lang.String... value)
Adds the supplied string as a value for this attribute.
|
void |
addStringValues(java.util.Collection<java.lang.String> values)
Adds all the strings in the supplied collection as values for this attribute.
|
<T> void |
addValue(ValueTranscoder<T> transcoder,
T... value)
Adds the supplied values for this attribute by encoding them with the supplied transcoder.
|
<T> void |
addValues(ValueTranscoder<T> transcoder,
java.util.Collection<T> values)
Adds all the values in the supplied collection for this attribute by encoding them with the supplied transcoder.
|
void |
clear()
Removes all the values in this ldap attribute.
|
static LdapAttribute |
createLdapAttribute(SortBehavior sb,
java.lang.String name,
java.util.Collection<java.lang.Object> values)
Creates a new ldap attribute.
|
protected <E> java.util.Collection<E> |
createSortBehaviorCollection(java.lang.Class<E> c)
Returns an implementation of collection for the sort behavior of this bean.
|
static java.lang.String |
escapeValue(java.lang.String value)
Escapes the supplied string value per RFC 4514 section 2.4.
|
byte[] |
getBinaryValue()
Returns a single byte array value of this attribute.
|
java.util.Collection<byte[]> |
getBinaryValues()
Returns the values of this attribute as byte arrays.
|
private static <E> java.util.Comparator<E> |
getComparator(java.lang.Class<E> c)
Returns a comparator for the supplied class type.
|
java.lang.String |
getName()
Returns the name of this attribute.
|
java.lang.String |
getName(boolean withOptions)
Returns the name of this attribute with or without options.
|
java.lang.String[] |
getOptions()
Returns the options for this attribute.
|
java.lang.String |
getStringValue()
Returns a single string value of this attribute.
|
java.util.Collection<java.lang.String> |
getStringValues()
Returns the values of this attribute as strings.
|
<T> T |
getValue(ValueTranscoder<T> transcoder)
Returns a single decoded value of this attribute.
|
<T> java.util.Collection<T> |
getValues(ValueTranscoder<T> transcoder)
Returns the values of this attribute decoded by the supplied transcoder.
|
int |
hashCode() |
boolean |
isBinary()
Returns whether this ldap attribute contains a value of type byte[].
|
void |
removeBinaryValue(byte[]... value)
Removes the supplied value from the attribute values if it exists.
|
void |
removeBinaryValues(java.util.Collection<byte[]> values)
Removes the supplied values from the attribute values if they exists.
|
void |
removeStringValue(java.lang.String... value)
Removes the supplied value from the attribute values if it exists.
|
void |
removeStringValues(java.util.Collection<java.lang.String> values)
Removes the supplied values from the attribute values if they exists.
|
void |
setName(java.lang.String name)
Sets the name of this attribute.
|
int |
size()
Returns the number of values in this ldap attribute.
|
java.lang.String |
toString() |
equals, getSortBehaviorprivate static final int HASH_CODE_SEED
private static final long serialVersionUID
private java.lang.String attributeName
private final LdapAttribute.LdapAttributeValues<?> attributeValues
public LdapAttribute()
public LdapAttribute(SortBehavior sb)
sb - sort behavior of this attributepublic LdapAttribute(boolean binary)
binary - whether this attribute contains binary valuespublic LdapAttribute(SortBehavior sb, boolean binary)
sb - sort behavior of this attributebinary - whether this attribute contains binary valuespublic LdapAttribute(java.lang.String name)
name - of this attributepublic LdapAttribute(java.lang.String name,
java.lang.String... values)
name - of this attributevalues - of this attributepublic LdapAttribute(java.lang.String name,
byte[]... values)
name - of this attributevalues - of this attributepublic java.lang.String getName()
public java.lang.String getName(boolean withOptions)
withOptions - whether options should be included in the namepublic void setName(java.lang.String name)
name - to setpublic java.lang.String[] getOptions()
public java.util.Collection<java.lang.String> getStringValues()
public java.lang.String getStringValue()
getStringValues().public java.util.Collection<byte[]> getBinaryValues()
public byte[] getBinaryValue()
getBinaryValues().public boolean isBinary()
public <T> java.util.Collection<T> getValues(ValueTranscoder<T> transcoder)
T - type of decoded attributestranscoder - to decode attribute values withpublic <T> T getValue(ValueTranscoder<T> transcoder)
getValues(ValueTranscoder).T - type of decoded attributestranscoder - to decode attribute values withpublic void addStringValue(java.lang.String... value)
value - to addjava.lang.NullPointerException - if value is nullpublic void addStringValues(java.util.Collection<java.lang.String> values)
addStringValue(String...).values - to addpublic void addBinaryValue(byte[]... value)
value - to addjava.lang.NullPointerException - if value is nullpublic void addBinaryValues(java.util.Collection<byte[]> values)
addBinaryValue(byte[][]).values - to addpublic <T> void addValue(ValueTranscoder<T> transcoder, T... value)
T - type attribute to encodetranscoder - to encode value withvalue - to encode and addjava.lang.NullPointerException - if value is nullpublic <T> void addValues(ValueTranscoder<T> transcoder, java.util.Collection<T> values)
addValue(ValueTranscoder, Object...).T - type attribute to encodetranscoder - to encode value withvalues - to encode and addpublic void removeStringValue(java.lang.String... value)
value - to removepublic void removeStringValues(java.util.Collection<java.lang.String> values)
removeStringValue(String...).values - to removepublic void removeBinaryValue(byte[]... value)
value - to removepublic void removeBinaryValues(java.util.Collection<byte[]> values)
removeBinaryValue(byte[][]).values - to removepublic int size()
public void clear()
public int hashCode()
hashCode in class AbstractLdapBeanpublic java.lang.String toString()
toString in class java.lang.Objectprotected <E> java.util.Collection<E> createSortBehaviorCollection(java.lang.Class<E> c)
SortBehavior.UNORDERED, LinkedHashSet for SortBehavior.ORDERED, and TreeSet for SortBehavior.SORTED.E - contained in the collectionc - type contained in the collectionprivate static <E> java.util.Comparator<E> getComparator(java.lang.Class<E> c)
Object.toString() for unknown types.E - type of classc - type to comparepublic static LdapAttribute createLdapAttribute(SortBehavior sb, java.lang.String name, java.util.Collection<java.lang.Object> values)
sb - sort behaviorname - of this attributevalues - of this attributejava.lang.IllegalArgumentException - if values contains something other than String or byte[]public static java.lang.String escapeValue(java.lang.String value)
value - to escape