Package org.ldaptive
Class LdapAttribute
- java.lang.Object
-
- org.ldaptive.LdapAttribute
-
- Direct Known Subclasses:
UnicodePwdAttribute
public class LdapAttribute extends java.lang.ObjectLDAP attribute defined as:Attribute ::= PartialAttribute(WITH COMPONENTS { ..., vals (SIZE(1..MAX))})- Author:
- Middleware Services
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLdapAttribute.Builder
-
Constructor Summary
Constructors Constructor Description LdapAttribute()Default constructor.LdapAttribute(java.lang.String type)Creates a new attribute.LdapAttribute(java.lang.String type, byte[]... value)Creates a new attribute.LdapAttribute(java.lang.String type, java.lang.String... value)Creates a new attribute.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddBinaryValues(byte[]... value)Adds the supplied byte array as a value for this attribute.voidaddBinaryValues(java.util.Collection<byte[]> values)Adds all the byte arrays in the supplied collection as values for this attribute.voidaddBufferValues(java.nio.ByteBuffer... values)Adds all the buffers in the supplied collection as values for this attribute.voidaddBufferValues(java.util.Collection<java.nio.ByteBuffer> values)Adds all the buffers in the supplied collection as values for this attribute.voidaddStringValues(java.lang.String... value)Adds the supplied string as a value for this attribute.voidaddStringValues(java.util.Collection<java.lang.String> values)Adds all the strings in the supplied collection as values for this attribute.<T> voidaddValues(java.util.function.Function<T,byte[]> func, java.util.Collection<T> values)Adds all the values in the supplied collection for this attribute by encoding them with the supplied function.<T> voidaddValues(java.util.function.Function<T,byte[]> func, T... value)Adds the supplied values for this attribute by encoding them with the supplied function.static LdapAttribute.Builderbuilder()Creates a builder for this class.voidclear()Removes all the values in this ldap attribute.voidconfigureBinary(java.lang.String... attrNames)Checks whether attrNames matches the name of this attribute.booleanequals(java.lang.Object o)static java.lang.StringescapeValue(java.lang.String value)Deprecated.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.java.lang.StringgetName()Returns the attribute description with options.java.lang.StringgetName(boolean withOptions)Returns the attribute description with or without options.java.util.List<java.lang.String>getOptions()Returns any options that may exist on the attribute description.java.lang.StringgetStringValue()Returns a single string value of this attribute.java.util.Collection<java.lang.String>getStringValues()Returns the values of this attribute as strings.<T> TgetValue(java.util.function.Function<byte[],T> func)Returns a single decoded value of this attribute.<T> java.util.Collection<T>getValues(java.util.function.Function<byte[],T> func)Returns the values of this attribute decoded by the supplied function.inthashCode()booleanisBinary()Returns whether this ldap attribute is binary.voidremoveBinaryValues(byte[]... value)Removes the supplied byte array as a value from this attribute.voidremoveBinaryValues(java.util.Collection<byte[]> values)Removes all the byte arrays in the supplied collection as values from this attribute.voidremoveBufferValues(java.nio.ByteBuffer... values)Removes all the buffers in the supplied collection as values from this attribute.voidremoveBufferValues(java.util.Collection<java.nio.ByteBuffer> values)Removes all the buffers in the supplied collection as values from this attribute.voidremoveStringValues(java.lang.String... value)Removes the supplied string as a value from this attribute.voidremoveStringValues(java.util.Collection<java.lang.String> values)Removes all the strings in the supplied collection as values from this attribute.voidsetBinary(boolean b)Sets whether this ldap attribute is binary.voidsetName(java.lang.String type)Sets the name.intsize()Returns the number of values in this ldap attribute.static LdapAttributesort(LdapAttribute la)Returns a new attribute whose values are sorted.java.lang.StringtoString()
-
-
-
Constructor Detail
-
LdapAttribute
public LdapAttribute()
Default constructor.
-
LdapAttribute
public LdapAttribute(java.lang.String type)
Creates a new attribute.- Parameters:
type- attribute description
-
LdapAttribute
public LdapAttribute(java.lang.String type, byte[]... value)Creates a new attribute.- Parameters:
type- attribute descriptionvalue- attribute values
-
LdapAttribute
public LdapAttribute(java.lang.String type, java.lang.String... value)Creates a new attribute.- Parameters:
type- attribute descriptionvalue- attribute values
-
-
Method Detail
-
setName
public void setName(java.lang.String type)
Sets the name. This method has the side effect of setting this attribute as binary if the name has an option of 'binary' or the name matches one ofBINARY_ATTRIBUTES.- Parameters:
type- attribute name
-
isBinary
public boolean isBinary()
Returns whether this ldap attribute is binary.- Returns:
- whether this ldap attribute is binary
-
setBinary
public void setBinary(boolean b)
Sets whether this ldap attribute is binary.- Parameters:
b- whether this ldap attribute is binary
-
configureBinary
public void configureBinary(java.lang.String... attrNames)
Checks whether attrNames matches the name of this attribute. If a match is found this attribute is set as binary.- Parameters:
attrNames- custom binary attribute names
-
getName
public java.lang.String getName()
Returns the attribute description with options.- Returns:
- attribute description
-
getName
public java.lang.String getName(boolean withOptions)
Returns the attribute description with or without options.- Parameters:
withOptions- whether the attribute description should include options- Returns:
- attribute description
-
getOptions
public java.util.List<java.lang.String> getOptions()
Returns any options that may exist on the attribute description.- Returns:
- attribute description options
-
getBinaryValue
public byte[] getBinaryValue()
Returns a single byte array value of this attribute.- Returns:
- single byte array attribute value or null if this attribute is empty
-
getBinaryValues
public java.util.Collection<byte[]> getBinaryValues()
Returns the values of this attribute as byte arrays. The return collection cannot be modified.- Returns:
- collection of string attribute values
-
getStringValue
public java.lang.String getStringValue()
Returns a single string value of this attribute.- Returns:
- single string attribute value or null if this attribute is empty
-
getStringValues
public java.util.Collection<java.lang.String> getStringValues()
Returns the values of this attribute as strings. Binary data is base64 encoded. The return collection cannot be modified.- Returns:
- collection of string attribute values
-
getValue
public <T> T getValue(java.util.function.Function<byte[],T> func)
Returns a single decoded value of this attribute.- Type Parameters:
T- type of decoded attribute- Parameters:
func- to decode attribute value with- Returns:
- single decoded attribute value or null if this attribute is empty
-
getValues
public <T> java.util.Collection<T> getValues(java.util.function.Function<byte[],T> func)
Returns the values of this attribute decoded by the supplied function.- Type Parameters:
T- type of decoded attributes- Parameters:
func- to decode attribute values with- Returns:
- collection of decoded attribute values, null values are discarded
-
addBinaryValues
public void addBinaryValues(byte[]... value)
Adds the supplied byte array as a value for this attribute.- Parameters:
value- to add, null values are discarded
-
addBinaryValues
public void addBinaryValues(java.util.Collection<byte[]> values)
Adds all the byte arrays in the supplied collection as values for this attribute.- Parameters:
values- to add, null values are discarded
-
addStringValues
public void addStringValues(java.lang.String... value)
Adds the supplied string as a value for this attribute.- Parameters:
value- to add, null values are discarded
-
addStringValues
public void addStringValues(java.util.Collection<java.lang.String> values)
Adds all the strings in the supplied collection as values for this attribute.- Parameters:
values- to add, null values are discarded
-
addBufferValues
public void addBufferValues(java.nio.ByteBuffer... values)
Adds all the buffers in the supplied collection as values for this attribute.- Parameters:
values- to add, null values are discarded
-
addBufferValues
public void addBufferValues(java.util.Collection<java.nio.ByteBuffer> values)
Adds all the buffers in the supplied collection as values for this attribute.- Parameters:
values- to add, null values are discarded
-
addValues
public <T> void addValues(java.util.function.Function<T,byte[]> func, T... value)Adds the supplied values for this attribute by encoding them with the supplied function.- Type Parameters:
T- type attribute to encode- Parameters:
func- to encode value withvalue- to encode and add, null values are discarded
-
addValues
public <T> void addValues(java.util.function.Function<T,byte[]> func, java.util.Collection<T> values)Adds all the values in the supplied collection for this attribute by encoding them with the supplied function. SeeaddValues(Function, Object...).- Type Parameters:
T- type attribute to encode- Parameters:
func- to encode value withvalues- to encode and add, null values are discarded
-
removeBinaryValues
public void removeBinaryValues(byte[]... value)
Removes the supplied byte array as a value from this attribute.- Parameters:
value- to remove, null values are discarded
-
removeBinaryValues
public void removeBinaryValues(java.util.Collection<byte[]> values)
Removes all the byte arrays in the supplied collection as values from this attribute.- Parameters:
values- to remove, null values are discarded
-
removeStringValues
public void removeStringValues(java.lang.String... value)
Removes the supplied string as a value from this attribute.- Parameters:
value- to remove, null values are discarded
-
removeStringValues
public void removeStringValues(java.util.Collection<java.lang.String> values)
Removes all the strings in the supplied collection as values from this attribute.- Parameters:
values- to remove, null values are discarded
-
removeBufferValues
public void removeBufferValues(java.nio.ByteBuffer... values)
Removes all the buffers in the supplied collection as values from this attribute.- Parameters:
values- to remove, null values are discarded
-
removeBufferValues
public void removeBufferValues(java.util.Collection<java.nio.ByteBuffer> values)
Removes all the buffers in the supplied collection as values from this attribute.- Parameters:
values- to remove, null values are discarded
-
size
public int size()
Returns the number of values in this ldap attribute.- Returns:
- number of values in this ldap attribute
-
clear
public void clear()
Removes all the values in this ldap attribute.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
sort
public static LdapAttribute sort(LdapAttribute la)
Returns a new attribute whose values are sorted. String values are sorted naturally. Binary values are sorted usingByteBuffer.compareTo(ByteBuffer).- Parameters:
la- attribute to sort- Returns:
- sorted attribute
-
escapeValue
@Deprecated public static java.lang.String escapeValue(java.lang.String value)
Deprecated.Escapes the supplied string value per RFC 4514 section 2.4.- Parameters:
value- to escape- Returns:
- escaped value
-
builder
public static LdapAttribute.Builder builder()
Creates a builder for this class.- Returns:
- new builder
-
-