Package scriptella.driver.csv
Class CsvQuery
java.lang.Object
scriptella.driver.csv.CsvQuery
- All Implemented Interfaces:
ParametersCallback
Query for CSV file.
- Version:
- 1.0
- Author:
- Fyodor Kupolov
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCsvQuery(CSVReader queryReader, PropertiesSubstitutor substitutor, CsvConnectionParameters csvParams) Creates a query for CSVReader. -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(CSVReader reader, QueryCallback queryCallback, AbstractConnection.StatementCounter counter) Executes a query over a specified text content.protected ColumnsMapprotected ObjectgetCurrentRowValueAt(int columnIndex, String columnName) Returns the value of a specified column.getParameter(String name) Returns the value of parameter specified by name.protected ColumnsMapparseHeader(CSVReader reader) protected voidprocessRow(QueryCallback queryCallback, String[] r) Processes the current row.protected booleanrowMatches(String[] r) Checks if current CSV row matches any of the specified patterns.
-
Field Details
-
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
- Throws:
IOException
-
rowMatches
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
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
Description copied from interface:ParametersCallbackReturns the value of parameter specified by name.The callback internally delegates a call to parent callbacks if the parameter cannot be found.
- Specified by:
getParameterin interfaceParametersCallback- 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
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 indexcolumnName- column name.- Returns:
- value of the specified column of the current row.
-
getColumnsMap
-