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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description booleancanDecode(ColumnDecoder column, java.lang.Class<?> type)If codec can decode this a server datatype to a java class typebooleancanEncode(java.lang.Object value)Can Codec encode the java object typedefault booleancanEncodeLongData()Indicate if can encode long datajava.lang.StringclassName()Codec native typeTdecodeBinary(ReadableByteBuf buffer, MutableInt fieldLength, ColumnDecoder column, java.util.Calendar cal, Context context)Decode from a mysql packet binary encoded a value to codec java typeTdecodeText(ReadableByteBuf buffer, MutableInt fieldLength, ColumnDecoder column, java.util.Calendar cal, Context context)Decode from a mysql packet text encoded a value to codec java typevoidencodeBinary(Writer encoder, Context context, java.lang.Object value, java.util.Calendar cal, java.lang.Long length)Binary encode value to writerdefault byte[]encodeData(T value, java.lang.Long length)binary encoding value to a byte[]default voidencodeLongData(Writer encoder, T value, java.lang.Long length)binary encoding value to a long data packetvoidencodeText(Writer encoder, Context context, java.lang.Object value, java.util.Calendar cal, java.lang.Long length)Text encode value to writerintgetBinaryEncodeType()Return server encoding data type
-
-
-
Method Detail
-
className
java.lang.String className()
Codec native type- Returns:
- code native return type
-
canDecode
boolean canDecode(ColumnDecoder column, java.lang.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(java.lang.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(ReadableByteBuf buffer, MutableInt fieldLength, ColumnDecoder column, java.util.Calendar cal, Context context) throws java.sql.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:
java.sql.SQLDataException- if unexpected error occurs during decoding
-
decodeBinary
T decodeBinary(ReadableByteBuf buffer, MutableInt fieldLength, ColumnDecoder column, java.util.Calendar cal, Context context) throws java.sql.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:
java.sql.SQLDataException- if unexpected error occurs during decoding
-
encodeText
void encodeText(Writer encoder, Context context, java.lang.Object value, java.util.Calendar cal, java.lang.Long length) throws java.io.IOException, java.sql.SQLException
Text encode value to writer- Parameters:
encoder- writercontext- connection contextvalue- value to encodecal- calendarlength- maximum value length- Throws:
java.io.IOException- if any socket error occursjava.sql.SQLException- if encoding error occurs
-
encodeBinary
void encodeBinary(Writer encoder, Context context, java.lang.Object value, java.util.Calendar cal, java.lang.Long length) throws java.io.IOException, java.sql.SQLException
Binary encode value to writer- Parameters:
encoder- writercontext- connection contextvalue- value to encodecal- calendarlength- maximum value length- Throws:
java.io.IOException- if any socket error occursjava.sql.SQLException- 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, java.lang.Long length) throws java.io.IOException, java.sql.SQLException
binary encoding value to a long data packet- Parameters:
encoder- writervalue- value to encodelength- maximum length value- Throws:
java.io.IOException- if any socket error occursjava.sql.SQLException- if encoding error occurs
-
encodeData
default byte[] encodeData(T value, java.lang.Long length) throws java.io.IOException, java.sql.SQLException
binary encoding value to a byte[]- Parameters:
value- value to encodelength- maximum length value- Returns:
- encoded value
- Throws:
java.io.IOException- if any socket error occursjava.sql.SQLException- if encoding error occurs
-
getBinaryEncodeType
int getBinaryEncodeType()
Return server encoding data type- Returns:
- server encoding data type
-
-