Interface Attribute
- All Superinterfaces:
Externalizable, Iterable<Value>, Serializable
- All Known Implementing Classes:
DefaultAttribute
- Author:
- Apache Directory Project
-
Method Summary
Modifier and TypeMethodDescriptionintadd(byte[]... vals) Adds some values to this attribute.intAdds some values to this attribute.intAdds some values to this attribute.voidapply(AttributeType attributeType) Set the attribute type associated with this EntryAttribute.voidclear()Remove all the values from this attribute.clone()booleancontains(byte[]... vals) Indicates whether the specified values are some of the attribute's values.booleanIndicates whether the specified values are some of the attribute's values.booleanIndicates whether the specified values are some of the attribute's values.get()Get the first value of this attribute.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 throwngetId()Get's the attribute identifier for this entry.Get the String value, if and only if the value is known to be a String, otherwise a InvalidAttributeValueException will be throwngetUpId()Get's the user provided identifier for this entry.booleanTells if the attribute is human readable.booleanisInstanceOf(AttributeType attributeType) Check if the current attribute type has the same type (or is a descendant of) than the given attributeTypebooleanisValid(AttributeType attributeType) Checks to see if this attribute is valid along with the values it contains.booleanremove(byte[]... val) Removes all the values that are equal to the given values.booleanRemoves all the values that are equal to the given values.booleanRemoves all the values that are equal to the given values.voidSet the user provided ID.voidsetUpId(String upId, AttributeType attributeType) Set the user provided ID.intsize()Retrieves the number of values in this attribute.A pretty-pinter for AttributeMethods inherited from interface Externalizable
readExternal, writeExternalMethods inherited from interface Iterable
forEach, iterator, spliterator
-
Method Details
-
add
Adds some values to this attribute. If the new values are already present in the attribute values, the method has no effect.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.
- Parameters:
vals- some new values to be added which may be null- Returns:
- the number of added values, or 0 if none has been added
- Throws:
LdapInvalidAttributeValueException- if some of the added values are not valid
-
add
Adds some values to this attribute. If the new values are already present in the attribute values, the method has no effect.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.- Parameters:
vals- some new values to be added which may be null- Returns:
- the number of added values, or 0 if none has been added
- Throws:
LdapInvalidAttributeValueException- if some of the added values are not valid
-
add
Adds some values to this attribute. If the new values are already present in the attribute values, the method has no effect.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.
- Parameters:
val- some new values to be added which may be null- Returns:
- the number of added values, or 0 if none has been added
- Throws:
LdapInvalidAttributeValueException- if some of the added values are not valid
-
clear
void clear()Remove all the values from this attribute. -
clone
Attribute clone()- Returns:
- A clone of the current object
-
contains
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[]
- Parameters:
vals- the values- Returns:
- true if this attribute contains all the given values, otherwise false
-
contains
boolean 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
- Parameters:
vals- the values- Returns:
- true if this attribute contains all the given values, otherwise false
-
contains
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.
- Parameters:
vals- the values- Returns:
- true if this attribute contains all the given values, otherwise false
-
getAttributeType
AttributeType getAttributeType()Get the attribute type associated with this EntryAttribute.- Returns:
- the attributeType associated with this entry attribute
-
apply
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
- Parameters:
attributeType- the attributeType associated with this entry attribute- Throws:
LdapInvalidAttributeValueException- if the contained values are not valid accordingly to the added AttributeType
-
isInstanceOf
Check if the current attribute type has the same type (or is a descendant of) than the given attributeType
- Parameters:
attributeType- The AttributeType to check- Returns:
- true if the current attribute is of the expected attributeType or a descendant of it
- Throws:
LdapInvalidAttributeValueException- If there is no AttributeType
-
get
Value 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.
- Returns:
- The first value for this attribute.
-
getBytes
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.
- Returns:
- The value as a byte[]
- Throws:
LdapInvalidAttributeValueException- If the value is a String
-
getId
String getId()Get's the attribute identifier for this entry. This is the value that will be used as the identifier for the attribute within the entry.- Returns:
- the identifier for this attribute
-
getUpId
String getUpId()Get's the user provided identifier for this entry. This is the value that will be used as the identifier for the attribute within the entry. If this is a commonName attribute for example and the user provides "COMMONname" instead when adding the entry then this is the format the user will have that entry returned by the directory server. To do so we store this value as it was given and track it in the attribute using this property.- Returns:
- the user provided identifier for this attribute
-
isHumanReadable
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.
- Returns:
- true if the attribute is human readable
-
getString
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.
- Returns:
- The value as a String
- Throws:
LdapInvalidAttributeValueException- If the value is a byte[]
-
remove
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[]
- Parameters:
vals- the values to be removed- Returns:
- true if all the values are removed, otherwise false
-
remove
boolean 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
- Parameters:
val- the values to be removed- Returns:
- true if all the values are removed, otherwise false
-
remove
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).
- Parameters:
vals- the values to be removed- Returns:
- true if all the values are removed, otherwise false
-
setUpId
Set the user provided ID. It will also set the ID, normalizing the upId (removing spaces before and after, and lower casing it)- Parameters:
upId- The attribute ID- Throws:
IllegalArgumentException- If the ID is empty or null or resolve to an empty value after being trimmed
-
setUpId
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.
- Parameters:
upId- The attribute IDattributeType- The associated attributeType
-
size
int size()Retrieves the number of values in this attribute.- Returns:
- the number of values in this attribute, including any values wrapping a null value if there is one
-
isValid
Checks to see if this attribute is valid along with the values it contains.- Parameters:
attributeType- The AttributeType- Returns:
- true if the attribute and it's values are valid, false otherwise
- Throws:
LdapInvalidAttributeValueException- if there is a failure to check syntaxes of values
-
toString
-