net.java.ao.types
Interface LogicalType<T>


public interface LogicalType<T>

Defines a logical type which can translate between one or more Java types and one or more JDBC types. This should be independent of the underlying database dialect.


Method Summary
 int getDefaultJdbcWriteType()
          Returns the default JDBC type to use when writing values to the database.
 com.google.common.collect.ImmutableSet<Integer> getJdbcReadTypes()
          Returns the set of JDBC types that can be translated into this logical type.
 String getName()
          Returns a descriptive name for this logical type.
 com.google.common.collect.ImmutableSet<Class<?>> getTypes()
          Returns the Java types that are handled by this logical type.
 boolean isAllowedAsPrimaryKey()
          Returns a boolean specifying if this type can be used as a primary key value.
 T parse(String input)
          Attempts to parse a string into a value of this logical type.
 T parseDefault(String input)
          Same as parse(String), but adds any necessary validation when the value is being used as a default value for a column.
 T pullFromDatabase(EntityManager manager, ResultSet res, Class<T> type, int columnIndex)
          Reads a value from a JDBC result set.
 T pullFromDatabase(EntityManager manager, ResultSet res, Class<T> type, String columnName)
          Reads a value from a JDBC result set.
 void putToDatabase(EntityManager manager, PreparedStatement stmt, int index, T value, int jdbcType)
          Sets a value in a JDBC statement.
 boolean shouldCache(Class<?> value)
           
 Object validate(Object value)
          Verifies that a value can be stored in the database.
 boolean valueEquals(Object val1, Object val2)
           
 String valueToString(T value)
           
 

Method Detail

getName

String getName()
Returns a descriptive name for this logical type.


getTypes

com.google.common.collect.ImmutableSet<Class<?>> getTypes()
Returns the Java types that are handled by this logical type. Only one logical type can handle any given Java type.


getJdbcReadTypes

com.google.common.collect.ImmutableSet<Integer> getJdbcReadTypes()
Returns the set of JDBC types that can be translated into this logical type.


getDefaultJdbcWriteType

int getDefaultJdbcWriteType()
Returns the default JDBC type to use when writing values to the database. This can be overridden by each database provider in the SchemaProperties.


isAllowedAsPrimaryKey

boolean isAllowedAsPrimaryKey()
Returns a boolean specifying if this type can be used as a primary key value.

Returns:
if it's allowed or not

parse

T parse(String input)
        throws IllegalArgumentException
Attempts to parse a string into a value of this logical type.

Throws:
IllegalArgumentException

parseDefault

T parseDefault(String input)
               throws IllegalArgumentException
Same as parse(String), but adds any necessary validation when the value is being used as a default value for a column.

Throws:
IllegalArgumentException

validate

Object validate(Object value)
                throws IllegalArgumentException
Verifies that a value can be stored in the database. Returns the same value or a canonically equivalent value.

Throws:
IllegalArgumentException

putToDatabase

void putToDatabase(EntityManager manager,
                   PreparedStatement stmt,
                   int index,
                   T value,
                   int jdbcType)
                   throws SQLException
Sets a value in a JDBC statement.

Throws:
SQLException

pullFromDatabase

T pullFromDatabase(EntityManager manager,
                   ResultSet res,
                   Class<T> type,
                   String columnName)
                   throws SQLException
Reads a value from a JDBC result set.

Throws:
SQLException

pullFromDatabase

T pullFromDatabase(EntityManager manager,
                   ResultSet res,
                   Class<T> type,
                   int columnIndex)
                   throws SQLException
Reads a value from a JDBC result set.

Throws:
SQLException

shouldCache

boolean shouldCache(Class<?> value)

valueEquals

boolean valueEquals(Object val1,
                    Object val2)

valueToString

String valueToString(T value)


Copyright © 2007-2013. All Rights Reserved.