public interface ObjectCodec<TYPE>
Codec interface for Object translation to/from byte arrays for serialization and deserialization.
Implementations must follow several rules to enable correct usage:
Modifier and Type | Field and Description |
---|---|
static int |
VARIABLE_WIDTH_SENTINEL
The value which represents variable width columns.
|
Modifier and Type | Method and Description |
---|---|
default void |
checkWidth(int actualWidth)
Verify that this codec is capable of supporting a column that has an actual width of actual width
|
TYPE |
decode(byte[] input,
int offset,
int length)
Decode an object from an array of bytes.
|
byte[] |
encode(TYPE input)
Encode the specified input as an array of bytes.
|
int |
expectedObjectWidth()
What width byte array does this ObjectCodec expect to encode and decode?
|
static final int VARIABLE_WIDTH_SENTINEL
@NotNull byte[] encode(@Nullable TYPE input)
CollectionUtil.ZERO_LENGTH_BYTE_ARRAY
) is strongly encouraged.input
- The input object, possibly null@Nullable TYPE decode(@NotNull byte[] input, int offset, int length)
input
- The input byte array containing bytes to decodeoffset
- The offset into the byte array to start decoding fromlength
- The length of the byte array to decode from, starting at the offsetint expectedObjectWidth()
default void checkWidth(int actualWidth) throws IllegalArgumentException
actualWidth
- the actual width of the instantiated columnIllegalArgumentException
- if the actual width is not compatible with this codec