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 Details

    • GEOMETRY_CLASS

      public static final 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 String GEOMETRY_CLASS_NAME
      See Also:
  • Constructor Details

    • ValueToObjectConverter

      private ValueToObjectConverter()
  • Method Details

    • objectToValue

      public static Value objectToValue(Session session, Object x, int type)
      Convert a Java object to a value.
      Parameters:
      session - the session
      x - the value
      type - the suggested value type, or Value#UNKNOWN
      Returns:
      the value
    • otherToValue

      private static Value otherToValue(Session session, Object x)
    • arrayToValue

      private static Value arrayToValue(Session session, Object x)
    • resultSetToValue

      static Value resultSetToValue(Session session, ResultSet rs)
    • readResultSetMeta

      private static LinkedHashMap<String,TypeInfo> readResultSetMeta(Session session, ResultSetMetaData meta, int columnCount) throws SQLException
      Throws:
      SQLException
    • valueToObject

      public static <T> T valueToObject(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 class
      value - the value
      conn - the connection
      Returns:
      the object of the specified class representing the specified value, or null
    • valueToArray

      private static Object valueToArray(Class<?> type, Value value, JdbcConnection conn)
    • valueToOther

      private static Object valueToOther(Class<?> type, Value value, JdbcConnection conn)
    • getDefaultClass

      public static Class<?> getDefaultClass(int type, boolean forJdbc)
      Get the name of the Java class for the given value type.
      Parameters:
      type - the value type
      forJdbc - if true get class for JDBC layer, if false get class for Java functions API
      Returns:
      the class
    • valueToDefaultObject

      public static Object valueToDefaultObject(Value value, JdbcConnection conn, boolean forJdbc)
      Converts the specified value to the default Java object for its type.
      Parameters:
      value - the value
      conn - the connection
      forJdbc - if true perform conversion for JDBC layer, if false perform conversion for Java functions API
      Returns:
      the object
    • valueToDefaultArray

      public static 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 value
      conn - the connection
      forJdbc - if true perform conversion for JDBC layer, if false 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 session
      rs - the result set
      columnIndex - the column index (1-based)
      Returns:
      the value