|
||||||||||
| 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
org.apache.directory.shared.ldap.entry.DefaultServerAttribute
public final class DefaultServerAttribute
A server side entry attribute aware of schema.
| Field Summary | |
|---|---|
static long |
serialVersionUID
|
| Fields inherited from class org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute |
|---|
attributeType, id, isHR, upId, values |
| Constructor Summary | |
|---|---|
DefaultServerAttribute(AttributeType attributeType)
Create a new instance of a EntryAttribute, without ID nor value. |
|
DefaultServerAttribute(AttributeType attributeType,
byte[]... vals)
Create a new instance of a EntryAttribute, with some byte[] values. |
|
DefaultServerAttribute(AttributeType attributeType,
EntryAttribute attribute)
Creates a new instance of DefaultServerAttribute, by copying another attribute, which can be a ClientAttribute. |
|
DefaultServerAttribute(AttributeType attributeType,
java.lang.String... vals)
Create a new instance of a EntryAttribute, without ID but with some values. |
|
DefaultServerAttribute(AttributeType attributeType,
Value<?>... vals)
Doc me more! 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. |
|
DefaultServerAttribute(java.lang.String upId,
AttributeType attributeType)
Create a new instance of a EntryAttribute, without value. |
|
DefaultServerAttribute(java.lang.String upId,
AttributeType attributeType,
byte[]... vals)
Create a new instance of a EntryAttribute, with some byte[] values. |
|
DefaultServerAttribute(java.lang.String upId,
AttributeType attributeType,
java.lang.String... vals)
Create a new instance of a EntryAttribute. |
|
DefaultServerAttribute(java.lang.String upId,
AttributeType attributeType,
Value<?>... vals)
Doc me more! 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. |
|
| 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 type, including a null value. |
EntryAttribute |
clone()
Clone an attribute. |
boolean |
contains(byte[]... vals)
Indicates whether all the specified values are attribute's values. |
boolean |
contains(java.lang.String... vals)
Indicates whether all the specified values are attribute's values. |
boolean |
contains(Value<?>... vals)
Indicates whether the specified values are some of the attribute's values. |
void |
deserialize(java.io.ObjectInput in)
|
boolean |
equals(java.lang.Object obj)
|
int |
hashCode()
The hashCode is based on the id, the isHR flag and on the internal values. |
boolean |
isValid()
Checks to see if this attribute is valid along with the values it contains. |
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 |
serialize(java.io.ObjectOutput out)
|
void |
setHR(boolean isHR)
Overload the ClientAttribte isHR method : we can't change this flag for a ServerAttribute, as the HR is already set using the AttributeType. |
void |
setId(java.lang.String id)
Overload the DefaultClientAttribute.setId(String) method. |
java.lang.String |
toString()
|
void |
writeExternal(java.io.ObjectOutput out)
Overload the DefaultClientAttribute.setUpId(String) method. |
| Methods inherited from class org.apache.directory.shared.ldap.entry.client.DefaultClientAttribute |
|---|
contains, get, get, getAll, getAttributeType, getBytes, getId, getString, getUpId, instanceOf, isHR, isValid, iterator, put, put, put, put, setAttributeType, setUpId, setUpId, size, toClientAttribute |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.apache.directory.shared.ldap.entry.EntryAttribute |
|---|
get, get, getAll, getAttributeType, getBytes, getId, getString, getUpId, instanceOf, isHR, isValid, put, put, put, put, setAttributeType, setUpId, setUpId, size, toClientAttribute |
| Methods inherited from interface java.lang.Iterable |
|---|
iterator |
| Field Detail |
|---|
public static final long serialVersionUID
| Constructor Detail |
|---|
public DefaultServerAttribute(AttributeType attributeType,
EntryAttribute attribute)
attributeType - The attribute's typeattribute - The attribute to be copiedpublic DefaultServerAttribute(AttributeType attributeType)
attributeType - the attributeType for the empty attribute added into the entry
public DefaultServerAttribute(java.lang.String upId,
AttributeType attributeType)
upId - the ID for the added attributeTypeattributeType - the added AttributeType
public DefaultServerAttribute(AttributeType attributeType,
Value<?>... vals)
attributeType - the attribute type according to the schemavals - an initial set of values for this attribute
public DefaultServerAttribute(java.lang.String upId,
AttributeType attributeType,
Value<?>... vals)
upId - the ID of the added attributeattributeType - the attribute type according to the schemavals - an initial set of values for this attribute
public DefaultServerAttribute(AttributeType attributeType,
java.lang.String... vals)
attributeType - The attributeType added on creationvals - The added value for this attribute
public DefaultServerAttribute(java.lang.String upId,
AttributeType attributeType,
java.lang.String... vals)
upId - the ID for the added attributeattributeType - The attributeType added on creationvals - the added values for this attribute
public DefaultServerAttribute(AttributeType attributeType,
byte[]... vals)
attributeType - The attributeType added on creationvals - The value for the added attribute
public DefaultServerAttribute(java.lang.String upId,
AttributeType attributeType,
byte[]... vals)
upId - the ID for the added attributeattributeType - the AttributeType to be addedvals - the values for the added attribute| Method Detail |
|---|
public int add(byte[]... vals)
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, the value is not added.
It's the responsibility of the caller to check if the stored values are consistent with the attribute's type.
add in interface EntryAttributeadd in class DefaultClientAttributevals - some new values to be added which may be null
public int add(java.lang.String... vals)
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, the value is not added.
add in interface EntryAttributeadd in class DefaultClientAttributevals - some new values to be added which may be null
EntryAttribute.add(String...)public int add(Value<?>... vals)
DefaultClientAttributeThe 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 EntryAttributeadd in class DefaultClientAttributeEntryAttribute.add(org.apache.directory.shared.ldap.entry.Value...)public void clear()
clear in interface EntryAttributeclear in class DefaultClientAttributepublic boolean contains(byte[]... vals)
Indicates whether all the specified values are attribute's values. If
at least one value is not an attribute's value, this method will return
false
If the Attribute is HR, this method will returns false
contains in interface EntryAttributecontains in class DefaultClientAttributevals - the values
public boolean contains(java.lang.String... vals)
Indicates whether all the specified values are attribute's values. If
at least one value is not an attribute's value, this method will return
false
If the Attribute is not HR, this method will returns false
contains in interface EntryAttributecontains in class DefaultClientAttributevals - the values
public boolean contains(Value<?>... vals)
Indicates whether the specified values are some of the attribute's values.
If the Attribute is HR, te metho will only accept String Values. Otherwise, it will only accept Binary values.
contains in interface EntryAttributecontains in class DefaultClientAttributevals - the values
public boolean isValid()
throws LdapException
Checks to see if this attribute is valid along with the values it contains.
An attribute is valid if :
isValid in interface EntryAttributeisValid in class DefaultClientAttributejavax.naming.NamingException - if there is a failure to check syntaxes of values
LdapException - if there is a failure to check syntaxes of valuespublic boolean remove(byte[]... vals)
DefaultClientAttributeRemoves 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 EntryAttributeremove in class DefaultClientAttributevals - the values to be removed
true if all the values shave been removed from this attributeEntryAttribute#remove(byte[]...)public boolean remove(java.lang.String... vals)
DefaultClientAttributeReturns 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 EntryAttributeremove in class DefaultClientAttributevals - the values to be removed
true if all the values shave been removed from this attributeEntryAttribute.remove(String...)public boolean remove(Value<?>... vals)
DefaultClientAttributeRemoves 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 EntryAttributeremove in class DefaultClientAttributevals - the values to be removed
true if all the values shave been removed from this attributeEntryAttribute.remove(org.apache.directory.shared.ldap.entry.Value...)public void setHR(boolean isHR)
Overload the ClientAttribte isHR method : we can't change this flag for a ServerAttribute, as the HR is already set using the AttributeType. Set the attribute to Human Readable or to Binary.
setHR in interface EntryAttributesetHR in class DefaultClientAttributeisHR - true for a Human Readable attribute,
false for a Binary attribute.public void setId(java.lang.String id)
Overload the DefaultClientAttribute.setId(String) method.
As the attributeType has already been set, we have to be sure that the argument is compatible with the attributeType's name.
If the given ID is not compatible with the attributeType's possible names, the previously loaded ID will be kept.
setId in interface EntryAttributesetId in class DefaultClientAttributeid - The attribute ID
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
Overload the DefaultClientAttribute.setUpId(String) method.
As the attributeType has already been set, we have to be sure that the argument is compatible with the attributeType's name.
If the given ID is not compatible with the attributeType's possible names, the previously loaded ID will be kept.
writeExternal in interface java.io.ExternalizablewriteExternal in class DefaultClientAttributeupId - The attribute ID
public void setUpId( String upId )
{
if ( !StringTools.isEmpty( StringTools.trim( upId ) ) )
{
if ( attributeType.getName() == null )
{
// If the name is null, then we may have to store an OID
if ( OID.isOID( upId ) && attributeType.getOid().equals( upId ) )
{
// Everything is fine, store the upId.
// This should not happen...
super.setUpId( upId );
return;
}
}
else
{
// We have at least one name. Check that the normalized upId
// is one of those names. Otherwise, the upId may be an OID too.
// In this case, it must be equals to the attributeType OID.
String normUpId = StringTools.lowerCaseAscii( StringTools.trim( upId ) );
for ( String atId:attributeType.getNames() )
{
if ( atId.equalsIgnoreCase( normUpId ) )
{
// Found ! We can store the upId and get out
super.setUpId( upId );
return;
}
}
// Last case, the UpId is an OID
if ( OID.isOID( normUpId ) && attributeType.getOid().equals( normUpId ) )
{
// We have an OID : stores it
super.setUpId( upId );
return;
}
return;
}
}
return;
}
//-------------------------------------------------------------------------
// Serialization methods
//-------------------------------------------------------------------------
/**
java.io.IOExceptionWe can't use this method for a ServerAttribute, as we have to feed the value
with an AttributeType object
public void serialize(java.io.ObjectOutput out)
throws java.io.IOException
java.io.IOException
This is the place where we serialize attributes, and all theirs
elements.
The inner structure is the same as the client attribute, but we can't call
it as we won't be able to serialize the serverValues
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
readExternal in interface java.io.ExternalizablereadExternal in class DefaultClientAttributejava.io.IOException
java.lang.ClassNotFoundExceptionWe can't use this method for a ServerAttribute, as we have to feed the value
with an AttributeType object
public void deserialize(java.io.ObjectInput in)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundExceptionExternalizable.readExternal(ObjectInput)public EntryAttribute clone()
clone in interface EntryAttributeclone in class DefaultClientAttributeCloneable#clone()public boolean equals(java.lang.Object obj)
equals in class DefaultClientAttributetrue if the two objects are equalObject.equals(Object)public int hashCode()
hashCode in class DefaultClientAttributeObject.hashCode()public java.lang.String toString()
toString in class DefaultClientAttributeObject.toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||