org.apache.directory.shared.ldap.entry.client
Class ClientStringValue

java.lang.Object
  extended by org.apache.directory.shared.ldap.entry.AbstractValue<java.lang.String>
      extended by org.apache.directory.shared.ldap.entry.client.ClientStringValue
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Value<java.lang.String>>, Value<java.lang.String>

public class ClientStringValue
extends AbstractValue<java.lang.String>

A server side schema aware wrapper around a String attribute value. This value wrapper uses schema information to syntax check values, and to compare them for equality and ordering. It caches results and invalidates them when the wrapped value changes.

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

Field Summary
 
Fields inherited from class org.apache.directory.shared.ldap.entry.AbstractValue
normalized, normalizedValue, valid, wrapped
 
Constructor Summary
ClientStringValue()
          Creates a ServerStringValue without an initial wrapped value.
ClientStringValue(java.lang.String wrapped)
          Creates a ServerStringValue with an initial wrapped String value.
 
Method Summary
 ClientStringValue clone()
          Get a clone of the Client Value
 int compareTo(Value<java.lang.String> value)
           
 boolean equals(java.lang.Object obj)
           
 java.lang.String get()
          Get the stored value.
 java.lang.String getCopy()
          Get a copy of the stored value.
 java.lang.String getNormalizedValue()
          Gets the normalized (canonical) representation for the wrapped string.
 java.lang.String getNormalizedValueCopy()
          Gets a copy of the the normalized (canonical) representation for the wrapped value.
 int hashCode()
           
 boolean isBinary()
          Tells if the current value is Binary or String
 void normalize(Normalizer normalizer)
          Normalize the value.
 void readExternal(java.io.ObjectInput in)
           
 void set(java.lang.String wrapped)
          Sets the wrapped String value.
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.apache.directory.shared.ldap.entry.AbstractValue
clear, getNormalizedValueReference, getReference, isNormalized, isNull, isValid, isValid, normalize, setNormalized
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClientStringValue

public ClientStringValue()
Creates a ServerStringValue without an initial wrapped value.


ClientStringValue

public ClientStringValue(java.lang.String wrapped)
Creates a ServerStringValue with an initial wrapped String value.

Parameters:
wrapped - the value to wrap which can be null
Method Detail

get

public java.lang.String get()
Get the stored value.

Specified by:
get in interface Value<java.lang.String>
Overrides:
get in class AbstractValue<java.lang.String>
Returns:
The stored value

getCopy

public java.lang.String getCopy()
Get a copy of the stored value.

Returns:
A copy of the stored value.

set

public final void set(java.lang.String wrapped)
Sets the wrapped String value. Has the side effect of setting the normalizedValue and the valid flags to null if the wrapped value is different than what is already set. These cached values must be recomputed to be correct with different values.

Specified by:
set in interface Value<java.lang.String>
Specified by:
set in class AbstractValue<java.lang.String>
Parameters:
wrapped - the byte array to use as the wrapped value
See Also:
ServerValue#set(Object)

getNormalizedValue

public java.lang.String 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.

Specified by:
getNormalizedValue in interface Value<java.lang.String>
Overrides:
getNormalizedValue in class AbstractValue<java.lang.String>
Returns:
gets the normalized value

getNormalizedValueCopy

public java.lang.String getNormalizedValueCopy()
Gets a copy of the the normalized (canonical) representation for the wrapped value.

Returns:
gets a copy of the normalized value

normalize

public final void normalize(Normalizer normalizer)
                     throws javax.naming.NamingException
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:
javax.naming.NamingException - If the value cannot be normalized

compareTo

public int compareTo(Value<java.lang.String> value)
Throws:
java.lang.IllegalStateException - on failures to extract the comparator, or the normalizers needed to perform the required comparisons based on the schema
See Also:
ServerValue#compareTo(ServerValue)

clone

public ClientStringValue clone()
Get a clone of the Client Value

Specified by:
clone in interface Value<java.lang.String>
Overrides:
clone in class AbstractValue<java.lang.String>
Returns:
a copy of the current value

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
Returns:
the instance's hashcode
See Also:
Object.hashCode()

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
See Also:
Two ClientStringValue are equals if their normalized values are equal

isBinary

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

Returns:
true if the value is Binary, false otherwise

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException
See Also:
Externalizable.readExternal(ObjectInput)

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Throws:
java.io.IOException
See Also:
Externalizable.writeExternal(ObjectOutput)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


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