Class CsvQuery

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

public class CsvQuery extends Object implements ParametersCallback
Query for CSV file.
Version:
1.0
Author:
Fyodor Kupolov
  • Field Details

    • LOG

      protected static final Logger LOG
  • Constructor Details

    • CsvQuery

      public CsvQuery(CSVReader queryReader, PropertiesSubstitutor substitutor, CsvConnectionParameters csvParams)
      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.
      csvParams - parsed parameters of the CSV connection
  • Method Details

    • execute

      public void execute(CSVReader reader, QueryCallback queryCallback, AbstractConnection.StatementCounter counter) throws 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:
      IOException - if IO error occurs.
    • parseHeader

      protected ColumnsMap parseHeader(CSVReader reader) throws IOException
      Throws:
      IOException
    • rowMatches

      protected boolean rowMatches(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(QueryCallback queryCallback, 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 Object getParameter(String name)
      Description copied from interface: ParametersCallback
      Returns the value of parameter specified by name.

      The callback internally delegates a call to parent callbacks if the parameter cannot be found.

      Specified by:
      getParameter in interface ParametersCallback
      Parameters:
      name - parameter name. Providers are allowed (but not required) to ignore a case of the name parameter to comply with their internal model. For example JDBC drivers are case-insensitive to column names.
      Returns:
      parameter value or null if parameter doesn't exist.
    • getCurrentRowValueAt

      protected Object getCurrentRowValueAt(int columnIndex, 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 ColumnsMap getColumnsMap()