Class LocalDateCodec

java.lang.Object
org.mariadb.jdbc.plugin.codec.LocalDateCodec
All Implemented Interfaces:
Codec<LocalDate>

public class LocalDateCodec extends Object implements Codec<LocalDate>
LocalDate codec
  • Field Details

    • INSTANCE

      public static final LocalDateCodec INSTANCE
      default instance
    • COMPATIBLE_TYPES

      private static final EnumSet<DataType> COMPATIBLE_TYPES
  • Constructor Details

    • LocalDateCodec

      public LocalDateCodec()
  • Method Details

    • parseDate

      public static int[] parseDate(ReadableByteBuf buf, MutableInt length)
      Parse text encoded Date
      Parameters:
      buf - packet buffer
      length - data length
      Returns:
      date/month/year array
    • localDateOf

      static LocalDate localDateOf(int year, int month, int dayOfMonth) throws SQLDataException
      LocalDate from server values, or SQLDataException when they cannot be represented (zero day or month, permitted by the server when sql_mode doesn't contain NO_ZERO_IN_DATE).
      Parameters:
      year - year
      month - month
      dayOfMonth - day of month
      Returns:
      LocalDate
      Throws:
      SQLDataException - if the value is not a valid date
    • className

      public String className()
      Description copied from interface: Codec
      Codec native type
      Specified by:
      className in interface Codec<LocalDate>
      Returns:
      code native return type
    • canDecode

      public boolean canDecode(ColumnDecoder column, Class<?> type)
      Description copied from interface: Codec
      If codec can decode this a server datatype to a java class type
      Specified by:
      canDecode in interface Codec<LocalDate>
      Parameters:
      column - server datatype
      type - java return class
      Returns:
      true if codec can decode it
    • canEncode

      public boolean canEncode(Object value)
      Description copied from interface: Codec
      Can Codec encode the java object type
      Specified by:
      canEncode in interface Codec<LocalDate>
      Parameters:
      value - java object type
      Returns:
      true if codec can encode java type
    • decodeText

      public LocalDate decodeText(ReadableByteBuf buf, MutableInt length, ColumnDecoder column, Calendar cal, Context context) throws SQLDataException
      Description copied from interface: Codec
      Decode from a mysql packet text encoded a value to codec java type
      Specified by:
      decodeText in interface Codec<LocalDate>
      Parameters:
      buf - mysql packet buffer
      length - encoded value length
      column - server column metadata
      cal - calendar
      context - connection context
      Returns:
      decoded value
      Throws:
      SQLDataException - if unexpected error occurs during decoding
    • decodeBinary

      public LocalDate decodeBinary(ReadableByteBuf buf, MutableInt length, ColumnDecoder column, Calendar cal, Context context) throws SQLDataException
      Description copied from interface: Codec
      Decode from a mysql packet binary encoded a value to codec java type
      Specified by:
      decodeBinary in interface Codec<LocalDate>
      Parameters:
      buf - mysql packet buffer
      length - encoded value length
      column - server column metadata
      cal - calendar
      context - connection context
      Returns:
      decoded value
      Throws:
      SQLDataException - if unexpected error occurs during decoding
    • encodeText

      public void encodeText(Writer encoder, Context context, LocalDate val, Calendar cal, Long maxLen) throws IOException
      Description copied from interface: Codec
      Text encode value to writer
      Specified by:
      encodeText in interface Codec<LocalDate>
      Parameters:
      encoder - writer
      context - connection context
      val - value to encode
      cal - calendar
      maxLen - maximum value length
      Throws:
      IOException - if any socket error occurs
    • getApproximateTextProtocolLength

      public int getApproximateTextProtocolLength(LocalDate value, Long length)
      Description copied from interface: Codec
      Get approximate text length, or -1 if unknown
      Specified by:
      getApproximateTextProtocolLength in interface Codec<LocalDate>
      Parameters:
      value - parameter object
      length - max length
      Returns:
      max length if known, -1 if unknown
    • encodeBinary

      public void encodeBinary(Writer encoder, Context context, LocalDate value, Calendar providedCal, Long maxLength) throws IOException
      Description copied from interface: Codec
      Binary encode value to writer
      Specified by:
      encodeBinary in interface Codec<LocalDate>
      Parameters:
      encoder - writer
      context - connection context
      value - value to encode
      providedCal - calendar
      maxLength - maximum value length
      Throws:
      IOException - if any socket error occurs
    • getBinaryEncodeType

      public int getBinaryEncodeType()
      Description copied from interface: Codec
      Return server encoding data type
      Specified by:
      getBinaryEncodeType in interface Codec<LocalDate>
      Returns:
      server encoding data type