org.helidb.lang.serializer
Class CharacterNullSerializer

java.lang.Object
  extended by org.helidb.lang.serializer.CharacterSerializer
      extended by org.helidb.lang.serializer.CharacterNullSerializer
All Implemented Interfaces:
Serializer<Character>

public class CharacterNullSerializer
extends CharacterSerializer

A Serializer for Character values that may be null. Character values are serialized to a two bytes long, big-endian byte array. A special, configurable value is used to represent null.

The singleton instance INSTANCE uses two zero bytes to represent null values. It may be used instead of instantiating this class.

Since:
1.1
Author:
Karl Gustafsson
See Also:
CharacterSerializer, Character
In_jar:
helidb-core

Field Summary
static CharacterNullSerializer INSTANCE
          The singleton instance.
 
Fields inherited from class org.helidb.lang.serializer.CharacterSerializer
DATA_SIZE
 
Constructor Summary
CharacterNullSerializer(byte[] nullValue)
          Instantiate this class.
CharacterNullSerializer(char nullValue)
          Instantiate this class.
 
Method Summary
 Character interpret(byte[] barr)
          Interpret the data in the byte array to an object of the type handled by the Serializer implementation.
 Character interpret(byte[] barr, int offset, int length)
          Interpret the data in the byte array to an object of the type handled by the Serializer implementation.
 boolean isNullValuesPermitted()
          Does this serializer permit null values?
 byte[] serialize(Character value)
          Serialize the supplied object into a new byte array.
 int serialize(Character value, byte[] barr, int offset)
          Serialize the supplied object into the byte array.
 
Methods inherited from class org.helidb.lang.serializer.CharacterSerializer
encodeCharacter, getCharacter, getSerializedSize, read, read, readCharacter, readCharacter
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

public static final CharacterNullSerializer INSTANCE
The singleton instance. May be used instead of instantiating this class. It uses two zero bytes to represent null values.

Constructor Detail

CharacterNullSerializer

public CharacterNullSerializer(byte[] nullValue)
Instantiate this class.

Parameters:
nullValue - The value used to represent null Character:s. (big-endian)

CharacterNullSerializer

public CharacterNullSerializer(char nullValue)
Instantiate this class.

Parameters:
nullValue - The value used to represent null Character:s.
Method Detail

interpret

public Character interpret(byte[] barr,
                           int offset,
                           int length)
Description copied from interface: Serializer
Interpret the data in the byte array to an object of the type handled by the Serializer implementation.

Specified by:
interpret in interface Serializer<Character>
Overrides:
interpret in class CharacterSerializer
Parameters:
barr - The byte array containing the data.
offset - The start position of the data.
length - The length of the data.
Returns:
The interpreted object.
See Also:
Serializer.interpret(byte[])

interpret

public Character interpret(byte[] barr)
Description copied from interface: Serializer
Interpret the data in the byte array to an object of the type handled by the Serializer implementation.

Specified by:
interpret in interface Serializer<Character>
Overrides:
interpret in class CharacterSerializer
Parameters:
barr - The byte array containing the data.
Returns:
The interpreted object.
See Also:
Serializer.interpret(byte[], int, int)

serialize

public int serialize(Character value,
                     byte[] barr,
                     int offset)
Description copied from interface: Serializer
Serialize the supplied object into the byte array.

Specified by:
serialize in interface Serializer<Character>
Overrides:
serialize in class CharacterSerializer
Parameters:
value - The object to serialize.
barr - The byte array to serialize it to.
offset - The start position to write data at in the byte array.
Returns:
The number of bytes written to the array.

serialize

public byte[] serialize(Character value)
Description copied from interface: Serializer
Serialize the supplied object into a new byte array.

Specified by:
serialize in interface Serializer<Character>
Overrides:
serialize in class CharacterSerializer
Parameters:
value - The object to serialize.
Returns:
The object serialized into a byte array.

isNullValuesPermitted

public boolean isNullValuesPermitted()
Description copied from interface: Serializer
Does this serializer permit null values?

Specified by:
isNullValuesPermitted in interface Serializer<Character>
Overrides:
isNullValuesPermitted in class CharacterSerializer
Returns:
true, always.