public final class DefaultServerAttribute extends DefaultClientAttribute implements EntryAttribute
| Modifier and Type | Field and Description |
|---|---|
static long |
serialVersionUID |
attributeType, id, isHR, upId, values| Constructor and Description |
|---|
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,
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(String upId,
AttributeType attributeType)
Create a new instance of a EntryAttribute, without value.
|
DefaultServerAttribute(String upId,
AttributeType attributeType,
byte[]... vals)
Create a new instance of a EntryAttribute, with some byte[] values.
|
DefaultServerAttribute(String upId,
AttributeType attributeType,
String... vals)
Create a new instance of a EntryAttribute.
|
DefaultServerAttribute(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.
|
| 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<?>... 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(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(ObjectInput in) |
boolean |
equals(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(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 |
serialize(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(String id)
Overload the
DefaultClientAttribute.setId(String) method. |
String |
toString() |
void |
writeExternal(ObjectOutput out)
Overload the
DefaultClientAttribute.setUpId(String) method. |
contains, get, get, getAll, getAttributeType, getBytes, getId, getString, getUpId, instanceOf, isHR, isValid, iterator, put, put, put, put, setAttributeType, setUpId, setUpId, size, toClientAttributefinalize, getClass, notify, notifyAll, wait, wait, waitget, get, getAll, getAttributeType, getBytes, getId, getString, getUpId, instanceOf, isHR, isValid, put, put, put, put, setAttributeType, setUpId, setUpId, size, toClientAttributeforEach, iterator, spliteratorpublic static final long serialVersionUID
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 entrypublic DefaultServerAttribute(String upId, AttributeType attributeType)
upId - the ID for the added attributeTypeattributeType - the added AttributeTypepublic DefaultServerAttribute(AttributeType attributeType, Value<?>... vals)
attributeType - the attribute type according to the schemavals - an initial set of values for this attributepublic DefaultServerAttribute(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 attributepublic DefaultServerAttribute(AttributeType attributeType, String... vals)
attributeType - The attributeType added on creationvals - The added value for this attributepublic DefaultServerAttribute(String upId, AttributeType attributeType, String... vals)
upId - the ID for the added attributeattributeType - The attributeType added on creationvals - the added values for this attributepublic DefaultServerAttribute(AttributeType attributeType, byte[]... vals)
attributeType - The attributeType added on creationvals - The value for the added attributepublic DefaultServerAttribute(String upId, AttributeType attributeType, byte[]... vals)
upId - the ID for the added attributeattributeType - the AttributeType to be addedvals - the values for the added attributepublic 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 nullpublic int add(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 nullEntryAttribute.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 valuespublic boolean contains(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 valuespublic 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 valuespublic 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 DefaultClientAttributeNamingException - if there is a failure to check syntaxes of valuesLdapException - 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 removedtrue if all the values shave been removed from this attributeEntryAttribute#remove(byte[]...)public boolean remove(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 removedtrue 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 removedtrue 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(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 IDpublic void writeExternal(ObjectOutput out) throws 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 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
//-------------------------------------------------------------------------
/**IOExceptionWe can't use this method for a ServerAttribute, as we have to feed the value
with an AttributeType objectpublic void serialize(ObjectOutput out) throws IOException
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
readExternal in interface ExternalizablereadExternal in class DefaultClientAttributeIOExceptionClassNotFoundExceptionWe can't use this method for a ServerAttribute, as we have to feed the value
with an AttributeType objectpublic void deserialize(ObjectInput in) throws IOException, ClassNotFoundException
IOExceptionClassNotFoundExceptionExternalizable.readExternal(ObjectInput)public EntryAttribute clone()
clone in interface EntryAttributeclone in class DefaultClientAttributeCloneable#clone()public boolean equals(Object obj)
equals in class DefaultClientAttributetrue if the two objects are equalObject.equals(Object)public int hashCode()
hashCode in class DefaultClientAttributeObject.hashCode()public String toString()
toString in class DefaultClientAttributeObject.toString()Copyright © 2003–2016 The Apache Software Foundation. All rights reserved.