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,FloatArrayCodec,FloatCodec,FloatObjectArrayCodec,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
Modifier and TypeMethodDescriptionbooleanIf codec can decode this a server datatype to a java class typebooleanCan Codec encode the java object typedefault booleanIndicate if can encode long dataCodec native typedecodeBinary(org.mariadb.jdbc.client.ReadableByteBuf buffer, MutableInt fieldLength, org.mariadb.jdbc.client.ColumnDecoder column, Calendar cal, org.mariadb.jdbc.client.Context context) Decode from a mysql packet binary encoded a value to codec java typedecodeText(org.mariadb.jdbc.client.ReadableByteBuf buffer, MutableInt fieldLength, org.mariadb.jdbc.client.ColumnDecoder column, Calendar cal, org.mariadb.jdbc.client.Context context) Decode from a mysql packet text encoded a value to codec java typevoidencodeBinary(Writer encoder, org.mariadb.jdbc.client.Context context, 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 writerintReturn server encoding data type
-
Method Details
-
className
String className()Codec native type- Returns:
- code native return type
-
canDecode
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
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, org.mariadb.jdbc.client.Context context) 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- calendarcontext- connection context- 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, org.mariadb.jdbc.client.Context context) 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- calendarcontext- connection context- 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, org.mariadb.jdbc.client.Context context, Object value, Calendar cal, Long length) throws IOException, SQLException Binary 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
-
canEncodeLongData
default boolean canEncodeLongData()Indicate if can encode long data- Returns:
- true if possible
-
encodeLongData
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
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
-