org.apache.directory.shared.ldap.entry
Interface Value<T>

All Superinterfaces:
java.lang.Cloneable, java.lang.Comparable<Value<T>>, java.io.Externalizable, java.io.Serializable
All Known Implementing Classes:
AbstractValue, BinaryValue, StringValue

public interface Value<T>
extends java.lang.Cloneable, java.io.Externalizable, java.lang.Comparable<Value<T>>

A interface for wrapping attribute values stored into an EntryAttribute. These values can be a String or a byte[].

Version:
$Rev$, $Date$
Author:
Apache Directory Project

Method Summary
 Value<T> clone()
           
 T get()
          Get the wrapped value.
 byte[] getBytes()
          Get the wrapped value as a byte[].
 T getNormalizedValue()
          Gets the normalized (canonical) representation for the wrapped string.
 T getNormalizedValueCopy()
          Gets a copy of the 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()
          Get a reference on the stored value.
 java.lang.String getString()
          Get the wrapped value as a String.
 boolean isBinary()
          Tells if the current value is Binary or String
 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()
          Tells if the value is valid.
 boolean isValid(SyntaxChecker checker)
          Tells if the value is valid wrt a Syntax checker
 int length()
           
 void normalize()
          Normalize the value.
 void normalize(Normalizer normalizer)
          Normalize the value.
 void setNormalized(boolean normalized)
          Set the normalized flag.
 
Methods inherited from interface java.io.Externalizable
readExternal, writeExternal
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Method Detail

clone

Value<T> clone()

isNull

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

Returns:
true if the inner value is null.

get

T get()
Get the wrapped value. It will return a copy, not a reference.

Returns:
a copy of the wrapped value

getBytes

byte[] getBytes()
Get the wrapped value as a byte[]. If the original value is binary, this method will return a copy of the wrapped byte[]

Returns:
the wrapped value as a byte[]

getString

java.lang.String getString()
Get the wrapped value as a String. If the original value is binary, this method will return the value as if it was an UTF-8 encoded String.

Returns:
the wrapped value as a String

getReference

T getReference()
Get a reference on the stored value.

Returns:
a reference on the wrapped value.

isNormalized

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

Returns:
true if the value has already been normalized.

isValid

boolean isValid()
Tells if the value is valid. The value must have already been validated at least once through a call to isValid( SyntaxChecker ).

Returns:
true if the value is valid

isValid

boolean isValid(SyntaxChecker checker)
                throws LdapException
Tells if the value is valid wrt a Syntax checker

Parameters:
checker - the SyntaxChecker to use to validate the value
Returns:
true if the value is valid
Throws:
LdapException - if the value cannot be validated

setNormalized

void setNormalized(boolean normalized)
Set the normalized flag.

Parameters:
normalized - the value : true or false

getNormalizedValue

T getNormalizedValue()
Gets the normalized (canonical) representation for the wrapped string. If the wrapped String is null, null is returned, otherwise the normalized form is returned. If the normalizedValue is null, then this method will attempt to generate it from the wrapped value: repeated calls to this method do not unnecessarily normalize the wrapped value. Only changes to the wrapped value result in attempts to normalize the wrapped value.

Returns:
gets the normalized value

getNormalizedValueReference

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

Returns:
gets a reference to the normalized value

getNormalizedValueCopy

T getNormalizedValueCopy()
Gets a copy of the the normalized (canonical) representation for the wrapped value.

Returns:
gets a copy of the normalized value

normalize

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

Throws:
LdapException - if the value cannot be normalized

normalize

void normalize(Normalizer normalizer)
               throws LdapException
Normalize the value. For a client String value, applies the given normalizer. It supposes that the client has access to the schema in order to select the appropriate normalizer.

Parameters:
normalizer - the normalizer to apply to the value
Throws:
LdapException - if the value cannot be normalized

isBinary

boolean isBinary()
Tells if the current value is Binary or String

Returns:
true if the value is Binary, false otherwise

length

int length()
Returns:
The length of the interned value


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