Package org.mariadb.jdbc.plugin
Interface Codec<T>
-
- Type Parameters:
T- java type supported
- All Known Implementing Classes:
BigDecimalCodec,BigIntegerCodec,BitSetCodec,BlobCodec,BooleanCodec,ByteArrayCodec,ByteCodec,ClobCodec,DateCodec,DoubleCodec,DurationCodec,FloatCodec,GeometryCollectionCodec,InstantCodec,IntCodec,LineStringCodec,LocalDateCodec,LocalDateTimeCodec,LocalTimeCodec,LongCodec,MultiLinestringCodec,MultiPointCodec,MultiPolygonCodec,OffsetDateTimeCodec,PointCodec,PolygonCodec,ReaderCodec,ShortCodec,StreamCodec,StringCodec,TimeCodec,TimestampCodec,UuidCodec,ZonedDateTimeCodec
public interface Codec<T>Codec interface, to describe how a certain type of data must be encoded / decoded
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleancanDecode(org.mariadb.jdbc.client.ColumnDecoder column, Class<?> type)If codec can decode this a server datatype to a java class typebooleancanEncode(Object value)Can Codec encode the java object typedefault booleancanEncodeLongData()Indicate if can encode long dataStringclassName()Codec native typeTdecodeBinary(org.mariadb.jdbc.client.ReadableByteBuf buffer, MutableInt fieldLength, org.mariadb.jdbc.client.ColumnDecoder column, Calendar cal)Decode from a mysql packet binary encoded a value to codec java typeTdecodeText(org.mariadb.jdbc.client.ReadableByteBuf buffer, MutableInt fieldLength, org.mariadb.jdbc.client.ColumnDecoder column, Calendar cal)Decode from a mysql packet text encoded a value to codec java typevoidencodeBinary(Writer encoder, Object value, Calendar cal, Long length)Binary encode value to writerdefault byte[]encodeData(T value, Long length)binary encoding value to a byte[]default voidencodeLongData(Writer encoder, T value, Long length)binary encoding value to a long data packetvoidencodeText(Writer encoder, org.mariadb.jdbc.client.Context context, Object value, Calendar cal, Long length)Text encode value to writerintgetBinaryEncodeType()Return server encoding data type
-
-
-
Method Detail
-
className
String className()
Codec native type- Returns:
- code native return type
-
canDecode
boolean canDecode(org.mariadb.jdbc.client.ColumnDecoder column, Class<?> type)If codec can decode this a server datatype to a java class type- Parameters:
column- server datatypetype- java return class- Returns:
- true if codec can decode it
-
canEncode
boolean canEncode(Object value)
Can Codec encode the java object type- Parameters:
value- java object type- Returns:
- true if codec can encode java type
-
decodeText
T decodeText(org.mariadb.jdbc.client.ReadableByteBuf buffer, MutableInt fieldLength, org.mariadb.jdbc.client.ColumnDecoder column, Calendar cal) throws SQLDataException
Decode from a mysql packet text encoded a value to codec java type- Parameters:
buffer- mysql packet bufferfieldLength- encoded value lengthcolumn- server column metadatacal- calendar- Returns:
- decoded value
- Throws:
SQLDataException- if unexpected error occurs during decoding
-
decodeBinary
T decodeBinary(org.mariadb.jdbc.client.ReadableByteBuf buffer, MutableInt fieldLength, org.mariadb.jdbc.client.ColumnDecoder column, Calendar cal) throws SQLDataException
Decode from a mysql packet binary encoded a value to codec java type- Parameters:
buffer- mysql packet bufferfieldLength- encoded value lengthcolumn- server column metadatacal- calendar- Returns:
- decoded value
- Throws:
SQLDataException- if unexpected error occurs during decoding
-
encodeText
void encodeText(Writer encoder, org.mariadb.jdbc.client.Context context, Object value, Calendar cal, Long length) throws IOException, SQLException
Text encode value to writer- Parameters:
encoder- writercontext- connection contextvalue- value to encodecal- calendarlength- maximum value length- Throws:
IOException- if any socket error occursSQLException- if encoding error occurs
-
encodeBinary
void encodeBinary(Writer encoder, Object value, Calendar cal, Long length) throws IOException, SQLException
Binary encode value to writer- Parameters:
encoder- writervalue- value to encodecal- calendarlength- maximum value length- Throws:
IOException- if any socket error occursSQLException- if encoding error occurs
-
canEncodeLongData
default boolean canEncodeLongData()
Indicate if can encode long data- Returns:
- true if possible
-
encodeLongData
default void encodeLongData(Writer encoder, T value, Long length) throws IOException, SQLException
binary encoding value to a long data packet- Parameters:
encoder- writervalue- value to encodelength- maximum length value- Throws:
IOException- if any socket error occursSQLException- if encoding error occurs
-
encodeData
default byte[] encodeData(T value, Long length) throws IOException, SQLException
binary encoding value to a byte[]- Parameters:
value- value to encodelength- maximum length value- Returns:
- encoded value
- Throws:
IOException- if any socket error occursSQLException- if encoding error occurs
-
getBinaryEncodeType
int getBinaryEncodeType()
Return server encoding data type- Returns:
- server encoding data type
-
-