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

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

public class BinaryValue
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.

Author:
Apache Directory Project
See Also:
Serialized Form

Field Summary
static long serialVersionUID
          Used for serialization
 
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
BinaryValue(AttributeType attributeType, byte[] value)
          Creates a BinaryValue with an initial wrapped binary value.
BinaryValue(byte[] value)
          Creates a BinaryValue with an initial wrapped binary value.
 
Method Summary
 BinaryValue clone()
          Clone a Value
 int compareTo(Value<byte[]> value)
           
static BinaryValue deserialize(AttributeType attributeType, ObjectInput in)
          Deserialize a schema aware BinaryValue.
static BinaryValue deserialize(ObjectInput in)
          Deserialize a BinaryValue.
 boolean equals(Object obj)
          Checks to see if this BinaryValue equals the supplied object.
 byte[] getBytes()
          Get the wrapped value as a byte[].
 byte[] getNormValue()
          Gets a direct reference to the normalized representation for the wrapped value of this ServerValue wrapper.
 String getString()
          Get the wrapped value as a String.
 byte[] 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()
          Dumps binary in hex with label.
 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
 

Field Detail

serialVersionUID

public static final long serialVersionUID
Used for serialization

See Also:
Constant Field Values
Constructor Detail

BinaryValue

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

Parameters:
value - the binary value to wrap which may be null, or a zero length byte array

BinaryValue

public BinaryValue(AttributeType attributeType,
                   byte[] value)
            throws LdapInvalidAttributeValueException
Creates a BinaryValue with an initial wrapped binary value.

Parameters:
attributeType - the schema type associated with this BinaryValue
value - the binary value to wrap which may be null, or a zero length byte array
Throws:
LdapInvalidAttributeValueException - If the added value is invalid accordingly to the schema
Method Detail

getNormValue

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

compareTo

public int compareTo(Value<byte[]> value)
See Also:
ServerValue#compareTo(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)
Checks to see if this BinaryValue equals the supplied object. This equals implementation overrides the BinaryValue implementation which is not schema aware.

Overrides:
equals in class Object

clone

public BinaryValue clone()
Clone a Value

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

getValue

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

Returns:
a copy of the wrapped value

isHumanReadable

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

Returns:
true if the value is HR, false otherwise

length

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

getBytes

public byte[] getBytes()
Get the wrapped value as a byte[]. This method returns a copy of the wrapped byte[].

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

getString

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

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

deserialize

public static BinaryValue deserialize(ObjectInput in)
                               throws IOException,
                                      ClassNotFoundException
Deserialize a BinaryValue. It will return a new BinaryValue 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 BinaryValue

deserialize

public static BinaryValue deserialize(AttributeType attributeType,
                                      ObjectInput in)
                               throws IOException,
                                      ClassNotFoundException
Deserialize a schema aware BinaryValue. It will return a new BinaryValue 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 BinaryValue

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

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


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