Package org.apache.ofbiz.entity.jdbc
Class JdbcValueHandler<T>
- java.lang.Object
-
- org.apache.ofbiz.entity.jdbc.JdbcValueHandler<T>
-
- Direct Known Subclasses:
JdbcValueHandler.ArrayJdbcValueHandler
,JdbcValueHandler.BigDecimalJdbcValueHandler
,JdbcValueHandler.BlobJdbcValueHandler
,JdbcValueHandler.BooleanJdbcValueHandler
,JdbcValueHandler.ByteArrayJdbcValueHandler
,JdbcValueHandler.ClobJdbcValueHandler
,JdbcValueHandler.DateJdbcValueHandler
,JdbcValueHandler.DoubleJdbcValueHandler
,JdbcValueHandler.FloatJdbcValueHandler
,JdbcValueHandler.IntegerJdbcValueHandler
,JdbcValueHandler.LongJdbcValueHandler
,JdbcValueHandler.ObjectJdbcValueHandler
,JdbcValueHandler.RowIdJdbcValueHandler
,JdbcValueHandler.ShortJdbcValueHandler
,JdbcValueHandler.StringJdbcValueHandler
,JdbcValueHandler.TimeJdbcValueHandler
,JdbcValueHandler.TimestampJdbcValueHandler
public abstract class JdbcValueHandler<T> extends java.lang.Object
An object that handles getting/setting column values in JDBCPreparedStatement
andResultSet
objects.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
JdbcValueHandler.ArrayJdbcValueHandler
Ajava.sql.Array
JDBC value handler.protected static class
JdbcValueHandler.BigDecimalJdbcValueHandler
Ajava.math.BigDecimal
JDBC value handler.protected static class
JdbcValueHandler.BlobJdbcValueHandler
Ajava.sql.Blob
JDBC value handler.protected static class
JdbcValueHandler.BooleanJdbcValueHandler
Ajava.lang.Boolean
JDBC value handler.protected static class
JdbcValueHandler.ByteArrayJdbcValueHandler
Abyte[]
JDBC value handler.protected static class
JdbcValueHandler.ClobJdbcValueHandler
Ajava.sql.Clob
JDBC value handler.protected static class
JdbcValueHandler.DateJdbcValueHandler
Ajava.sql.Date
JDBC value handler.protected static class
JdbcValueHandler.DoubleJdbcValueHandler
Ajava.lang.Double
JDBC value handler.protected static class
JdbcValueHandler.FloatJdbcValueHandler
Ajava.lang.Float
JDBC value handler.protected static class
JdbcValueHandler.IntegerJdbcValueHandler
Ajava.lang.Integer
JDBC value handler.protected static class
JdbcValueHandler.LongJdbcValueHandler
Ajava.lang.Long
JDBC value handler.protected static class
JdbcValueHandler.ObjectJdbcValueHandler
Ajava.lang.Object
JDBC value handler.protected static class
JdbcValueHandler.RowIdJdbcValueHandler
Ajava.sql.RowId
JDBC value handler.protected static class
JdbcValueHandler.ShortJdbcValueHandler
Ajava.lang.Short
JDBC value handler.protected static class
JdbcValueHandler.StringJdbcValueHandler
Ajava.lang.String
JDBC value handler.protected static class
JdbcValueHandler.TimeJdbcValueHandler
Ajava.sql.Time
JDBC value handler.protected static class
JdbcValueHandler.TimestampJdbcValueHandler
Ajava.sql.Timestamp
JDBC value handler.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
module
-
Constructor Summary
Constructors Modifier Constructor Description protected
JdbcValueHandler(int sqlType)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
castAndSetValue(java.sql.PreparedStatement ps, int parameterIndex, T obj)
Sets a value in aPreparedStatement
.protected JdbcValueHandler<T>
create(int sqlType)
static JdbcValueHandler<?>
getInstance(java.lang.String javaType, java.lang.String sqlType)
Returns theJdbcValueHandler
that corresponds to a field type.abstract java.lang.Class<T>
getJavaClass()
int
getSqlType()
Returns the SQL type for this handler.abstract T
getValue(java.sql.ResultSet rs, int columnIndex)
Returns a value from aResultSet
.protected abstract JdbcValueHandler<T>
newInstance(int sqlType)
Returns a new instance of the object - initialized with the specified SQL type.protected static java.lang.String
parseSqlType(java.lang.String sqlType)
protected static byte[]
serializeObject(java.lang.Object obj)
void
setValue(java.sql.PreparedStatement ps, int parameterIndex, T obj)
Sets a value in aPreparedStatement
.
-
-
-
Method Detail
-
getInstance
public static JdbcValueHandler<?> getInstance(java.lang.String javaType, java.lang.String sqlType)
Returns theJdbcValueHandler
that corresponds to a field type.- Parameters:
javaType
- The Java type specified in fieldtype*.xmlsqlType
- The SQL type specified in fieldtype*.xml- Returns:
- A
JdbcValueHandler
instance
-
parseSqlType
protected static java.lang.String parseSqlType(java.lang.String sqlType)
-
serializeObject
protected static byte[] serializeObject(java.lang.Object obj) throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
castAndSetValue
protected abstract void castAndSetValue(java.sql.PreparedStatement ps, int parameterIndex, T obj) throws java.sql.SQLException
Sets a value in aPreparedStatement
. Theobj
argument is converted to the correct data type. Subclasses override this method to castobj
to the correct data type and call the appropriatePreparedStatement.setXxx
method.- Parameters:
ps
-parameterIndex
-obj
-- Throws:
java.sql.SQLException
-
create
protected JdbcValueHandler<T> create(int sqlType)
-
getSqlType
public int getSqlType()
Returns the SQL type for this handler.- Returns:
- return the SQL type
- See Also:
java.sql.Types
-
getValue
public abstract T getValue(java.sql.ResultSet rs, int columnIndex) throws java.sql.SQLException
Returns a value from aResultSet
. The returned object is converted to the Java data type specified in the fieldtype file.- Parameters:
rs
- the ResultSet objectcolumnIndex
- the column index- Returns:
- get value from result set
- Throws:
java.sql.SQLException
-
newInstance
protected abstract JdbcValueHandler<T> newInstance(int sqlType)
Returns a new instance of the object - initialized with the specified SQL type.- Parameters:
sqlType
- the sql type- Returns:
- returns a new instance
-
getJavaClass
public abstract java.lang.Class<T> getJavaClass()
-
setValue
public void setValue(java.sql.PreparedStatement ps, int parameterIndex, T obj) throws java.sql.SQLException
Sets a value in aPreparedStatement
. Theobj
argument is converted to the correct data type.- Parameters:
ps
-parameterIndex
-obj
-- Throws:
java.sql.SQLException
-
-