prefuse.data.io.sql
Class CompositeSQLDataHandler

java.lang.Object
  extended by prefuse.data.io.sql.CompositeSQLDataHandler
All Implemented Interfaces:
SQLDataHandler

public class CompositeSQLDataHandler
extends java.lang.Object
implements SQLDataHandler

SQLDataHandler that allows multiple handlers to be grouped together. This class supports a map that allows specific data field / column names to use a custom SQLDataHandler implementation, while maintaining a default handler for any data fields without an entry in the map.

Author:
jeffrey heer

Constructor Summary
CompositeSQLDataHandler()
          Create a new CompositeSQLDataHandler.
CompositeSQLDataHandler(SQLDataHandler defaultHandler)
          Create a new CompositeSQLDataHandler.
 
Method Summary
 void addHandler(java.lang.String columnName, SQLDataHandler handler)
          Add a custom data handler for a given column name.
 java.lang.Class getDataType(java.lang.String columnName, int sqlType)
          Return the Java data type for the given data field name and its sql data type.
 void process(Table t, int trow, java.sql.ResultSet rset, int rcol)
          Process a data value from a ResultSet, translating it into a Java data value and storing it in a Table.
 boolean removeHandler(java.lang.String columnName)
          Remove a custom data handler for a given column name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompositeSQLDataHandler

public CompositeSQLDataHandler()
Create a new CompositeSQLDataHandler. Uses a DefaultSQLDataHandler as the default handler.


CompositeSQLDataHandler

public CompositeSQLDataHandler(SQLDataHandler defaultHandler)
Create a new CompositeSQLDataHandler.

Parameters:
defaultHandler - the default data handler to use
Method Detail

addHandler

public void addHandler(java.lang.String columnName,
                       SQLDataHandler handler)
Add a custom data handler for a given column name.

Parameters:
columnName - the data field / column name
handler - the data handler to use for the field

removeHandler

public boolean removeHandler(java.lang.String columnName)
Remove a custom data handler for a given column name. Subsequent to this method, the column will use the default handler.

Parameters:
columnName - the data field / column name
Returns:
true if a handler was successfully removed, false if no such custom handler was found.

process

public void process(Table t,
                    int trow,
                    java.sql.ResultSet rset,
                    int rcol)
             throws java.sql.SQLException
Description copied from interface: SQLDataHandler
Process a data value from a ResultSet, translating it into a Java data value and storing it in a Table.

Specified by:
process in interface SQLDataHandler
Parameters:
t - the Table in which to store the result value
trow - the Table row to add to
rset - the ResultSet to read the SQL value from, assumed to be set to the desired row
rcol - the column index of the data value in the row set. This is also used to look up the column name, which is used to access the correct data field of the Table.
Throws:
java.sql.SQLException - if an error occurs accessing the ResultSet
See Also:
SQLDataHandler.process(prefuse.data.Table, int, java.sql.ResultSet, int)

getDataType

public java.lang.Class getDataType(java.lang.String columnName,
                                   int sqlType)
Description copied from interface: SQLDataHandler
Return the Java data type for the given data field name and its sql data type.

Specified by:
getDataType in interface SQLDataHandler
Parameters:
columnName - the name of data field / column
sqlType - the field's sql data type, one of the constants in the Types class.
Returns:
the Java Class data type
See Also:
SQLDataHandler.getDataType(java.lang.String, int)


Copyright © 2007 Regents of the University of California