public interface Attribute extends Iterable<Value>, Externalizable
Modifier and Type | Method and Description |
---|---|
int |
add(byte[]... vals)
Adds some values to this attribute.
|
int |
add(String... vals)
Adds some values to this attribute.
|
int |
add(Value... val)
Adds some values to this attribute.
|
void |
apply(AttributeType attributeType)
Set the attribute type associated with this EntryAttribute.
|
void |
clear()
Remove all the values from this attribute.
|
Attribute |
clone() |
boolean |
contains(byte[]... vals)
Indicates whether the specified values are some of the attribute's values.
|
boolean |
contains(String... vals)
Indicates whether the specified values are some of the attribute's values.
|
boolean |
contains(Value... vals)
Indicates whether the specified values are some of the attribute's values.
|
Value |
get()
Get the first value of this attribute.
|
AttributeType |
getAttributeType()
Get the attribute type associated with this EntryAttribute.
|
byte[] |
getBytes()
Get the byte[] value, if and only if the value is known to be Binary,
otherwise a InvalidAttributeValueException will be thrown
|
String |
getId()
Get's the attribute identifier for this entry.
|
String |
getString()
Get the String value, if and only if the value is known to be a String,
otherwise a InvalidAttributeValueException will be thrown
|
String |
getUpId()
Get's the user provided identifier for this entry.
|
boolean |
isHumanReadable()
Tells if the attribute is human readable.
|
boolean |
isInstanceOf(AttributeType attributeType)
Check if the current attribute type has the same type (or is a descendant of)
than the given attributeType
|
boolean |
isValid(AttributeType attributeType)
Checks to see if this attribute is valid along with the values it contains.
|
boolean |
remove(byte[]... val)
Removes all the values that are equal to the given values.
|
boolean |
remove(String... vals)
Removes all the values that are equal to the given values.
|
boolean |
remove(Value... vals)
Removes all the values that are equal to the given values.
|
void |
setUpId(String upId)
Set the user provided ID.
|
void |
setUpId(String upId,
AttributeType attributeType)
Set the user provided ID.
|
int |
size()
Retrieves the number of values in this attribute.
|
String |
toString(String tabs)
A pretty-pinter for Attribute
|
forEach, iterator, spliterator
readExternal, writeExternal
int add(String... vals) throws LdapInvalidAttributeValueException
The new values are added at the end of list of values.
This method returns the number of values that were added.
If the value's type is different from the attribute's type, a conversion is done. For instance, if we try to set some String into a Binary attribute, we just store the UTF-8 byte array encoding for this String.
If we try to store some byte[] in a HR attribute, we try to convert those byte[] assuming they represent an UTF-8 encoded String. Of course, if it's not the case, the stored value will be incorrect.
It's the responsibility of the caller to check if the stored values are consistent with the attribute's type.
The caller can set the HR flag in order to enforce a type for the current attribute, otherwise this type will be set while adding the first value, using the value's type to set the flag.
vals
- some new values to be added which may be nullLdapInvalidAttributeValueException
- if some of the added values are not validint add(byte[]... vals) throws LdapInvalidAttributeValueException
The new values are added at the end of list of values.
This method returns the number of values that were added.
If the value's type is different from the attribute's type, a conversion is done. For instance, if we try to set some String into a Binary attribute, we just store the UTF-8 byte array encoding for this String. If we try to store some byte[] in a HR attribute, we try to convert those byte[] assuming they represent an UTF-8 encoded String. Of course, if it's not the case, the stored value will be incorrect.vals
- some new values to be added which may be nullLdapInvalidAttributeValueException
- if some of the added values are not validint add(Value... val) throws LdapInvalidAttributeValueException
The new values are added at the end of list of values.
This method returns the number of values that were added.
If the value's type is different from the attribute's type, a conversion is done. For instance, if we try to set some String Value into a Binary attribute, we just store the UTF-8 byte array encoding for this Value.
If we try to store some Value in a HR attribute, we try to convert those Value assuming they represent an UTF-8 encoded String. Of course, if it's not the case, the stored value will be incorrect.
It's the responsibility of the caller to check if the stored values are consistent with the attribute's type.
The caller can set the HR flag in order to enforce a type for the current attribute, otherwise this type will be set while adding the first value, using the value's type to set the flag.
Note : If the entry contains no value, and the unique added value is a null length value, then this value will be considered as a binary value.
val
- some new values to be added which may be nullLdapInvalidAttributeValueException
- if some of the added values are not validvoid clear()
boolean contains(String... vals)
Indicates whether the specified values are some of the attribute's values.
If the Attribute is not HR, the values will be converted to byte[]
vals
- the valuesboolean contains(byte[]... vals)
Indicates whether the specified values are some of the attribute's values.
If the Attribute is HR, the values will be converted to String
vals
- the valuesboolean contains(Value... vals)
Indicates whether the specified values are some of the attribute's values.
If the Attribute is HR, the binary values will be converted to String before being checked.
vals
- the valuesAttributeType getAttributeType()
void apply(AttributeType attributeType) throws LdapInvalidAttributeValueException
Set the attribute type associated with this EntryAttribute.
The current attributeType will be replaced. It is the responsibility of the caller to insure that the existing values are compatible with the new AttributeType
attributeType
- the attributeType associated with this entry attributeLdapInvalidAttributeValueException
- if the contained values are not valid accordingly
to the added AttributeTypeboolean isInstanceOf(AttributeType attributeType) throws LdapInvalidAttributeValueException
Check if the current attribute type has the same type (or is a descendant of) than the given attributeType
attributeType
- The AttributeType to checkLdapInvalidAttributeValueException
- If there is no AttributeTypeValue get()
Get the first value of this attribute. If there is none, null is returned.
This method is meant to be used if the attribute hold only one value.
byte[] getBytes() throws LdapInvalidAttributeValueException
Get the byte[] value, if and only if the value is known to be Binary, otherwise a InvalidAttributeValueException will be thrown
Note that this method returns the first value only.
LdapInvalidAttributeValueException
- If the value is a StringString getId()
String getUpId()
boolean isHumanReadable()
Tells if the attribute is human readable.
This flag is set by the caller, or implicitly when adding String values into an attribute which is not yet declared as Binary.
String getString() throws LdapInvalidAttributeValueException
Get the String value, if and only if the value is known to be a String, otherwise a InvalidAttributeValueException will be thrown
Note that this method returns the first value only.
LdapInvalidAttributeValueException
- If the value is a byte[]boolean remove(String... vals)
Removes all the values that are equal to the given values.
Returns true if all the values are removed.
If the attribute type is not HR, then the values will be first converted to byte[]
vals
- the values to be removedboolean remove(byte[]... val)
Removes all the values that are equal to the given values.
Returns true if all the values are removed.
If the attribute type is HR, then the values will be first converted to String
val
- the values to be removedboolean remove(Value... vals)
Removes all the values that are equal to the given values.
Returns true if all the values are removed.
If the attribute type is HR and some value which are not String, we will convert the values first (same thing for a non-HR attribute).
vals
- the values to be removedvoid setUpId(String upId)
upId
- The attribute IDIllegalArgumentException
- If the ID is empty or null or
resolve to an empty value after being trimmedvoid setUpId(String upId, AttributeType attributeType)
Set the user provided ID. If we have none, the upId is assigned the attributetype's name. If it does not have any name, we will use the OID.
If we have an upId and an AttributeType, they must be compatible. : - if the upId is an OID, it must be the AttributeType's OID - otherwise, its normalized form must be equals to ones of the attributeType's names.
In any case, the ATtributeType will be changed. The caller is responsible for the present values to be compatible with the new AttributeType.
upId
- The attribute IDattributeType
- The associated attributeTypeint size()
boolean isValid(AttributeType attributeType) throws LdapInvalidAttributeValueException
attributeType
- The AttributeTypeLdapInvalidAttributeValueException
- if there is a failure to check syntaxes of valuesCopyright © 2003–2020 The Apache Software Foundation. All rights reserved.