org.eclipse.datatools.sqltools.data.internal.core.common
Class DefaultColumnDataAccessor

java.lang.Object
  extended by org.eclipse.datatools.sqltools.data.internal.core.common.DefaultColumnDataAccessor
All Implemented Interfaces:
IColumnDataAccessor

public class DefaultColumnDataAccessor
extends java.lang.Object
implements IColumnDataAccessor

This is the default implementation of the IColumnDataAccessor that is used when no contributuion is made to the columnDataAcessor extension point. This class relies on the JDBC driver to get data in and out from the database.

Author:
groux

Constructor Summary
DefaultColumnDataAccessor()
           
 
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().
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultColumnDataAccessor

public DefaultColumnDataAccessor()
Method Detail

initialize

public void initialize(Column sqlCol)
Description copied from interface: IColumnDataAccessor
Initialize the object after its creation.

Specified by:
initialize in interface IColumnDataAccessor

getSelectExpr

public java.lang.String getSelectExpr()
Description copied from interface: IColumnDataAccessor
Returns the SELECT expression corresponding to the column.

Specified by:
getSelectExpr in interface IColumnDataAccessor

read

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

Specified by:
read in interface IColumnDataAccessor
Throws:
java.sql.SQLException
java.io.IOException

isSnippet

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

Specified by:
isSnippet in interface IColumnDataAccessor

getValuesExpr

public java.lang.String getValuesExpr(java.lang.Object val)
Description copied from interface: IColumnDataAccessor
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).

Specified by:
getValuesExpr in interface IColumnDataAccessor

writeValuesExprArgs

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

Specified by:
writeValuesExprArgs in interface IColumnDataAccessor
Throws:
java.sql.SQLException
java.io.IOException

getSetAss

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

Specified by:
getSetAss in interface IColumnDataAccessor

writeSetAssArgs

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

Specified by:
writeSetAssArgs in interface IColumnDataAccessor
Throws:
java.sql.SQLException
java.io.IOException

getWhereCond

public java.lang.String getWhereCond(java.lang.Object val)
Description copied from interface: IColumnDataAccessor
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)

Specified by:
getWhereCond in interface IColumnDataAccessor

writeWhereCondArgs

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

Specified by:
writeWhereCondArgs in interface IColumnDataAccessor
Throws:
java.sql.SQLException
java.io.IOException

getLabel

public java.lang.String getLabel(java.lang.Object val,
                                 int type)
Description copied from interface: IColumnDataAccessor
Returns a short text to represent the provided object.

Specified by:
getLabel in interface IColumnDataAccessor

serialize

public java.lang.String serialize(java.lang.Object val,
                                  int type)
Description copied from interface: IColumnDataAccessor
Serializes an object as a string (for inline editing).

Specified by:
serialize in interface IColumnDataAccessor

deserialize

public java.lang.Object deserialize(java.lang.String val,
                                    int type)
Description copied from interface: IColumnDataAccessor
Deserializes a string to an object (for inline editing).

Specified by:
deserialize in interface IColumnDataAccessor

supportsInlineEdit

public boolean supportsInlineEdit()
Description copied from interface: IColumnDataAccessor
Returns true if the provided value can be edited inline using the serialization methods.

Specified by:
supportsInlineEdit in interface IColumnDataAccessor