scriptella.driver.csv
Class CsvQuery

java.lang.Object
  extended by scriptella.driver.csv.CsvQuery
All Implemented Interfaces:
scriptella.spi.ParametersCallback

public class CsvQuery
extends java.lang.Object
implements scriptella.spi.ParametersCallback

Query for CSV file.

Version:
1.0
Author:
Fyodor Kupolov

Field Summary
protected  boolean headers
           
protected static java.util.logging.Logger LOG
           
protected  java.lang.String nullString
           
protected  boolean trim
           
 
Constructor Summary
CsvQuery(CSVReader queryReader, scriptella.expression.PropertiesSubstitutor substitutor, java.lang.String nullString, boolean headers, boolean trim)
          Creates a query for CSVReader.
 
Method Summary
 void execute(CSVReader reader, scriptella.spi.QueryCallback queryCallback, scriptella.spi.AbstractConnection.StatementCounter counter)
          Executes a query over a specified text content.
protected  scriptella.util.ColumnsMap getColumnsMap()
           
protected  java.lang.Object getCurrentRowValueAt(int columnIndex, java.lang.String columnName)
          Returns the value of a specified column.
 java.lang.Object getParameter(java.lang.String name)
           
protected  scriptella.util.ColumnsMap parseHeader(CSVReader reader)
           
protected  void processRow(scriptella.spi.QueryCallback queryCallback, java.lang.String[] r)
          Processes the current row.
protected  boolean rowMatches(java.lang.String[] r)
          Checks if current CSV row matches any of the specified patterns.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final java.util.logging.Logger LOG

headers

protected final boolean headers

trim

protected final boolean trim

nullString

protected final java.lang.String nullString
Constructor Detail

CsvQuery

public CsvQuery(CSVReader queryReader,
                scriptella.expression.PropertiesSubstitutor substitutor,
                java.lang.String nullString,
                boolean headers,
                boolean trim)
Creates a query for CSVReader.

Parameters:
queryReader - query CSVReader.
substitutor - properties substitutor to use. The parameters for the substitutor must be set by a caller.
headers - true if first line of input CSV file contains headers.
trim - true if if extra whitespaces should be trimmed.
nullString - string to treat as NULL.
Method Detail

execute

public void execute(CSVReader reader,
                    scriptella.spi.QueryCallback queryCallback,
                    scriptella.spi.AbstractConnection.StatementCounter counter)
             throws java.io.IOException
Executes a query over a specified text content.

Parameters:
reader - CSV content reader.
queryCallback - callback to use for result set iteration.
counter - statements counter.
Throws:
java.io.IOException - if IO error occurs.

parseHeader

protected scriptella.util.ColumnsMap parseHeader(CSVReader reader)
                                          throws java.io.IOException
Throws:
java.io.IOException

rowMatches

protected boolean rowMatches(java.lang.String[] r)
Checks if current CSV row matches any of the specified patterns.

Parameters:
r - row to check
Returns:
true if row matches one of queries.

processRow

protected void processRow(scriptella.spi.QueryCallback queryCallback,
                          java.lang.String[] r)
Processes the current row.

This template method may be used for customizations by sublasses.

Parameters:
queryCallback - query callback to use.
r - row to pass as current parameters callback.

getParameter

public java.lang.Object getParameter(java.lang.String name)
Specified by:
getParameter in interface scriptella.spi.ParametersCallback

getCurrentRowValueAt

protected java.lang.Object getCurrentRowValueAt(int columnIndex,
                                                java.lang.String columnName)
Returns the value of a specified column.

This method may be overriden to perform conversion etc
2 parameters are passed for performance reasons, so that subclasses may decide wich one to use.

Parameters:
columnIndex - column index
columnName - column name.
Returns:
value of the specified column of the current row.

getColumnsMap

protected scriptella.util.ColumnsMap getColumnsMap()


Copyright © Copyright 2006-2009 The Scriptella Project Team.