Class JdbcValueHandler<T>

    • Field Detail

      • module

        public static final java.lang.String module
    • Constructor Detail

      • JdbcValueHandler

        protected JdbcValueHandler​(int sqlType)
    • Method Detail

      • getInstance

        public static JdbcValueHandler<?> getInstance​(java.lang.String javaType,
                                                      java.lang.String sqlType)
        Returns the JdbcValueHandler that corresponds to a field type.
        Parameters:
        javaType - The Java type specified in fieldtype*.xml
        sqlType - 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 a PreparedStatement. The obj argument is converted to the correct data type. Subclasses override this method to cast obj to the correct data type and call the appropriate PreparedStatement.setXxx method.
        Parameters:
        ps -
        parameterIndex -
        obj -
        Throws:
        java.sql.SQLException
      • 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 a ResultSet. The returned object is converted to the Java data type specified in the fieldtype file.
        Parameters:
        rs - the ResultSet object
        columnIndex - 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 a PreparedStatement. The obj argument is converted to the correct data type.
        Parameters:
        ps -
        parameterIndex -
        obj -
        Throws:
        java.sql.SQLException