Package scriptella.driver.csv
Class CsvConnection
java.lang.Object
scriptella.spi.AbstractConnection
scriptella.driver.text.AbstractTextConnection
scriptella.driver.csv.CsvConnection
- All Implemented Interfaces:
Connection
Represents a connection to CSV file.
For configuration details and examples see overview page.
- Version:
- 1.1
- Author:
- Fyodor Kupolov, Sean Summers
-
Nested Class Summary
Nested classes/interfaces inherited from class scriptella.spi.AbstractConnection
AbstractConnection.StatementCounter -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName of theescapeconnection property.static final StringName of theheadersconnection property.protected static final Loggerstatic final StringName of thequoteconnection property.static final StringName of thequoteallconnection property.static final StringName of theseparatorconnection property.Fields inherited from class scriptella.driver.text.AbstractTextConnection
ENCODING, EOL, FLUSH, FORMAT_PREFIX, NULL_STRING, SKIP_LINES, TRIMFields inherited from class scriptella.spi.AbstractConnection
counter -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the connection and releases all related resources.voidexecuteQuery(Resource queryContent, ParametersCallback parametersCallback, QueryCallback queryCallback) Executes a query specified by its content.voidexecuteScript(Resource scriptContent, ParametersCallback parametersCallback) Executes a script specified by its content.protected CsvConnectionParametersprotected CSVWritergetOut()protected CsvQuerynewCsvQuery(CSVReader csvReader, PropertiesSubstitutor ps) Template factory method to instantiate query handlers.Methods inherited from class scriptella.driver.text.AbstractTextConnection
newInputReader, newOutputWriterMethods inherited from class scriptella.spi.AbstractConnection
commit, getDialectIdentifier, getExecutedStatementsCount, isReadonly, rollback, setDialectIdentifier, toString
-
Field Details
-
LOG
-
SEPARATOR
Name of theseparatorconnection property. The delimiter to use for separating entries when reading from or writing to files.- See Also:
-
QUOTE
Name of thequoteconnection property. The character to use for quoted elements when reading from or writing to files. Use empty string to suppress quoting.- See Also:
-
ESCAPE
Name of theescapeconnection property. The character to use for escaped elements when writing to files. Use empty string to suppress escaping.- See Also:
-
HEADERS
Name of theheadersconnection property. true means the first line contains headers. Default value is true.Only valid for <query> elements.
- See Also:
-
QUOTEALL
Name of thequoteallconnection property. false means only elements with the quote or escape character are quoted. Default value is true.- See Also:
-
-
Constructor Details
-
CsvConnection
-
-
Method Details
-
executeScript
public void executeScript(Resource scriptContent, ParametersCallback parametersCallback) throws ProviderException Description copied from interface:ConnectionExecutes a script specified by its content.scriptContent may be used as a key for caching purposes, i.e. provider may precompile scripts and use compiled versions for subsequent executions. Please note that only inline
text resourcescan be safely cached.- Parameters:
scriptContent- script content. Cannot be null.parametersCallback- callback to get parameter values. Cannot be null.- Throws:
ProviderException- if script execution failed.
-
executeQuery
public void executeQuery(Resource queryContent, ParametersCallback parametersCallback, QueryCallback queryCallback) throws ProviderException Description copied from interface:ConnectionExecutes a query specified by its content.- Parameters:
queryContent- query content. Cannot be null.parametersCallback- callback to get parameter values. Cannot be null.queryCallback- callback to call for each result set element produced by this query. Cannot be null.- Throws:
ProviderException- if query execution failed.- See Also:
-
getOut
- Returns:
- lazily intialized writer.
-
newCsvQuery
Template factory method to instantiate query handlers.- Parameters:
csvReader- CSV reader to use for parsing.ps- properties substitutor.- Returns:
- constructed query for a specified input and parameters.
-
close
Description copied from interface:ConnectionCloses the connection and releases all related resources.- Throws:
ProviderException- if a critical failure occured.
-
getConnectionParameters
- Overrides:
getConnectionParametersin classAbstractTextConnection
-