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

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

public class ClientBinaryValue
extends AbstractValue<byte[]>

A server side schema aware wrapper around a binary 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
ClientBinaryValue()
          Creates a ServerBinaryValue without an initial wrapped value.
ClientBinaryValue(byte[] wrapped)
          Creates a ServerBinaryValue with an initial wrapped binary value.
 
Method Summary
 void clear()
          Reset the value
 ClientBinaryValue clone()
           
 int compareTo(Value<byte[]> value)
           
 boolean equals(java.lang.Object obj)
          Checks to see if this ServerBinaryValue equals the supplied object.
 byte[] getCopy()
          Gets a copy of the binary value.
 byte[] getNormalizedValueCopy()
          Gets a direct reference to the normalized representation for the wrapped value of this ServerValue wrapper.
 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(byte[] wrapped)
          Sets this value's wrapped value to a copy of the src array.
 java.lang.String toString()
          Dumps binary in hex with label.
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.apache.directory.shared.ldap.entry.AbstractValue
get, getNormalizedValue, getNormalizedValueReference, getReference, isNormalized, isNull, isValid, isValid, normalize, setNormalized
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClientBinaryValue

public ClientBinaryValue()
Creates a ServerBinaryValue without an initial wrapped value.

Parameters:
attributeType - the schema type associated with this ServerBinaryValue

ClientBinaryValue

public ClientBinaryValue(byte[] wrapped)
Creates a ServerBinaryValue with an initial wrapped binary value.

Parameters:
attributeType - the schema type associated with this ServerBinaryValue
wrapped - the binary value to wrap which may be null, or a zero length byte array
Method Detail

clear

public void clear()
Reset the value

Specified by:
clear in interface Value<byte[]>
Overrides:
clear in class AbstractValue<byte[]>

set

public final void set(byte[] wrapped)
Description copied from class: AbstractValue
Sets this value's wrapped value to a copy of the src array.

Specified by:
set in interface Value<byte[]>
Specified by:
set in class AbstractValue<byte[]>
Parameters:
wrapped - the byte array to use as the wrapped value

getNormalizedValueCopy

public byte[] getNormalizedValueCopy()
Gets a direct reference to the normalized representation for the wrapped value of this ServerValue wrapper. Implementations will most likely leverage the attributeType this value is associated with to determine how to properly normalize the wrapped value.

Returns:
the normalized version of the wrapped value
Throws:
javax.naming.NamingException - if schema entity resolution fails or normalization fails

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<byte[]> 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)

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)
Checks to see if this ServerBinaryValue equals the supplied object. This equals implementation overrides the BinaryValue implementation which is not schema aware.

Overrides:
equals in class java.lang.Object
Throws:
java.lang.IllegalStateException - on failures to extract the comparator, or the normalizers needed to perform the required comparisons based on the schema

clone

public ClientBinaryValue clone()
Specified by:
clone in interface Value<byte[]>
Overrides:
clone in class AbstractValue<byte[]>
Returns:
a copy of the current value

getCopy

public byte[] getCopy()
Gets a copy of the binary value.

Returns:
a copy of the binary value

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()
Dumps binary in hex with label.

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


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