public abstract class Codec
extends java.lang.Object
getCodec(uk.ac.starlink.table.ValueInfo)
method, or use one of the static members.
The static members are all safe for concurrent use from multiple threads.
This is (supposed to be) considerably more lightweight than
all the Serializable
business - for one thing
there's no way to tell from the stream what kind of item has been
serialized, you have to make sure the right Codec instance is on
hand. In general it deals with primitive wrapper objects and
arrays of same, but new Codec instances for different classes
can be added.
Modifier and Type | Field and Description |
---|---|
static Codec |
BOOLEAN
Codec for byte-serialized boolean values, null handled.
|
static Codec |
BYTE
Codec for 8-bit byte, no null handling.
|
static Codec |
BYTE_ARRAY
Codec for variable-length array of 8-bit bytes.
|
static Codec |
CHAR
Codec for 16-bit character, no null handling.
|
static Codec |
DOUBLE
Codec for 64-bit floating point, nulls treated like NaN.
|
static Codec |
DOUBLE_ARRAY
Codec for variable-length array of 64-bit doubles.
|
static Codec |
FLOAT
Codec for 32-bit floating point, nulls treated like NaN.
|
static Codec |
FLOAT_ARRAY
Codec for variable-length array of 32-bit floats.
|
static Codec |
INT
Codec for 32-bit integer, no null handling.
|
static Codec |
INT_ARRAY
Codec for variable-length array of 32-bit integers.
|
static Codec |
LONG
Codec for 64-bit integer, no null handling.
|
static Codec |
LONG_ARRAY
Codec for variable-length array of 64-bit integers.
|
static Codec |
SHORT
Codec for 16-bit integer, no null handling.
|
static Codec |
SHORT_ARRAY
Codec for variable-length array of 16-bit integers.
|
static Codec |
STRING
Codec for variable-length string.
|
Constructor and Description |
---|
Codec() |
Modifier and Type | Method and Description |
---|---|
abstract boolean |
decodeBoolean(ByteStoreAccess in)
Deserialises an item from a stream, and presents it as a boolean
if possible.
|
abstract double |
decodeDouble(ByteStoreAccess in)
Deserialises an item from a stream, and presents it as a double
if possible.
|
abstract int |
decodeInt(ByteStoreAccess in)
Deserialises an item from a stream, and presents it as an integer
if possible.
|
abstract long |
decodeLong(ByteStoreAccess in)
Deserialises an item from a stream, and presents it as a long integer
if possible.
|
abstract java.lang.Object |
decodeObject(ByteStoreAccess in)
Deserializes an item from a stream.
|
abstract int |
encode(java.lang.Object value,
java.io.DataOutput out)
Serializes an object to a stream.
|
static Codec |
getCodec(ValueInfo info)
Returns a codec suitable for serializing/deserializing the contents
of a given ValueInfo.
|
abstract int |
getItemSize()
Returns the number of bytes a call to
encode will write. |
protected void |
warnCorrupt()
Logs a warning that unexpected data has been found in the stream
during decoding.
|
public static final Codec BYTE
public static final Codec SHORT
public static final Codec INT
public static final Codec LONG
public static final Codec FLOAT
public static final Codec DOUBLE
public static final Codec CHAR
public static final Codec BOOLEAN
public static final Codec BYTE_ARRAY
public static final Codec SHORT_ARRAY
public static final Codec INT_ARRAY
public static final Codec LONG_ARRAY
public static final Codec FLOAT_ARRAY
public static final Codec DOUBLE_ARRAY
public static final Codec STRING
public abstract int encode(java.lang.Object value, java.io.DataOutput out) throws java.io.IOException
value
- object to serializeout
- destination stream, positioned at place to writejava.io.IOException
public abstract java.lang.Object decodeObject(ByteStoreAccess in) throws java.io.IOException
in
- source stream, positioned at start of itemjava.io.IOException
public abstract int decodeInt(ByteStoreAccess in) throws java.io.IOException
in
- source stream, positioned at start of itemjava.io.IOException
public abstract long decodeLong(ByteStoreAccess in) throws java.io.IOException
in
- source stream, positioned at start of itemjava.io.IOException
public abstract double decodeDouble(ByteStoreAccess in) throws java.io.IOException
in
- source stream, positioned at start of itemjava.io.IOException
public abstract boolean decodeBoolean(ByteStoreAccess in) throws java.io.IOException
in
- source stream, positioned at start of itemjava.io.IOException
public abstract int getItemSize()
encode
will write.
If this value may vary, -1 is returned.public static Codec getCodec(ValueInfo info)
info
, null
is returned.info
- object describing the kind of item which is required to
be de/serializedprotected void warnCorrupt()