|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.directory.shared.ldap.entry.client.DefaultClientAttribute
public class DefaultClientAttribute
A client side entry attribute. The client is not aware of the schema, so we can't tell if the stored value will be String or Binary. We will default to Binary.
To define the kind of data stored, the client must set the isHR flag.
| Field Summary | |
|---|---|
protected AttributeType |
attributeType
The associated AttributeType |
protected java.lang.String |
id
The normalized ID (will be the OID if we have a AttributeType) |
protected java.lang.Boolean |
isHR
Tells if the attribute is Human Readable or not. |
protected java.lang.String |
upId
The User provided ID |
protected java.util.Set<Value<?>> |
values
The set of contained values |
| Constructor Summary | |
|---|---|
DefaultClientAttribute()
Create a new instance of a EntryAttribute, without ID nor value. |
|
DefaultClientAttribute(java.lang.String upId)
Create a new instance of a EntryAttribute, without value. |
|
DefaultClientAttribute(java.lang.String upId,
byte[]... vals)
Create a new instance of a EntryAttribute, with some byte[] values. |
|
DefaultClientAttribute(java.lang.String upId,
java.lang.String... vals)
Create a new instance of a EntryAttribute. |
|
DefaultClientAttribute(java.lang.String upId,
Value<?>... vals)
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(java.lang.String... vals)
Adds some values to this attribute. |
int |
add(Value<?>... vals)
Adds some values to this attribute. |
void |
clear()
Remove all the values from this attribute. |
EntryAttribute |
clone()
|
boolean |
contains(byte[]... vals)
Indicates whether the specified values are some of the attribute's values. |
boolean |
contains(java.lang.Object... vals)
|
boolean |
contains(java.lang.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(java.lang.Object obj)
|
Value<?> |
get()
Get the first value of this attribute. |
Value<?> |
get(int i)
Get the nth value of this attribute. |
java.util.Iterator<Value<?>> |
getAll()
Returns an iterator over all the attribute's values. |
AttributeType |
getAttributeType()
Get the attribute type associated with this ServerAttribute. |
byte[] |
getBytes()
Get the byte[] value, if and only if the value is known to be Binary, otherwise a InvalidAttributeValueException will be thrown |
java.lang.String |
getId()
Get's the attribute identifier. |
java.lang.String |
getString()
Get the String value, if and only if the value is known to be a String, otherwise a InvalidAttributeValueException will be thrown |
java.lang.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 |
instanceOf(java.lang.String attributeId)
Check if the current attribute type is of the expected attributeType |
boolean |
isHR()
Tells if the attribute is Human Readable. |
boolean |
isValid()
Checks to see if this attribute is valid along with the values it contains. |
boolean |
isValid(SyntaxChecker checker)
Checks to see if this attribute is valid along with the values it contains. |
java.util.Iterator<Value<?>> |
iterator()
An iterator on top of the stored values. |
int |
put(byte[]... vals)
Puts some values to this attribute. |
int |
put(java.util.List<Value<?>> vals)
Puts a list of values into this attribute. |
int |
put(java.lang.String... vals)
Puts some values to this attribute. |
int |
put(Value<?>... vals)
Puts some values to this attribute. |
void |
readExternal(java.io.ObjectInput in)
|
boolean |
remove(byte[]... vals)
Removes all the values that are equal to the given values. |
boolean |
remove(java.lang.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 |
setAttributeType(AttributeType attributeType)
Set the attribute type associated with this ServerAttribute. |
void |
setHR(boolean isHR)
Set the attribute to Human Readable or to Binary. |
void |
setId(java.lang.String id)
Set the normalized ID. |
void |
setUpId(java.lang.String upId)
Set the user provided ID. |
void |
setUpId(java.lang.String upId,
AttributeType attributeType)
Set the user provided ID. |
int |
size()
Retrieves the number of values in this attribute. |
EntryAttribute |
toClientAttribute()
Convert the ServerAttribute to a ClientAttribute |
java.lang.String |
toString()
|
void |
writeExternal(java.io.ObjectOutput out)
|
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected AttributeType attributeType
protected java.util.Set<Value<?>> values
protected java.lang.String upId
protected java.lang.String id
protected java.lang.Boolean isHR
| Constructor Detail |
|---|
public DefaultClientAttribute()
public DefaultClientAttribute(java.lang.String upId)
public DefaultClientAttribute(java.lang.String upId,
Value<?>... vals)
upId - attributeType - the attribute type according to the schemavals - an initial set of values for this attribute
public DefaultClientAttribute(java.lang.String upId,
java.lang.String... vals)
public DefaultClientAttribute(java.lang.String upId,
byte[]... vals)
| 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 EntryAttributeLdapInvalidAttributeValueException - If the value is a String
public java.lang.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 EntryAttributeLdapInvalidAttributeValueException - If the value is a byte[]public java.lang.String getId()
getId in interface EntryAttributepublic void setHR(boolean isHR)
Set the attribute to Human Readable or to Binary.
setHR in interface EntryAttributeisHR - true for a Human Readable attribute,
false for a Binary attribute.public void setId(java.lang.String id)
setId in interface EntryAttributeid - The attribute ID
java.lang.IllegalArgumentException - If the ID is empty or null or
resolve to an empty value after being trimmedpublic java.lang.String getUpId()
getUpId in interface EntryAttributepublic void setUpId(java.lang.String upId)
setUpId in interface EntryAttributeupId - The attribute ID
java.lang.IllegalArgumentException - If the ID is empty or null or
resolve to an empty value after being trimmed
public void setUpId(java.lang.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 compatoble with the new AttributeType.
setUpId in interface EntryAttributeupId - The attribute IDattributeType - The associated attributeTypepublic boolean isHR()
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.
isHR in interface EntryAttribute
public boolean isValid()
throws LdapException
isValid in interface EntryAttributeLdapException - if there is a failure to check syntaxes of values
public boolean isValid(SyntaxChecker checker)
throws LdapException
isValid in interface EntryAttributechecker - The syntax checker
LdapException - 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 EntryAttributeval - some new values to be added which may be null
public int add(java.lang.String... vals)
EntryAttributeThe 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 EntryAttributevals - some new values to be added which may be null
EntryAttribute.add(String...)public int add(byte[]... 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 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 EntryAttributeval - some new values to be added which may be null
public void clear()
clear in interface EntryAttributepublic 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 EntryAttributevals - the values
public boolean contains(java.lang.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 EntryAttributevals - 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 EntryAttributevals - the values
public boolean contains(java.lang.Object... vals)
EntryAttribute#contains(Object...)public Value<?> get()
Get the first value of this attribute. If there is none, null is returned.
Note : even if we are storing values into a Set, one can assume the values are ordered following the insertion order.
This method is meant to be used if the attribute hold only one value.
get in interface EntryAttributepublic Value<?> get(int i)
Get the nth value of this attribute. If there is none, null is returned.
Note : even if we are storing values into a Set, one can assume the values are ordered following the insertion order.
get in interface EntryAttributei - the index of the value to get
public java.util.Iterator<Value<?>> getAll()
The effect on the returned enumeration of adding or removing values of the attribute is not specified.
This method will throw any LdapException that occurs.
getAll in interface EntryAttributepublic int size()
size in interface EntryAttributepublic 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 EntryAttributevals - 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 EntryAttributevals - the values to be removed
public boolean remove(java.lang.String... vals)
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 EntryAttributevals - the values to be removed
public java.util.Iterator<Value<?>> iterator()
iterator in interface java.lang.Iterable<Value<?>>public int put(java.lang.String... vals)
The new values will replace the previous values.
This method returns the number of values that were put.
put in interface EntryAttributeval - some values to be put which may be null
public int put(byte[]... vals)
The new values will replace the previous values.
This method returns the number of values that were put.
put in interface EntryAttributeval - some values to be put which may be null
public int put(Value<?>... vals)
The new values are replace the previous values.
This method returns the number of values that were put.
put in interface EntryAttributeval - some values to be put which may be null
public int put(java.util.List<Value<?>> vals)
Puts a list of values into this attribute.
The new values will replace the previous values.
This method returns the number of values that were put.
put in interface EntryAttributevals - the values to be put
public AttributeType getAttributeType()
getAttributeType in interface EntryAttributepublic void setAttributeType(AttributeType attributeType)
Set the attribute type associated with this ServerAttribute.
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
setAttributeType in interface EntryAttributeattributeType - the attributeType associated with this entry attribute
public boolean instanceOf(java.lang.String attributeId)
throws LdapInvalidAttributeValueException
Check if the current attribute type is of the expected attributeType
This method won't tell if the current attribute is a descendant of the attributeType. For instance, the "CN" serverAttribute will return false if we ask if it's an instance of "Name".
instanceOf in interface EntryAttributeattributeId - The AttributeType ID to check
LdapInvalidAttributeValueException - If there is no AttributeTypepublic EntryAttribute toClientAttribute()
toClientAttribute in interface EntryAttributepublic int hashCode()
hashCode in class java.lang.ObjectObject.hashCode()public boolean equals(java.lang.Object obj)
equals in class java.lang.ObjectObject.equals(Object)public EntryAttribute clone()
clone in interface EntryAttributeclone in class java.lang.ObjectCloneable#clone()public java.lang.String toString()
toString in class java.lang.ObjectObject.toString()
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
writeExternal in interface java.io.Externalizablejava.io.IOException
This is the place where we serialize attributes, and all theirs
elements.
The inner structure is :
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.Externalizablejava.io.IOException
java.lang.ClassNotFoundExceptionExternalizable#readExternal(ObjectInput)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||