Package org.h2.value
Class ValueToObjectConverter
- java.lang.Object
-
- org.h2.message.TraceObject
-
- org.h2.value.ValueToObjectConverter
-
public final class ValueToObjectConverter extends TraceObject
Data type conversion methods between values and Java objects.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.Class<?>
GEOMETRY_CLASS
The Geometry class.private static java.lang.String
GEOMETRY_CLASS_NAME
-
Fields inherited from class org.h2.message.TraceObject
ARRAY, BLOB, CALLABLE_STATEMENT, CLOB, CONNECTION, DATA_SOURCE, DATABASE_META_DATA, PARAMETER_META_DATA, PREPARED_STATEMENT, RESULT_SET, RESULT_SET_META_DATA, SAVEPOINT, SQLXML, STATEMENT, trace, XA_DATA_SOURCE, XID
-
-
Constructor Summary
Constructors Modifier Constructor Description private
ValueToObjectConverter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static Value
arrayToValue(Session session, java.lang.Object x)
static java.lang.Class<?>
getDefaultClass(int type, boolean forJdbc)
Get the name of the Java class for the given value type.static Value
objectToValue(Session session, java.lang.Object x, int type)
Convert a Java object to a value.private static Value
otherToValue(Session session, java.lang.Object x)
private static java.util.LinkedHashMap<java.lang.String,TypeInfo>
readResultSetMeta(Session session, java.sql.ResultSetMetaData meta, int columnCount)
static Value
readValue(Session session, JdbcResultSet rs, int columnIndex)
Read a value from the given result set.(package private) static Value
resultSetToValue(Session session, java.sql.ResultSet rs)
private static java.lang.Object
valueToArray(java.lang.Class<?> type, Value value, JdbcConnection conn)
static java.lang.Object
valueToDefaultArray(Value value, JdbcConnection conn, boolean forJdbc)
Converts the specified array value to array of default Java objects for its type.static java.lang.Object
valueToDefaultObject(Value value, JdbcConnection conn, boolean forJdbc)
Converts the specified value to the default Java object for its type.static <T> T
valueToObject(java.lang.Class<T> type, Value value, JdbcConnection conn)
Converts the specified value to an object of the specified type.private static java.lang.Object
valueToOther(java.lang.Class<?> type, Value value, JdbcConnection conn)
-
Methods inherited from class org.h2.message.TraceObject
debugCode, debugCodeAssign, debugCodeCall, debugCodeCall, debugCodeCall, getNextId, getTraceId, getTraceObjectName, isDebugEnabled, isInfoEnabled, logAndConvert, quote, quoteArray, quoteBigDecimal, quoteBytes, quoteDate, quoteIntArray, quoteMap, quoteTime, quoteTimestamp, setTrace, unsupported
-
-
-
-
Field Detail
-
GEOMETRY_CLASS
public static final java.lang.Class<?> GEOMETRY_CLASS
The Geometry class. This object is null if the JTS jar file is not in the classpath.
-
GEOMETRY_CLASS_NAME
private static final java.lang.String GEOMETRY_CLASS_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
objectToValue
public static Value objectToValue(Session session, java.lang.Object x, int type)
Convert a Java object to a value.- Parameters:
session
- the sessionx
- the valuetype
- the suggested value type, orValue#UNKNOWN
- Returns:
- the value
-
readResultSetMeta
private static java.util.LinkedHashMap<java.lang.String,TypeInfo> readResultSetMeta(Session session, java.sql.ResultSetMetaData meta, int columnCount) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
valueToObject
public static <T> T valueToObject(java.lang.Class<T> type, Value value, JdbcConnection conn)
Converts the specified value to an object of the specified type.- Type Parameters:
T
- the type- Parameters:
type
- the classvalue
- the valueconn
- the connection- Returns:
- the object of the specified class representing the specified
value, or
null
-
valueToArray
private static java.lang.Object valueToArray(java.lang.Class<?> type, Value value, JdbcConnection conn)
-
valueToOther
private static java.lang.Object valueToOther(java.lang.Class<?> type, Value value, JdbcConnection conn)
-
getDefaultClass
public static java.lang.Class<?> getDefaultClass(int type, boolean forJdbc)
Get the name of the Java class for the given value type.- Parameters:
type
- the value typeforJdbc
- iftrue
get class for JDBC layer, iffalse
get class for Java functions API- Returns:
- the class
-
valueToDefaultObject
public static java.lang.Object valueToDefaultObject(Value value, JdbcConnection conn, boolean forJdbc)
Converts the specified value to the default Java object for its type.- Parameters:
value
- the valueconn
- the connectionforJdbc
- iftrue
perform conversion for JDBC layer, iffalse
perform conversion for Java functions API- Returns:
- the object
-
valueToDefaultArray
public static java.lang.Object valueToDefaultArray(Value value, JdbcConnection conn, boolean forJdbc)
Converts the specified array value to array of default Java objects for its type.- Parameters:
value
- the array valueconn
- the connectionforJdbc
- iftrue
perform conversion for JDBC layer, iffalse
perform conversion for Java functions API- Returns:
- the object
-
readValue
public static Value readValue(Session session, JdbcResultSet rs, int columnIndex)
Read a value from the given result set.- Parameters:
session
- the sessionrs
- the result setcolumnIndex
- the column index (1-based)- Returns:
- the value
-
-