net.sf.colle.sql.schema
Interface LoaderFilter


public interface LoaderFilter

Allows files loaded by TableLoader to be filtered before contents are loaded into the database. Loader filters are listed in the system property net.sf.colle.sql.schema.loaderFilters separated by File.pathSeparator. Each filter can register to maniplate several tables by overriding getTables. If several tables register for the same table they will be each passed each line in the order they are registered As each table is loaded, init() is called to initialize the filter. Then each line's data will be sent to filter(). If the filter wishes to keep the line from being loaded it can do so by not calling the next filter. Equally, the filter may break a line into two lines by calling the next filter twice for each line it receives. The text file may contain more (or fewer) columns than the table they are being loaded into. If this is true, a filter must add or delete columns or the TableLoader will reject the line. All implementations must have a public, no-arguement constructor. Created: 23 Jun 2003

Version:
$Revision: 1.3 $, $Date: 2003/11/21 19:04:21 $
Author:
Dwayne Schultz

Method Summary
 void filter(List pxLine, int pnLineCount)
          Filters a line of data.
 List getTableNames()
          Returns a list of strings identifying each table this filter works on.
 void init(Table pxTable, LoaderFilter pxNextFilter, Connection pxConnection)
          Initializes the filter to work on a table.
 

Method Detail

getTableNames

public List getTableNames()
Returns a list of strings identifying each table this filter works on. If this method returns null it is assumed it works on all tables.


init

public void init(Table pxTable,
                 LoaderFilter pxNextFilter,
                 Connection pxConnection)
Initializes the filter to work on a table. The next filter must be passed each line that is to be loaded. The connection is provided so the filter can read the database that is being loaded. In most cases, filters will not need the connection.


filter

public void filter(List pxLine,
                   int pnLineCount)
            throws TooFewFieldsException,
                   TooManyFieldsException,
                   ParseException,
                   NumberFormatException,
                   SQLException
Filters a line of data. The next filter's filter() method must be called to load the line passed here. The number of columns in the line must match the number of columns in the database before the line is passed back to the last filter inside the TableLoader.

Parameters:
pxLine - list of strings, one for each field in the line
pnLineCount - line number being processed, for error reporting
Throws:
TooFewFieldsException
TooManyFieldsException
ParseException
NumberFormatException
SQLException