Class JDBCDecoderImpl

java.lang.Object
io.vertx.jdbcclient.spi.JDBCDecoderImpl
All Implemented Interfaces:
JDBCDecoder

public class JDBCDecoderImpl extends Object implements JDBCDecoder
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    cast(Object value)
    Try cast SQL value to standard Java value depends on standard JDBC 4.2 type mapping and compatible with Vertx
    decode(io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor, io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider)
    Convert the SQL value to Java value based on jdbc type
    protected Object
    decodeArray(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
     
    protected Object
    decodeArray(Array value, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor baseType)
     
    protected Object
    decodeBinary(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
    Convert a value from JDBCTypeWrapper.isBinaryType() datatype to Buffer.
    protected Object
    decodeDateTime(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
    Convert a value from date time JDBCType to Java date time
    protected Object
    decodeLink(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
    Convert a value from JDBCType.DATALINK datatype to URL
    protected Object
    decodeNumber(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
    Convert a value from Number JDBCType to Number
    protected Object
    decodeSpecificVendorType(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
    Convert a value from the specific SQL vendor data type to Java value
    protected Object
    decodeStruct(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
    Convert a value from JDBCType.STRUCT datatype to Tuple
    protected Object
    decodeUnhandledType(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
    Convert a value from the unhandled data type
    protected Object
    decodeXML(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
    Convert a value from JDBCType.SQLXML datatype to Buffer
    protected Object
    getCoerceObject(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, Class<?> cls)
     
    parse(CallableStatement cs, int pos, JDBCColumnDescriptorProvider jdbcTypeLookup)
    Parse SQL value to Java value
    parse(ResultSet rs, int pos, JDBCColumnDescriptorProvider jdbcTypeLookup)
    Parse SQL value to Java value
    protected String
    readerToString(Reader reader, Class<?> dataTypeClass)
     
    protected Buffer
    streamToBuffer(InputStream is, Class<?> dataTypeClass)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JDBCDecoderImpl

      public JDBCDecoderImpl()
  • Method Details

    • parse

      public Object parse(ResultSet rs, int pos, JDBCColumnDescriptorProvider jdbcTypeLookup) throws SQLException
      Description copied from interface: JDBCDecoder
      Parse SQL value to Java value
      Specified by:
      parse in interface JDBCDecoder
      Parameters:
      rs - JDBC result set
      pos - the Database column position
      jdbcTypeLookup - JDBCType provider
      Returns:
      java value
      Throws:
      SQLException - if any error in parsing
      See Also:
    • parse

      public Object parse(CallableStatement cs, int pos, JDBCColumnDescriptorProvider jdbcTypeLookup) throws SQLException
      Description copied from interface: JDBCDecoder
      Parse SQL value to Java value
      Specified by:
      parse in interface JDBCDecoder
      Parameters:
      cs - JDBC callable statement
      pos - the parameter column position
      jdbcTypeLookup - JDBCType provider
      Returns:
      java value
      Throws:
      SQLException - if any error in parsing
      See Also:
    • decode

      public Object decode(io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor, io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider) throws SQLException
      Description copied from interface: JDBCDecoder
      Convert the SQL value to Java value based on jdbc type
      Specified by:
      decode in interface JDBCDecoder
      Parameters:
      descriptor - the JDBC column descriptor
      valueProvider - the value provider
      Returns:
      java value
      Throws:
      SQLException
      See Also:
      • SQLValueProvider
      • JDBCColumnDescriptor
    • cast

      public Object cast(Object value) throws SQLException
      Description copied from interface: JDBCDecoder
      Try cast SQL value to standard Java value depends on standard JDBC 4.2 type mapping and compatible with Vertx

      For example: - java.sql.Time -> java.time.LocalTime - java.sql.Timestamp -> java.time.LocalDateTime

      Specified by:
      cast in interface JDBCDecoder
      Parameters:
      value - value
      Returns:
      a presenter value
      Throws:
      SQLException - if any error when casting
    • decodeArray

      protected Object decodeArray(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor) throws SQLException
      Throws:
      SQLException
    • decodeDateTime

      protected Object decodeDateTime(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor) throws SQLException
      Convert a value from date time JDBCType to Java date time
      Throws:
      SQLException
      See Also:
      • JDBCTypeWrapper.isDateTimeType()
    • decodeNumber

      protected Object decodeNumber(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor) throws SQLException
      Convert a value from Number JDBCType to Number
      Throws:
      SQLException
      See Also:
      • JDBCTypeWrapper.isNumberType()
    • decodeBinary

      protected Object decodeBinary(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor) throws SQLException
      Convert a value from JDBCTypeWrapper.isBinaryType() datatype to Buffer.

      Keep value as it is if the actual value's type is not byte[]

      Throws:
      SQLException
      See Also:
      • JDBCTypeWrapper.isBinaryType()
    • decodeStruct

      protected Object decodeStruct(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor) throws SQLException
      Convert a value from JDBCType.STRUCT datatype to Tuple

      Fallback to decodeUnhandledType(SQLValueProvider, JDBCColumnDescriptor) if the actual value's type is not Struct

      Throws:
      SQLException
    • decodeLink

      protected Object decodeLink(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor) throws SQLException
      Convert a value from JDBCType.DATALINK datatype to URL

      Keep value as it is if the actual value's type is not URL or String

      Throws:
      SQLException
    • decodeXML

      protected Object decodeXML(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor) throws SQLException
      Convert a value from JDBCType.SQLXML datatype to Buffer

      Fallback to decodeUnhandledType(SQLValueProvider, JDBCColumnDescriptor)} if the actual value's type is not SQLXML

      Throws:
      SQLException
    • decodeUnhandledType

      protected Object decodeUnhandledType(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor) throws SQLException
      Convert a value from the unhandled data type

      The default implementation converts any data type to a string value

      Returns:
      value
      Throws:
      SQLException
      See Also:
      • JDBCTypeWrapper.isUnhandledType()
    • decodeSpecificVendorType

      protected Object decodeSpecificVendorType(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor) throws SQLException
      Convert a value from the specific SQL vendor data type to Java value

      The default implementation converts any data type to a string value

      Returns:
      value
      Throws:
      SQLException
      See Also:
      • JDBCTypeWrapper.isSpecificVendorType()
    • decodeArray

      protected Object decodeArray(Array value, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor baseType) throws SQLException
      Throws:
      SQLException
    • getCoerceObject

      protected Object getCoerceObject(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, Class<?> cls) throws SQLException
      Throws:
      SQLException
    • streamToBuffer

      protected Buffer streamToBuffer(InputStream is, Class<?> dataTypeClass) throws SQLException
      Throws:
      SQLException
    • readerToString

      protected String readerToString(Reader reader, Class<?> dataTypeClass) throws SQLException
      Throws:
      SQLException