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 Objectcast(Object value)Try cast SQL value to standard Java value depends on standard JDBC 4.2 type mapping and compatible with VertxObjectdecode(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 ObjectdecodeArray(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)protected ObjectdecodeArray(Array value, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor baseType)protected ObjectdecodeBinary(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)Convert a value fromJDBCTypeWrapper.isBinaryType()datatype toBuffer.protected ObjectdecodeDateTime(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 ObjectdecodeLink(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)Convert a value fromJDBCType.DATALINKdatatype toURLprotected ObjectdecodeNumber(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)Convert a value from Number JDBCType to Numberprotected ObjectdecodeSpecificVendorType(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)Convert a value from thespecific SQL vendor data typetoJavavalueprotected ObjectdecodeStruct(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)Convert a value fromJDBCType.STRUCTdatatype toTupleprotected ObjectdecodeUnhandledType(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)Convert a value from the unhandled data typeprotected ObjectdecodeXML(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, io.vertx.jdbcclient.impl.actions.JDBCColumnDescriptor descriptor)Convert a value fromJDBCType.SQLXMLdatatype toBufferprotected ObjectgetCoerceObject(io.vertx.jdbcclient.impl.actions.SQLValueProvider valueProvider, Class<?> cls)Objectparse(CallableStatement cs, int pos, JDBCColumnDescriptorProvider jdbcTypeLookup)Parse SQL value to Java valueObjectparse(ResultSet rs, int pos, JDBCColumnDescriptorProvider jdbcTypeLookup)Parse SQL value to Java valueprotected BufferstreamToBuffer(InputStream is, Class<?> dataTypeClass)
-
-
-
Method Detail
-
parse
public Object parse(ResultSet rs, int pos, JDBCColumnDescriptorProvider jdbcTypeLookup) throws SQLException
Description copied from interface:JDBCDecoderParse SQL value to Java value- Specified by:
parsein 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:JDBCDecoderParse SQL value to Java value- Specified by:
parsein 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:JDBCDecoderConvert the SQL value to Java value based on jdbc type- Specified by:
decodein 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:JDBCDecoderTry 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:
castin 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.STRUCTdatatype toTupleFallback 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.DATALINKdatatype toURLKeep value as it is if the actual value's type is not
URLorString- 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.SQLXMLdatatype toBufferFallback 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 typetoJavavalueThe 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
-
-