org.apache.directory.api.ldap.model.entry
Class AbstractValue<T>

java.lang.Object
  extended by org.apache.directory.api.ldap.model.entry.AbstractValue<T>
All Implemented Interfaces:
Externalizable, Serializable, Cloneable, Comparable<Value<T>>, Value<T>
Direct Known Subclasses:
BinaryValue, StringValue

public abstract class AbstractValue<T>
extends Object
implements Value<T>

A wrapper around byte[] values in entries.

Author:
Apache Directory Project
See Also:
Serialized Form

Field Summary
protected  AttributeType attributeType
          reference to the attributeType zssociated with the value
protected  int h
          The computed hashcode.
protected static org.slf4j.Logger LOG
          logger for reporting errors that might not be handled properly upstream
protected  T normalizedValue
          the canonical representation of the wrapped value
protected  T wrappedValue
          the wrapped binary value
 
Fields inherited from interface org.apache.directory.api.ldap.model.entry.Value
BINARY, STRING
 
Constructor Summary
AbstractValue()
           
 
Method Summary
protected  void apply(AttributeType attributeType)
          Apply an AttributeType to the current Value, normalizing it.
 Value<T> clone()
          Clone a Value
 AttributeType getAttributeType()
          Get the associated AttributeType
 byte[] getBytes()
          Get the wrapped value as a byte[].
protected  LdapComparator<T> getLdapComparator()
          Gets a comparator using getMatchingRule() to resolve the matching that the comparator is extracted from.
 T getNormReference()
          Gets a reference to the the normalized (canonical) representation for the wrapped value.
 T getReference()
          Gets a reference to the wrapped value.
 String getString()
          Get the wrapped value as a String.
 boolean isInstanceOf(AttributeType attributeType)
          Check if the value is stored into an instance of the given AttributeType, or one of its ascendant.
 boolean isNull()
          Check if the contained value is null or not
 boolean isSchemaAware()
          Tells if the value is schema aware or not.
 boolean isValid(SyntaxChecker syntaxChecker)
          Uses the syntaxChecker associated with the attributeType to check if the value is valid.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.directory.api.ldap.model.entry.Value
getNormValue, getValue, isHumanReadable, length
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

LOG

protected static final org.slf4j.Logger LOG
logger for reporting errors that might not be handled properly upstream


attributeType

protected transient AttributeType attributeType
reference to the attributeType zssociated with the value


wrappedValue

protected T wrappedValue
the wrapped binary value


normalizedValue

protected T normalizedValue
the canonical representation of the wrapped value


h

protected volatile int h
The computed hashcode. We don't want to compute it each time the hashcode() method is called

Constructor Detail

AbstractValue

public AbstractValue()
Method Detail

clone

public Value<T> clone()
Clone a Value

Specified by:
clone in interface Value<T>
Overrides:
clone in class Object
Returns:
A cloned value

getReference

public T getReference()
Gets a reference to the wrapped value. Warning ! The value is not copied !!!

Specified by:
getReference in interface Value<T>
Returns:
a direct handle on the value that is wrapped

getString

public String getString()
Get the wrapped value as a String.

Specified by:
getString in interface Value<T>
Returns:
the wrapped value as a String

getBytes

public byte[] getBytes()
Get the wrapped value as a byte[].

Specified by:
getBytes in interface Value<T>
Returns:
the wrapped value as a byte[]

getAttributeType

public AttributeType getAttributeType()
Get the associated AttributeType

Specified by:
getAttributeType in interface Value<T>
Returns:
The AttributeType

apply

protected void apply(AttributeType attributeType)
              throws LdapInvalidAttributeValueException
Apply an AttributeType to the current Value, normalizing it.

Parameters:
attributeType - The AttributeType to apply
Throws:
LdapInvalidAttributeValueException - If the value is not valid accordingly to the schema

getLdapComparator

protected final LdapComparator<T> getLdapComparator()
                                             throws LdapException
Gets a comparator using getMatchingRule() to resolve the matching that the comparator is extracted from.

Returns:
a comparator associated with the attributeType or null if one cannot be found
Throws:
LdapException - if resolution of schema entities fail

isInstanceOf

public boolean isInstanceOf(AttributeType attributeType)
Check if the value is stored into an instance of the given AttributeType, or one of its ascendant. For instance, if the Value is associated with a CommonName, checking for Name will match.

Specified by:
isInstanceOf in interface Value<T>
Parameters:
attributeType - The AttributeType we are looking at
Returns:
true if the value is associated with the given attributeType or one of its ascendant

getNormReference

public T getNormReference()
Gets a reference to the the normalized (canonical) representation for the wrapped value.

Specified by:
getNormReference in interface Value<T>
Returns:
gets a reference to the normalized value

isNull

public final boolean isNull()
Check if the contained value is null or not

Specified by:
isNull in interface Value<T>
Returns:
true if the inner value is null.

isValid

public final boolean isValid(SyntaxChecker syntaxChecker)
                      throws LdapInvalidAttributeValueException
Uses the syntaxChecker associated with the attributeType to check if the value is valid.

Specified by:
isValid in interface Value<T>
Parameters:
syntaxChecker - the SyntaxChecker to use to validate the value
Returns:
true if the value is valid
Throws:
LdapInvalidAttributeValueException - if the value cannot be validated

isSchemaAware

public final boolean isSchemaAware()
Tells if the value is schema aware or not.

Specified by:
isSchemaAware in interface Value<T>
Returns:
true if the value is sxhema aware


Copyright © 2003-2013 The Apache Software Foundation. All Rights Reserved.