org.apache.directory.api.ldap.model.entry
Class StringValue

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

public class StringValue
extends AbstractValue<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.

Author:
Apache Directory Project
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.directory.api.ldap.model.entry.AbstractValue
attributeType, h, LOG, normalizedValue, wrappedValue
 
Fields inherited from interface org.apache.directory.api.ldap.model.entry.Value
BINARY, STRING
 
Constructor Summary
StringValue(AttributeType attributeType, String value)
          Creates a schema aware StringValue with an initial wrapped String value.
StringValue(String value)
          Creates a StringValue with an initial wrapped String value.
 
Method Summary
 StringValue clone()
          Clone a Value
 int compareTo(Value<String> value)
           
static StringValue deserialize(AttributeType attributeType, ObjectInput in)
          Deserialize a schemaAware StringValue.
static StringValue deserialize(ObjectInput in)
          Deserialize a StringValue.
 boolean equals(Object obj)
          Two StringValue are equals if their normalized values are equal
 byte[] getBytes()
          Get the wrapped value as a byte[].
 String getNormValue()
          Gets the normalized (canonical) representation for the wrapped string.
 String getString()
          Get the wrapped value as a String.
 String getValue()
          Get the wrapped value.
 int hashCode()
           
 boolean isHumanReadable()
          Tells if the current value is Human Readable
 int length()
           
 void readExternal(ObjectInput in)
          
 String toString()
           
 void writeExternal(ObjectOutput out)
          
 
Methods inherited from class org.apache.directory.api.ldap.model.entry.AbstractValue
apply, getAttributeType, getLdapComparator, getNormReference, getReference, isInstanceOf, isNull, isSchemaAware, isValid
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StringValue

public StringValue(String value)
Creates a StringValue with an initial wrapped String value.

Parameters:
value - the value to wrap which can be null

StringValue

public StringValue(AttributeType attributeType,
                   String value)
            throws LdapInvalidAttributeValueException
Creates a schema aware StringValue with an initial wrapped String value.

Parameters:
attributeType - the schema type associated with this StringValue
value - the value to wrap
Throws:
LdapInvalidAttributeValueException - If the added value is invalid accordingly to the schema
Method Detail

getValue

public String getValue()
Get the wrapped value. It will return a copy, not a reference.

Returns:
a copy of the wrapped value

getNormValue

public String getNormValue()
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.

Returns:
gets the normalized value

compareTo

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

clone

public StringValue clone()
Clone a Value

Specified by:
clone in interface Value<String>
Overrides:
clone in class AbstractValue<String>
Returns:
A cloned value

hashCode

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

equals

public boolean equals(Object obj)
Two StringValue are equals if their normalized values are equal

Overrides:
equals in class Object
See Also:
Object.equals(Object)

isHumanReadable

public boolean isHumanReadable()
Tells if the current value is Human Readable

Returns:
true if the value is a String, false otherwise

length

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

getBytes

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

Specified by:
getBytes in interface Value<String>
Overrides:
getBytes in class AbstractValue<String>
Returns:
the wrapped value as a byte[]

getString

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

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

deserialize

public static StringValue deserialize(ObjectInput in)
                               throws IOException,
                                      ClassNotFoundException
Deserialize a StringValue. It will return a new StringValue instance.

Parameters:
in - The input stream
Returns:
A new StringValue instance
Throws:
IOException - If the stream can't be read
ClassNotFoundException - If we can't instanciate a StringValue

deserialize

public static StringValue deserialize(AttributeType attributeType,
                                      ObjectInput in)
                               throws IOException,
                                      ClassNotFoundException
Deserialize a schemaAware StringValue. It will return a new StringValue instance.

Parameters:
attributeType - The AttributeType associated with the Value. Can be null
in - The input stream
Returns:
A new StringValue instance
Throws:
IOException - If the stream can't be read
ClassNotFoundException - If we can't instanciate a StringValue

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException

Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException

Throws:
IOException

toString

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


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