org.eclipse.datatools.sqltools.data.internal.core.common
Interface IColumnDataAccessor

All Known Implementing Classes:
DefaultColumnDataAccessor

public interface IColumnDataAccessor

IColumnDataAccessor defines the interface to access data stored in a given table column. This interface is currently used for the table data editor but could be extended to be used with the Extract/Load feature. It provides methods to read from and write to the database through the JDBC driver. It also provides methods to serialize or deserialize a value as a string. These methodes are used to edit some data in the table editor, when supportsInlineEdit() is true. The value can be represented by an aribitrary Object. The object is usually the one returned by the JDBC driver but it could be a custom object, to handle any specific need.

Author:
groux

Method Summary
 java.lang.Object deserialize(java.lang.String val, int type)
          Deserializes a string to an object (for inline editing).
 java.lang.String getLabel(java.lang.Object val, int type)
          Returns a short text to represent the provided object.
 java.lang.String getSelectExpr()
          Returns the SELECT expression corresponding to the column.
 java.lang.String getSetAss(java.lang.Object val)
          Returns the SQL assignment (including optional '?'), to be used in the SET clause.
 java.lang.String getValuesExpr(java.lang.Object val)
          Returns the SQL expression (including optional '?'), to be used in the VALUES clause.
 java.lang.String getWhereCond(java.lang.Object val)
          Returns the SQL condition (including optional '?'), to be used in the WHERE clause.
 void initialize(Column sqlCol)
          Initialize the object after its creation.
 boolean isSnippet(java.lang.Object val, int type)
          Return true if the supplyied value is a snippet and not the full value as stored in the database
 java.lang.Object read(java.sql.ResultSet rs, int col, int type, boolean snippet)
          Reads a value from the result set and return in as an Object.
 java.lang.String serialize(java.lang.Object val, int type)
          Serializes an object as a string (for inline editing).
 boolean supportsInlineEdit()
          Returns true if the provided value can be edited inline using the serialization methods.
 java.lang.String[] writeSetAssArgs(java.sql.PreparedStatement pst, int start, java.lang.Object val, int type)
          Writes the prepared statement arguments, corresponding to getSetAss().
 java.lang.String[] writeValuesExprArgs(java.sql.PreparedStatement pst, int start, java.lang.Object val, int type)
          Writes the prepared statement arguments, corresponding to getValuesExpr().
 java.lang.String[] writeWhereCondArgs(java.sql.PreparedStatement pst, int start, java.lang.Object val, int type)
          Writes the prepared statement arguments, corresponding to getWhereCond().
 

Method Detail

initialize

void initialize(Column sqlCol)
Initialize the object after its creation.


getSelectExpr

java.lang.String getSelectExpr()
Returns the SELECT expression corresponding to the column.


read

java.lang.Object read(java.sql.ResultSet rs,
                      int col,
                      int type,
                      boolean snippet)
                      throws java.sql.SQLException,
                             java.io.IOException
Reads a value from the result set and return in as an Object.

Throws:
java.sql.SQLException
java.io.IOException

isSnippet

boolean isSnippet(java.lang.Object val,
                  int type)
Return true if the supplyied value is a snippet and not the full value as stored in the database


getValuesExpr

java.lang.String getValuesExpr(java.lang.Object val)
Returns the SQL expression (including optional '?'), to be used in the VALUES clause. Return null if the value should be ommited (eg: default/auto-generated column).


writeValuesExprArgs

java.lang.String[] writeValuesExprArgs(java.sql.PreparedStatement pst,
                                       int start,
                                       java.lang.Object val,
                                       int type)
                                       throws java.sql.SQLException,
                                              java.io.IOException
Writes the prepared statement arguments, corresponding to getValuesExpr().

Throws:
java.sql.SQLException
java.io.IOException

getSetAss

java.lang.String getSetAss(java.lang.Object val)
Returns the SQL assignment (including optional '?'), to be used in the SET clause. Return null if the column should not be set.


writeSetAssArgs

java.lang.String[] writeSetAssArgs(java.sql.PreparedStatement pst,
                                   int start,
                                   java.lang.Object val,
                                   int type)
                                   throws java.sql.SQLException,
                                          java.io.IOException
Writes the prepared statement arguments, corresponding to getSetAss().

Throws:
java.sql.SQLException
java.io.IOException

getWhereCond

java.lang.String getWhereCond(java.lang.Object val)
Returns the SQL condition (including optional '?'), to be used in the WHERE clause. Return null if the column should not participate in the WHERE clause (eg: CLOB column)


writeWhereCondArgs

java.lang.String[] writeWhereCondArgs(java.sql.PreparedStatement pst,
                                      int start,
                                      java.lang.Object val,
                                      int type)
                                      throws java.sql.SQLException,
                                             java.io.IOException
Writes the prepared statement arguments, corresponding to getWhereCond().

Throws:
java.sql.SQLException
java.io.IOException

serialize

java.lang.String serialize(java.lang.Object val,
                           int type)
Serializes an object as a string (for inline editing).


deserialize

java.lang.Object deserialize(java.lang.String val,
                             int type)
Deserializes a string to an object (for inline editing).


getLabel

java.lang.String getLabel(java.lang.Object val,
                          int type)
Returns a short text to represent the provided object.


supportsInlineEdit

boolean supportsInlineEdit()
Returns true if the provided value can be edited inline using the serialization methods.