Package io.vertx.jdbcclient.spi
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 JDBCDecoderImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
cast(Object value)
Try cast SQL value to standard Java value depends on standard JDBC 4.2 type mapping and compatible with VertxObject
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 typeprotected 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 fromJDBCTypeWrapper.isBinaryType()
datatype toBuffer
.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 timeprotected Object
decodeLink(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
Convert a value fromJDBCType.DATALINK
datatype toURL
protected Object
decodeNumber(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
Convert a value from Number JDBCType to Numberprotected Object
decodeSpecificVendorType(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
Convert a value from thespecific SQL vendor data type
toJava
valueprotected Object
decodeStruct(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
Convert a value fromJDBCType.STRUCT
datatype toTuple
protected Object
decodeUnhandledType(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
Convert a value from the unhandled data typeprotected Object
decodeXML(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)
Convert a value fromJDBCType.SQLXML
datatype toBuffer
protected Object
getCoerceObject(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, Class<?> cls)
Object
parse(CallableStatement cs, int pos, JDBCColumnDescriptorProvider jdbcTypeLookup)
Parse SQL value to Java valueObject
parse(ResultSet rs, int pos, JDBCColumnDescriptorProvider jdbcTypeLookup)
Parse SQL value to Java valueprotected Buffer
streamToBuffer(InputStream is, Class<?> dataTypeClass)
-
-
-
Method Detail
-
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 interfaceJDBCDecoder
- Parameters:
rs
- JDBC result setpos
- the Database column positionjdbcTypeLookup
- JDBCType provider- Returns:
- java value
- Throws:
SQLException
- if any error in parsing- See Also:
ResultSet
,JDBCColumnDescriptorProvider
-
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 interfaceJDBCDecoder
- Parameters:
cs
- JDBC callable statementpos
- the parameter column positionjdbcTypeLookup
- JDBCType provider- Returns:
- java value
- Throws:
SQLException
- if any error in parsing- See Also:
CallableStatement
,JDBCColumnDescriptorProvider
-
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 interfaceJDBCDecoder
- Parameters:
descriptor
- the JDBC column descriptorvalueProvider
- 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 VertxFor example: - java.sql.Time -> java.time.LocalTime - java.sql.Timestamp -> java.time.LocalDateTime
- Specified by:
cast
in interfaceJDBCDecoder
- 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 fromJDBCTypeWrapper.isBinaryType()
datatype toBuffer
.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 fromJDBCType.STRUCT
datatype toTuple
Fallback to
decodeUnhandledType(SQLValueProvider, JDBCColumnDescriptor)
if the actual value's type is notStruct
- 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 fromJDBCType.DATALINK
datatype toURL
Keep value as it is if the actual value's type is not
URL
orString
- 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 fromJDBCType.SQLXML
datatype toBuffer
Fallback to
decodeUnhandledType(SQLValueProvider, JDBCColumnDescriptor)
} if the actual value's type is notSQLXML
- 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 typeThe 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 thespecific SQL vendor data type
toJava
valueThe 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
-
-