org.apache.directory.shared.ldap.entry
Class AbstractValue<T>

java.lang.Object
  extended by org.apache.directory.shared.ldap.entry.AbstractValue<T>
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Value<T>>, Value<T>
Direct Known Subclasses:
ClientBinaryValue, ClientStringValue

public abstract class AbstractValue<T>
extends java.lang.Object
implements Value<T>

A wrapper around byte[] values in entries.

Version:
$Rev$, $Date$
Author:
Apache Directory Project
See Also:
Serialized Form

Field Summary
protected  boolean normalized
          A flag set when the value has been normalized
protected  T normalizedValue
          the canonical representation of the wrapped value
protected  java.lang.Boolean valid
          cached results of the isValid() method call
protected  T wrapped
          the wrapped binary value
 
Constructor Summary
AbstractValue()
           
 
Method Summary
 void clear()
          Reset the value
 Value<T> clone()
           
 T get()
          Gets a copy of the wrapped binary value.
 T getNormalizedValue()
          Gets the normalized (canonical) representation for the wrapped value.
 T getNormalizedValueReference()
          Gets a reference to the the normalized (canonical) representation for the wrapped value.
 T getReference()
          Gets a reference to the wrapped binary value.
 boolean isNormalized()
          Tells if the value has already be normalized or not.
 boolean isNull()
          Check if the contained value is null or not
 boolean isValid()
          Check if the Valid flag is set or not.
 boolean isValid(SyntaxChecker syntaxChecker)
          Uses the syntaxChecker associated with the attributeType to check if the value is valid.
 void normalize()
          Normalize the value.
abstract  void set(T wrapped)
          Sets this value's wrapped value to a copy of the src array.
 void setNormalized(boolean normalized)
          Set the normalized flag.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.directory.shared.ldap.entry.Value
getCopy, getNormalizedValueCopy, isBinary, normalize
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

wrapped

protected T wrapped
the wrapped binary value


normalizedValue

protected T normalizedValue
the canonical representation of the wrapped value


normalized

protected boolean normalized
A flag set when the value has been normalized


valid

protected java.lang.Boolean valid
cached results of the isValid() method call

Constructor Detail

AbstractValue

public AbstractValue()
Method Detail

clear

public void clear()
Reset the value

Specified by:
clear in interface Value<T>

clone

public Value<T> clone()
Specified by:
clone in interface Value<T>
Overrides:
clone in class java.lang.Object

getReference

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

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

get

public T get()
Gets a copy of the wrapped binary value.

Specified by:
get in interface Value<T>
Returns:
a copy of the binary value that is wrapped

getNormalizedValue

public T getNormalizedValue()
Gets the normalized (canonical) representation for the wrapped value. If the wrapped value is null, null is returned, otherwise the normalized form is returned. If the normalized Value is null, then the wrapped value is returned

Specified by:
getNormalizedValue in interface Value<T>
Returns:
gets the normalized value

getNormalizedValueReference

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

Specified by:
getNormalizedValueReference 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 boolean isValid()
Check if the Valid flag is set or not. This flag is set by a call to the isValid( SyntaxChecker ) method for client values. It is overridden for server values. if the flag is not set, returns false

Specified by:
isValid in interface Value<T>
Returns:
true if the value is valid
See Also:
ServerValue#isValid()

isValid

public final boolean isValid(SyntaxChecker syntaxChecker)
                      throws javax.naming.NamingException
Uses the syntaxChecker associated with the attributeType to check if the value is valid. Repeated calls to this method do not attempt to re-check the syntax of the wrapped value every time if the wrapped value does not change. Syntax checks only result on the first check, and when the wrapped value changes.

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:
javax.naming.NamingException - if the value cannot be validated
See Also:
ServerValue#isValid()

normalize

public void normalize()
               throws javax.naming.NamingException
Normalize the value. In order to use this method, the Value must be schema aware.

Specified by:
normalize in interface Value<T>
Throws:
javax.naming.NamingException - If the value cannot be normalized

set

public abstract void set(T wrapped)
Sets this value's wrapped value to a copy of the src array.

Specified by:
set in interface Value<T>
Parameters:
wrapped - the byte array to use as the wrapped value

isNormalized

public final boolean isNormalized()
Tells if the value has already be normalized or not.

Specified by:
isNormalized in interface Value<T>
Returns:
true if the value has already been normalized.

setNormalized

public final void setNormalized(boolean normalized)
Set the normalized flag.

Specified by:
setNormalized in interface Value<T>
Parameters:
the - value : true or false


Copyright © 2003-2009 Apache Software Foundation. All Rights Reserved.