Package org.mariadb.jdbc.plugin.codec
Class ReaderCodec
- java.lang.Object
-
- org.mariadb.jdbc.plugin.codec.ReaderCodec
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.EnumSet<DataType>COMPATIBLE_TYPESstatic ReaderCodecINSTANCEdefault instance
-
Constructor Summary
Constructors Constructor Description ReaderCodec()
-
Method Summary
All Methods Instance Methods Concrete 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 typebooleancanEncodeLongData()Indicate if can encode long datajava.lang.StringclassName()Codec native typejava.io.ReaderdecodeBinary(ReadableByteBuf buf, MutableInt length, ColumnDecoder column, java.util.Calendar cal, Context context)Decode from a mysql packet binary encoded a value to codec java typejava.io.ReaderdecodeText(ReadableByteBuf buf, MutableInt length, 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 val, java.util.Calendar cal, java.lang.Long maxLength)Binary encode value to writerbyte[]encodeData(java.io.Reader reader, java.lang.Long maxLength)binary encoding value to a byte[]voidencodeLongData(Writer encoder, java.io.Reader reader, java.lang.Long maxLength)binary encoding value to a long data packetvoidencodeText(Writer encoder, Context context, java.lang.Object val, java.util.Calendar cal, java.lang.Long maxLen)Text encode value to writerintgetBinaryEncodeType()Return server encoding data type
-
-
-
Field Detail
-
INSTANCE
public static final ReaderCodec INSTANCE
default instance
-
COMPATIBLE_TYPES
private static final java.util.EnumSet<DataType> COMPATIBLE_TYPES
-
-
Method Detail
-
canDecode
public boolean canDecode(ColumnDecoder column, java.lang.Class<?> type)
Description copied from interface:CodecIf codec can decode this a server datatype to a java class type
-
className
public java.lang.String className()
Description copied from interface:CodecCodec native type
-
decodeText
public java.io.Reader decodeText(ReadableByteBuf buf, MutableInt length, ColumnDecoder column, java.util.Calendar cal, Context context) throws java.sql.SQLDataException
Description copied from interface:CodecDecode from a mysql packet text encoded a value to codec java type- Specified by:
decodeTextin interfaceCodec<java.io.Reader>- Parameters:
buf- mysql packet bufferlength- encoded value lengthcolumn- server column metadatacal- calendarcontext- connection context- Returns:
- decoded value
- Throws:
java.sql.SQLDataException- if unexpected error occurs during decoding
-
decodeBinary
public java.io.Reader decodeBinary(ReadableByteBuf buf, MutableInt length, ColumnDecoder column, java.util.Calendar cal, Context context) throws java.sql.SQLDataException
Description copied from interface:CodecDecode from a mysql packet binary encoded a value to codec java type- Specified by:
decodeBinaryin interfaceCodec<java.io.Reader>- Parameters:
buf- mysql packet bufferlength- encoded value lengthcolumn- server column metadatacal- calendarcontext- connection context- Returns:
- decoded value
- Throws:
java.sql.SQLDataException- if unexpected error occurs during decoding
-
canEncode
public boolean canEncode(java.lang.Object value)
Description copied from interface:CodecCan Codec encode the java object type
-
encodeText
public void encodeText(Writer encoder, Context context, java.lang.Object val, java.util.Calendar cal, java.lang.Long maxLen) throws java.io.IOException
Description copied from interface:CodecText encode value to writer- Specified by:
encodeTextin interfaceCodec<java.io.Reader>- Parameters:
encoder- writercontext- connection contextval- value to encodecal- calendarmaxLen- maximum value length- Throws:
java.io.IOException- if any socket error occurs
-
encodeBinary
public void encodeBinary(Writer encoder, Context context, java.lang.Object val, java.util.Calendar cal, java.lang.Long maxLength) throws java.io.IOException
Description copied from interface:CodecBinary encode value to writer- Specified by:
encodeBinaryin interfaceCodec<java.io.Reader>- Parameters:
encoder- writercontext- connection contextval- value to encodecal- calendarmaxLength- maximum value length- Throws:
java.io.IOException- if any socket error occurs
-
encodeLongData
public void encodeLongData(Writer encoder, java.io.Reader reader, java.lang.Long maxLength) throws java.io.IOException
Description copied from interface:Codecbinary encoding value to a long data packet- Specified by:
encodeLongDatain interfaceCodec<java.io.Reader>- Parameters:
encoder- writerreader- value to encodemaxLength- maximum length value- Throws:
java.io.IOException- if any socket error occurs
-
encodeData
public byte[] encodeData(java.io.Reader reader, java.lang.Long maxLength) throws java.io.IOExceptionDescription copied from interface:Codecbinary encoding value to a byte[]- Specified by:
encodeDatain interfaceCodec<java.io.Reader>- Parameters:
reader- value to encodemaxLength- maximum length value- Returns:
- encoded value
- Throws:
java.io.IOException- if any socket error occurs
-
getBinaryEncodeType
public int getBinaryEncodeType()
Description copied from interface:CodecReturn server encoding data type- Specified by:
getBinaryEncodeTypein interfaceCodec<java.io.Reader>- Returns:
- server encoding data type
-
canEncodeLongData
public boolean canEncodeLongData()
Description copied from interface:CodecIndicate if can encode long data- Specified by:
canEncodeLongDatain interfaceCodec<java.io.Reader>- Returns:
- true if possible
-
-