|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.directory.api.ldap.model.entry.DefaultAttribute
public class DefaultAttribute
An LDAP attribute.
To define the kind of data stored, the client must set the isHR flag, or inject an AttributeType.
| Constructor Summary | |
|---|---|
DefaultAttribute(AttributeType attributeType)
Create a new instance of a schema aware Attribute, without ID nor value. |
|
DefaultAttribute(AttributeType attributeType,
Attribute attribute)
Creates a new instance of schema aware Attribute, by copying another attribute. |
|
DefaultAttribute(AttributeType attributeType,
byte[]... vals)
Create a new instance of a schema aware Attribute, with some byte[] values. |
|
DefaultAttribute(AttributeType attributeType,
String... vals)
Create a new instance of a schema aware Attribute, without ID but with some values. |
|
DefaultAttribute(AttributeType attributeType,
Value<?>... vals)
Create a new instance of a schema aware Attribute, with some values. |
|
DefaultAttribute(String upId)
Create a new instance of an Attribute, without value. |
|
DefaultAttribute(String upId,
AttributeType attributeType)
Create a new instance of a schema aware Attribute, without value. |
|
DefaultAttribute(String upId,
AttributeType attributeType,
byte[]... vals)
Create a new instance of a schema aware Attribute, with some byte[] values, and a user provided ID. |
|
DefaultAttribute(String upId,
AttributeType attributeType,
String... vals)
Create a new instance of a schema aware Attribute, with some values, and a user provided ID. |
|
DefaultAttribute(String upId,
AttributeType attributeType,
Value<?>... vals)
Create a new instance of a schema aware Attribute, with some values, and a user provided ID. If the value does not correspond to the same attributeType, then it's wrapped value is copied into a new Value which uses the specified attributeType. |
|
DefaultAttribute(String upId,
byte[]... vals)
Create a new instance of an Attribute, with some binary values, and a user provided ID. |
|
DefaultAttribute(String upId,
String... vals)
Create a new instance of an Attribute, with some String values, and a user provided ID. |
|
DefaultAttribute(String upId,
Value<?>... vals)
Create a new instance of an Attribute, with some values, and a user provided ID. If the value does not correspond to the same attributeType, then it's wrapped value is copied into a new ClientValue which uses the specified attributeType. |
|
| Method Summary | |
|---|---|
int |
add(byte[]... vals)
Adds some values to this attribute. |
int |
add(String... vals)
Adds some values to this attribute. |
int |
add(Value<?>... vals)
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. |
boolean |
equals(Object obj)
|
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. |
int |
hashCode()
The hashCode is based on the id, the isHR flag and on the internal values. |
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. |
Iterator<Value<?>> |
iterator()
An iterator on top of the stored values. |
void |
readExternal(ObjectInput in)
|
boolean |
remove(byte[]... vals)
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 |
toString(String tabs)
A pretty-pinter for Attribute |
void |
writeExternal(ObjectOutput out)
This is the place where we serialize attributes, and all theirs elements. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultAttribute(AttributeType attributeType)
attributeType - the attributeType for the empty attribute added into the entrypublic DefaultAttribute(String upId)
upId - The user provided ID
public DefaultAttribute(String upId,
AttributeType attributeType)
upId - the ID for the added attributeTypeattributeType - the added AttributeType
public DefaultAttribute(String upId,
Value<?>... vals)
Otherwise, the value is stored, but as a reference. It's not a copy.
upId - the attributeType IDvals - an initial set of values for this attribute
public DefaultAttribute(AttributeType attributeType,
String... vals)
throws LdapInvalidAttributeValueException
attributeType - The attributeType added on creationvals - The added value for this attribute
LdapInvalidAttributeValueException - If any of the
added values is not valid
public DefaultAttribute(String upId,
AttributeType attributeType,
String... vals)
throws LdapInvalidAttributeValueException
upId - the ID for the created attributeattributeType - The attributeType added on creationvals - the added values for this attribute
LdapInvalidAttributeValueException - If any of the
added values is not valid
public DefaultAttribute(String upId,
AttributeType attributeType,
Value<?>... vals)
throws LdapInvalidAttributeValueException
Otherwise, the value is stored, but as a reference. It's not a copy.
upId - the ID of the created attributeattributeType - the attribute type according to the schemavals - an initial set of values for this attribute
LdapInvalidAttributeValueException - If any of the
added values is not valid
public DefaultAttribute(AttributeType attributeType,
Value<?>... vals)
throws LdapInvalidAttributeValueException
If the value does not correspond to the same attributeType, then it's wrapped value is copied into a new Value which uses the specified attributeType.
attributeType - the attribute type according to the schemavals - an initial set of values for this attribute
LdapInvalidAttributeValueException
public DefaultAttribute(String upId,
String... vals)
upId - the ID of the created attributevals - an initial set of String values for this attribute
public DefaultAttribute(String upId,
byte[]... vals)
upId - the ID of the created attributevals - an initial set of binary values for this attribute
public DefaultAttribute(AttributeType attributeType,
byte[]... vals)
throws LdapInvalidAttributeValueException
attributeType - The attributeType added on creationvals - The added binary values
LdapInvalidAttributeValueException - If any of the
added values is not valid
public DefaultAttribute(String upId,
AttributeType attributeType,
byte[]... vals)
throws LdapInvalidAttributeValueException
upId - the ID for the added attributeattributeType - the AttributeType to be addedvals - the binary values for the added attribute
LdapInvalidAttributeValueException - If any of the
added values is not valid
public DefaultAttribute(AttributeType attributeType,
Attribute attribute)
throws LdapException
attributeType - The attribute's typeattribute - The attribute to be copied
LdapException| Method Detail |
|---|
public 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.
getBytes in interface AttributeLdapInvalidAttributeValueException - If the value is a String
public 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.
getString in interface AttributeLdapInvalidAttributeValueException - If the value is a byte[]public String getId()
getId in interface Attributepublic String getUpId()
getUpId in interface Attributepublic void setUpId(String upId)
setUpId in interface AttributeupId - The attribute ID
public void 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.
setUpId in interface AttributeupId - The attribute IDattributeType - The associated attributeTypepublic 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.
isHumanReadable in interface Attribute
public boolean isValid(AttributeType attributeType)
throws LdapInvalidAttributeValueException
isValid in interface AttributeattributeType - The AttributeType
LdapInvalidAttributeValueException - if there is a failure to check syntaxes of valuespublic int add(Value<?>... vals)
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 StringValue into a Binary attribute, we just store the UTF-8 byte array encoding for this StringValue.
If we try to store some BinaryValue in a HR attribute, we try to convert those BinaryValue 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.
add in interface Attributevals - some new values to be added which may be null
public 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.
add in interface Attributevals - some new values to be added which may be null
LdapInvalidAttributeValueException - if some of the added values are not valid
public int 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.
add in interface Attributevals - some new values to be added which may be null
LdapInvalidAttributeValueException - if some of the added values are not validpublic void clear()
clear in interface Attributepublic boolean 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.
contains in interface Attributevals - the values
public 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[]
contains in interface Attributevals - the values
public 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
contains in interface Attributevals - the values
public 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.
get in interface Attributepublic int size()
size in interface Attributepublic boolean 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).
remove in interface Attributevals - the values to be removed
public boolean remove(byte[]... 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, then the values will be first converted to String
remove in interface Attributevals - the values to be removed
public 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[]
remove in interface Attributevals - the values to be removed
public Iterator<Value<?>> iterator()
iterator in interface Iterable<Value<?>>public AttributeType getAttributeType()
getAttributeType in interface Attribute
public 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
apply in interface AttributeattributeType - the attributeType associated with this entry attribute
LdapInvalidAttributeValueException - if the contained values are not valid accordingly
to the added AttributeType
public boolean isInstanceOf(AttributeType attributeType)
throws LdapInvalidAttributeValueException
Check if the current attribute type has the same type (or is a descendant of) than the given attributeType
isInstanceOf in interface AttributeattributeType - The AttributeType to check
LdapInvalidAttributeValueException - If there is no AttributeTypepublic int hashCode()
hashCode in class ObjectObject.hashCode()public boolean equals(Object obj)
equals in class ObjectObject.equals(Object)public Attribute clone()
clone in interface Attributeclone in class Object
public void writeExternal(ObjectOutput out)
throws IOException
writeExternal in interface ExternalizableIOException
public void readExternal(ObjectInput in)
throws IOException,
ClassNotFoundException
readExternal in interface ExternalizableIOException
ClassNotFoundExceptionpublic String toString()
toString in class ObjectObject.toString()public String toString(String tabs)
toString in interface Attributetabs - The tabs to add before any output
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||