Top Description Fields Constructors Methods
com.univocity.parsers.common.routine

public abstract Class AbstractRoutines<P extends CommonParserSettings<?>, W extends CommonWriterSettings<?>>

extends Object
Class Inheritance
Known Direct Subclasses
com.univocity.parsers.csv.CsvRoutines, com.univocity.parsers.fixed.FixedWidthRoutines, com.univocity.parsers.tsv.TsvRoutines
Type Parameters
<P>
parser configuration class
<W>
writer configuration class
Imports
com.univocity.parsers.annotations.*, com.univocity.parsers.common.*, com.univocity.parsers.common.fields.*, com.univocity.parsers.common.processor.*, java.io.*, java.nio.charset.*, java.sql.*, java.util.*

Basic implementation of commonly used routines around parsing/writing of data that can be reused and extended by parsers/writers of any supported format.

Field Summary

Modifier and TypeField and Description
private ColumnMapping
private boolean
private P
private Writer
private final String
private W

Constructor Summary

AccessConstructor and Description
public
AbstractRoutines(String
description of the routines for a given format
routineDescription
)

Creates a new instance of this routine class.

public
AbstractRoutines(String
description of the routines for a given format
routineDescription
,
P
configuration to use for parsing
parserSettings
)

Creates a new instance of this routine class.

public
AbstractRoutines(String
description of the routines for a given format
routineDescription
,
W
configuration to use for writing
writerSettings
)

Creates a new instance of this routine class.

public
AbstractRoutines(String
description of the routines for a given format
routineDescription
,
P
configuration to use for parsing
parserSettings
,
W
configuration to use for writing
writerSettings
)

Creates a new instance of this routine class.

Method Summary

Modifier and TypeMethod and Description
protected void
adjustColumnLengths(String[]
headers to be written
headers
,
int[]
the corresponding lengths of each header
lengths
)

Allows writers of any given format to adjust its settings to take into account column headers and lengths prior to writing data in any routine.

private void
protected abstract P

Returns:

a new instance of a usable parser configuration.
createDefaultParserSettings
()

Creates a default parser settings configuration

protected abstract W

Returns:

a new instance of a usable writer configuration.
createDefaultWriterSettings
()

Creates a default writer settings configuration

protected abstract AbstractParser<P>

Returns:

a parser implementation configured according to the given settings object.
createParser
(P
the configuration for new parser
parserSettings
)

Creates a new parser implementation using the given parser configuration

protected abstract AbstractWriter<W>

Returns:

a writer implementation configured according to the given settings object.
createWriter
(Writer
target output of the routine.
output
,
W
the configuration for new writer
writerSettings
)

Creates a new writer implementation using the given writer configuration

private RowProcessor
public ColumnMapper

Returns:

the column mapper
getColumnMapper
()

Returns a mapper that allows users to manually define mappings from attributes/methods of a given class to columns to be parsed or written in routines that manipulate java beans.

public InputDimension

Returns:

a InputDimension with information about the dimensions of the given input.
getInputDimension
(final File
the file to be parsed
input
)

Calculates the dimensions of a file (row and column count).

public InputDimension

Returns:

a InputDimension with information about the dimensions of the given input.
getInputDimension
(final File
the file to be parsed
input
,
String
encoding of the given file
encoding
)

Calculates the dimensions of a file (row and column count).

public InputDimension

Returns:

a InputDimension with information about the dimensions of the given input.
getInputDimension
(final InputStream
the input to be parsed
input
)

Calculates the dimensions of a given input (row and column count).

public InputDimension

Returns:

a InputDimension with information about the dimensions of the given input.
getInputDimension
(final InputStream
the input to be parsed
input
,
String
encoding of the given input
encoding
)

Calculates the dimensions of a given input (row and column count).

public InputDimension

Returns:

a InputDimension with information about the dimensions of the given input.
getInputDimension
(Reader
the input to be parsed
input
)

Calculates the dimensions of a given input (row and column count).

public boolean

Returns:

flag indicating whether to call the close() (or any other cleanup method) after a routine executes.
getKeepResourcesOpen
()

Returns a flag indicating whether resources used for writing should be kept open after being used by the routines available from this object, when applicable.

public final P

Returns:

the parser configuration.
getParserSettings
()

Returns the parser configuration (if any) used by the routines of this utility class.

public final W

Returns:

the writer configuration.
getWriterSettings
()

Returns the writer configuration (if any) used by the routines of this utility class.

public <
the type of java beans to be instantiated.
T
>
IterableResult<T, ParsingContext>

Returns:

an Iterable that allows iterating over the input and producing instances of java beans on demand.
iterate
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final File
the file to be parsed
input
)

Iterates over a file to produce instances of annotated java beans on demand.

public <
the type of java beans to be instantiated.
T
>
IterableResult<T, ParsingContext>

Returns:

an Iterable that allows iterating over the input and producing instances of java beans on demand.
iterate
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final File
the file to be parsed
input
,
String
encoding of the given file
encoding
)

Iterates over a file to produce instances of annotated java beans on demand.

public <
the type of java beans to be instantiated.
T
>
IterableResult<T, ParsingContext>

Returns:

an Iterable that allows iterating over the input and producing instances of java beans on demand.
iterate
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final File
the file to be parsed
input
,
Charset
encoding of the given file
encoding
)

Iterates over a file to produce instances of annotated java beans on demand.

public <
the type of java beans to be instantiated.
T
>
IterableResult<T, ParsingContext>

Returns:

an Iterable that allows iterating over the input and producing instances of java beans on demand.
iterate
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final InputStream
the input stream to be parsed
input
)

Iterates over an input stream to produce instances of annotated java beans on demand.

public <
the type of java beans to be instantiated.
T
>
IterableResult<T, ParsingContext>

Returns:

an Iterable that allows iterating over the input and producing instances of java beans on demand.
iterate
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final InputStream
the input stream to be parsed
input
,
String
encoding of the given input stream
encoding
)

Iterates over an input stream to produce instances of annotated java beans on demand.

public <
the type of java beans to be instantiated.
T
>
IterableResult<T, ParsingContext>

Returns:

an Iterable that allows iterating over the input and producing instances of java beans on demand.
iterate
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final InputStream
the input stream to be parsed
input
,
Charset
encoding of the given input stream
encoding
)

Iterates over an input stream to produce instances of annotated java beans on demand.

public <
the type of java beans to be instantiated.
T
>
IterableResult<T, ParsingContext>

Returns:

an Iterable that allows iterating over the input and producing instances of java beans on demand.
iterate
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final Reader
the input to be parsed
input
)

Iterates over an input to produce instances of annotated java beans on demand.

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

an Iterable that allows iterating over the input and producing instances of java beans on demand.
parseAll
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final File
the file to be parsed
input
,
int
expected number of rows to be parsed from the input which will be converted into java beans. Used to pre-allocate the size of the output List
expectedBeanCount
)

Parses a file into a list of annotated java beans

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

an Iterable that allows iterating over the input and producing instances of java beans on demand.
parseAll
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final File
the file to be parsed
input
,
String
encoding of the given file
encoding
,
int
expected number of rows to be parsed from the input which will be converted into java beans. Used to pre-allocate the size of the output List
expectedBeanCount
)

Parses a file into a list of annotated java beans

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

a list containing all java beans read from the input.
parseAll
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final File
the file to be parsed
input
,
Charset
encoding of the given file
encoding
,
int
expected number of rows to be parsed from the input which will be converted into java beans. Used to pre-allocate the size of the output List
expectedBeanCount
)

Parses a file into a list of annotated java beans

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

a list containing all java beans read from the input.
parseAll
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final InputStream
the input stream to be parsed
input
,
int
expected number of rows to be parsed from the input which will be converted into java beans. Used to pre-allocate the size of the output List
expectedBeanCount
)

Parses an input stream into a list of annotated java beans

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

a list containing all java beans read from the input.
parseAll
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final InputStream
the input stream to be parsed
input
,
String
encoding of the given input stream
encoding
,
int
expected number of rows to be parsed from the input which will be converted into java beans. Used to pre-allocate the size of the output List
expectedBeanCount
)

Parses an input stream into a list of annotated java beans

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

a list containing all java beans read from the input.
parseAll
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final InputStream
the input stream to be parsed
input
,
Charset
encoding of the given input stream
encoding
,
int
expected number of rows to be parsed from the input which will be converted into java beans. Used to pre-allocate the size of the output List
expectedBeanCount
)

Parses an input stream into a list of annotated java beans

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

a list containing all java beans read from the input.
parseAll
(Class<T>
the type of java beans to be instantiated.
beanType
,
Reader
the input to be parsed
input
,
int
expected number of rows to be parsed from the input which will be converted into java beans. Used to pre-allocate the size of the output List
expectedBeanCount
)

Parses the input into a list of annotated java beans

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

an Iterable that allows iterating over the input and producing instances of java beans on demand.
parseAll
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final File
the file to be parsed
input
)

Parses a file into a list of annotated java beans

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

an Iterable that allows iterating over the input and producing instances of java beans on demand.
parseAll
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final File
the file to be parsed
input
,
String
encoding of the given file
encoding
)

Parses a file into a list of annotated java beans

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

a list containing all java beans read from the input.
parseAll
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final File
the file to be parsed
input
,
Charset
encoding of the given file
encoding
)

Parses a file into a list of annotated java beans

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

a list containing all java beans read from the input.
parseAll
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final InputStream
the input stream to be parsed
input
)

Parses an input stream into a list of annotated java beans

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

a list containing all java beans read from the input.
parseAll
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final InputStream
the input stream to be parsed
input
,
String
encoding of the given input stream
encoding
)

Parses an input stream into a list of annotated java beans

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

a list containing all java beans read from the input.
parseAll
(final Class<T>
the type of java beans to be instantiated.
beanType
,
final InputStream
the input stream to be parsed
input
,
Charset
encoding of the given input stream
encoding
)

Parses an input stream into a list of annotated java beans

public <
the type of java beans to be instantiated.
T
>
List<T>

Returns:

a list containing all java beans read from the input.
parseAll
(Class<T>
the type of java beans to be instantiated.
beanType
,
Reader
the input to be parsed
input
)

Parses the input into a list of annotated java beans

public final void
parseAndWrite(Reader
the input data to be parsed using the settings provided in getParserSettings()
input
,
Writer
the output into where the input data should be written, using the format provided in getWriterSettings()
output
)

Reads all data from a given input and writes it to an output.

public void
setColumnMapper(ColumnMapper
the column mappings to use
columnMapper
)

Copies the given column mappings over to this processor.

public void
setKeepResourcesOpen(boolean
flag indicating whether to call the close() (or any other cleanup method) after a routine executes.
keepResourcesOpen
)

Allows preventing resources used for writing from being closed after being used by the routines available from this object, when applicable.

public final void
setParserSettings(P
the parser configuration.
parserSettings
)

Defines the parser configuration to be used by the routines of this utility class.

private void
private void
public final void
setWriterSettings(W
the parser configuration.
writerSettings
)

Defines the writer configuration to be used by the routines of this utility class.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private void
private void
public final void
write(ResultSet
the java.sql.ResultSet whose contents should be read and written to a given output
rs
,
File
the output file that will store the data in the given java.sql.ResultSet in the format specified by concrete implementations of this class.
output
)

Dumps the content of a java.sql.ResultSet into a file.

public final void
write(ResultSet
the java.sql.ResultSet whose contents should be read and written to a given output
rs
,
File
the output file that will store the data in the given java.sql.ResultSet in the format specified by concrete implementations of this class.
output
,
String
the output encoding of the file
encoding
)

Dumps the content of a java.sql.ResultSet into a file.

public final void
write(ResultSet
the java.sql.ResultSet whose contents should be read and written to a given output
rs
,
File
the output file that will store the data in the given java.sql.ResultSet in the format specified by concrete implementations of this class.
output
,
Charset
the output encoding of the file
encoding
)

Dumps the content of a java.sql.ResultSet into a file.

public final void
write(ResultSet
the java.sql.ResultSet whose contents should be read and written to a given output
rs
,
OutputStream
the output stream that will store the data in the given java.sql.ResultSet in the format specified by concrete implementations of this class.
output
)

Dumps the content of a java.sql.ResultSet into an output stream.

public final void
write(ResultSet
the java.sql.ResultSet whose contents should be read and written to a given output
rs
,
OutputStream
the output file that will store the data in the given java.sql.ResultSet in the format specified by concrete implementations of this class.
output
,
String
the output encoding of the output stream
encoding
)

Dumps the content of a java.sql.ResultSet into an output stream.

public final void
write(ResultSet
the java.sql.ResultSet whose contents should be read and written to a given output
rs
,
OutputStream
the output file that will store the data in the given java.sql.ResultSet in the format specified by concrete implementations of this class.
output
,
Charset
the output encoding of the output stream
encoding
)

Dumps the content of a java.sql.ResultSet into an output stream.

public final void
write(ResultSet
the java.sql.ResultSet whose contents should be read and written to a given output
rs
,
Writer
the output that will store the data in the given java.sql.ResultSet in the format specified by concrete implementations of this class.
output
)

Dumps the content of a java.sql.ResultSet.

public <
the type of element in the given collection
T
>
void
writeAll(Iterable<T>
the elements to write to the output
elements
,
Class<T>
the type of element in the given collection
beanType
,
File
the output into which the given elements will be written
output
,
String...
headers to use in the first row of the written result.
headers
)

Writes a collection of annotated java beans to a given output.

public <
the type of element in the given collection
T
>
void
writeAll(Iterable<T>
the elements to write to the output
elements
,
Class<T>
the type of element in the given collection
beanType
,
File
the output into which the given elements will be written
output
,
String
the output encoding to use for writing
encoding
,
String[]
headers to use in the first row of the written result.
headers
)

Writes a collection of annotated java beans to a given output.

public <
the type of element in the given collection
T
>
void
writeAll(Iterable<T>
the elements to write to the output
elements
,
Class<T>
the type of element in the given collection
beanType
,
File
the output into which the given elements will be written
output
,
Charset
the output encoding to use for writing
encoding
,
String...
headers to use in the first row of the written result.
headers
)

Writes a collection of annotated java beans to a given output.

public <
the type of element in the given collection
T
>
void
writeAll(Iterable<T>
the elements to write to the output
elements
,
Class<T>
the type of element in the given collection
beanType
,
OutputStream
the output into which the given elements will be written
output
,
String...
headers to use in the first row of the written result.
headers
)

Writes a collection of annotated java beans to a given output.

public <
the type of element in the given collection
T
>
void
writeAll(Iterable<T>
the elements to write to the output
elements
,
Class<T>
the type of element in the given collection
beanType
,
OutputStream
the output into which the given elements will be written
output
,
String
the output encoding to use for writing
encoding
,
String[]
headers to use in the first row of the written result.
headers
)

Writes a collection of annotated java beans to a given output.

public <
the type of element in the given collection
T
>
void
writeAll(Iterable<T>
the elements to write to the output
elements
,
Class<T>
the type of element in the given collection
beanType
,
OutputStream
the output into which the given elements will be written
output
,
Charset
the output encoding to use for writing
encoding
,
String...
headers to use in the first row of the written result.
headers
)

Writes a collection of annotated java beans to a given output.

public <
the type of element in the given collection
T
>
void
writeAll(Iterable<T>
the elements to write to the output
elements
,
Class<T>
the type of element in the given collection
beanType
,
Writer
the output into which the given elements will be written
output
,
String...
headers to use in the first row of the written result.
headers
)

Writes a collection of annotated java beans to a given output.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait