P
- parser configuration classW
- writer configuration classpublic abstract class AbstractRoutines<P extends CommonParserSettings<?>,W extends CommonWriterSettings<?>> extends Object
Constructor and Description |
---|
AbstractRoutines(String routineDescription)
Creates a new instance of this routine class.
|
AbstractRoutines(String routineDescription,
P parserSettings)
Creates a new instance of this routine class.
|
AbstractRoutines(String routineDescription,
P parserSettings,
W writerSettings)
Creates a new instance of this routine class.
|
AbstractRoutines(String routineDescription,
W writerSettings)
Creates a new instance of this routine class.
|
Modifier and Type | Method and Description |
---|---|
protected void |
adjustColumnLengths(String[] headers,
int[] 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.
|
protected abstract P |
createDefaultParserSettings()
Creates a default parser settings configuration
|
protected abstract W |
createDefaultWriterSettings()
Creates a default writer settings configuration
|
protected abstract AbstractParser<P> |
createParser(P parserSettings)
Creates a new parser implementation using the given parser configuration
|
protected abstract AbstractWriter<W> |
createWriter(Writer output,
W writerSettings)
Creates a new writer implementation using the given writer configuration
|
ColumnMapper |
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.
|
InputDimension |
getInputDimension(File input)
Calculates the dimensions of a file (row and column count).
|
InputDimension |
getInputDimension(File input,
String encoding)
Calculates the dimensions of a file (row and column count).
|
InputDimension |
getInputDimension(InputStream input)
Calculates the dimensions of a given input (row and column count).
|
InputDimension |
getInputDimension(InputStream input,
String encoding)
Calculates the dimensions of a given input (row and column count).
|
InputDimension |
getInputDimension(Reader input)
Calculates the dimensions of a given input (row and column count).
|
boolean |
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.
|
P |
getParserSettings()
Returns the parser configuration (if any) used by the routines of this utility class.
|
W |
getWriterSettings()
Returns the writer configuration (if any) used by the routines of this utility class.
|
<T> IterableResult<T,ParsingContext> |
iterate(Class<T> beanType,
File input)
Iterates over a file to produce instances of annotated java beans on demand.
|
<T> IterableResult<T,ParsingContext> |
iterate(Class<T> beanType,
File input,
Charset encoding)
Iterates over a file to produce instances of annotated java beans on demand.
|
<T> IterableResult<T,ParsingContext> |
iterate(Class<T> beanType,
File input,
String encoding)
Iterates over a file to produce instances of annotated java beans on demand.
|
<T> IterableResult<T,ParsingContext> |
iterate(Class<T> beanType,
InputStream input)
Iterates over an input stream to produce instances of annotated java beans on demand.
|
<T> IterableResult<T,ParsingContext> |
iterate(Class<T> beanType,
InputStream input,
Charset encoding)
Iterates over an input stream to produce instances of annotated java beans on demand.
|
<T> IterableResult<T,ParsingContext> |
iterate(Class<T> beanType,
InputStream input,
String encoding)
Iterates over an input stream to produce instances of annotated java beans on demand.
|
<T> IterableResult<T,ParsingContext> |
iterate(Class<T> beanType,
Reader input)
Iterates over an input to produce instances of annotated java beans on demand.
|
<T> List<T> |
parseAll(Class<T> beanType,
File input)
Parses a file into a list of annotated java beans
|
<T> List<T> |
parseAll(Class<T> beanType,
File input,
Charset encoding)
Parses a file into a list of annotated java beans
|
<T> List<T> |
parseAll(Class<T> beanType,
File input,
Charset encoding,
int expectedBeanCount)
Parses a file into a list of annotated java beans
|
<T> List<T> |
parseAll(Class<T> beanType,
File input,
int expectedBeanCount)
Parses a file into a list of annotated java beans
|
<T> List<T> |
parseAll(Class<T> beanType,
File input,
String encoding)
Parses a file into a list of annotated java beans
|
<T> List<T> |
parseAll(Class<T> beanType,
File input,
String encoding,
int expectedBeanCount)
Parses a file into a list of annotated java beans
|
<T> List<T> |
parseAll(Class<T> beanType,
InputStream input)
Parses an input stream into a list of annotated java beans
|
<T> List<T> |
parseAll(Class<T> beanType,
InputStream input,
Charset encoding)
Parses an input stream into a list of annotated java beans
|
<T> List<T> |
parseAll(Class<T> beanType,
InputStream input,
Charset encoding,
int expectedBeanCount)
Parses an input stream into a list of annotated java beans
|
<T> List<T> |
parseAll(Class<T> beanType,
InputStream input,
int expectedBeanCount)
Parses an input stream into a list of annotated java beans
|
<T> List<T> |
parseAll(Class<T> beanType,
InputStream input,
String encoding)
Parses an input stream into a list of annotated java beans
|
<T> List<T> |
parseAll(Class<T> beanType,
InputStream input,
String encoding,
int expectedBeanCount)
Parses an input stream into a list of annotated java beans
|
<T> List<T> |
parseAll(Class<T> beanType,
Reader input)
Parses the input into a list of annotated java beans
|
<T> List<T> |
parseAll(Class<T> beanType,
Reader input,
int expectedBeanCount)
Parses the input into a list of annotated java beans
|
void |
parseAndWrite(Reader input,
Writer output)
Reads all data from a given input and writes it to an output.
|
void |
setColumnMapper(ColumnMapper columnMapper)
Copies the given column mappings over to this processor.
|
void |
setKeepResourcesOpen(boolean keepResourcesOpen)
Allows preventing resources used for writing from being closed after being
used by the routines available from this object, when applicable.
|
void |
setParserSettings(P parserSettings)
Defines the parser configuration to be used by the routines of this utility class.
|
void |
setWriterSettings(W writerSettings)
Defines the writer configuration to be used by the routines of this utility class.
|
String |
toString() |
void |
write(ResultSet rs,
File output)
Dumps the content of a
ResultSet into a file. |
void |
write(ResultSet rs,
File output,
Charset encoding)
Dumps the content of a
ResultSet into a file. |
void |
write(ResultSet rs,
File output,
String encoding)
Dumps the content of a
ResultSet into a file. |
void |
write(ResultSet rs,
OutputStream output)
Dumps the content of a
ResultSet into an output stream. |
void |
write(ResultSet rs,
OutputStream output,
Charset encoding)
Dumps the content of a
ResultSet into an output stream. |
void |
write(ResultSet rs,
OutputStream output,
String encoding)
Dumps the content of a
ResultSet into an output stream. |
void |
write(ResultSet rs,
Writer output)
Dumps the content of a
ResultSet . |
<T> void |
writeAll(Iterable<T> elements,
Class<T> beanType,
File output,
Charset encoding,
String... headers)
Writes a collection of annotated java beans to a given output.
|
<T> void |
writeAll(Iterable<T> elements,
Class<T> beanType,
File output,
String... headers)
Writes a collection of annotated java beans to a given output.
|
<T> void |
writeAll(Iterable<T> elements,
Class<T> beanType,
File output,
String encoding,
String[] headers)
Writes a collection of annotated java beans to a given output.
|
<T> void |
writeAll(Iterable<T> elements,
Class<T> beanType,
OutputStream output,
Charset encoding,
String... headers)
Writes a collection of annotated java beans to a given output.
|
<T> void |
writeAll(Iterable<T> elements,
Class<T> beanType,
OutputStream output,
String... headers)
Writes a collection of annotated java beans to a given output.
|
<T> void |
writeAll(Iterable<T> elements,
Class<T> beanType,
OutputStream output,
String encoding,
String[] headers)
Writes a collection of annotated java beans to a given output.
|
<T> void |
writeAll(Iterable<T> elements,
Class<T> beanType,
Writer output,
String... headers)
Writes a collection of annotated java beans to a given output.
|
public AbstractRoutines(String routineDescription)
routineDescription
- description of the routines for a given formatpublic AbstractRoutines(String routineDescription, P parserSettings)
routineDescription
- description of the routines for a given formatparserSettings
- configuration to use for parsingpublic AbstractRoutines(String routineDescription, W writerSettings)
routineDescription
- description of the routines for a given formatwriterSettings
- configuration to use for writingpublic AbstractRoutines(String routineDescription, P parserSettings, W writerSettings)
routineDescription
- description of the routines for a given formatparserSettings
- configuration to use for parsingwriterSettings
- configuration to use for writingprotected abstract AbstractParser<P> createParser(P parserSettings)
parserSettings
- the configuration for new parserprotected abstract AbstractWriter<W> createWriter(Writer output, W writerSettings)
output
- target output of the routine.writerSettings
- the configuration for new writerprotected abstract P createDefaultParserSettings()
protected abstract W createDefaultWriterSettings()
public final P getParserSettings()
public final void setParserSettings(P parserSettings)
parserSettings
- the parser configuration.public final W getWriterSettings()
public final void setWriterSettings(W writerSettings)
writerSettings
- the parser configuration.protected void adjustColumnLengths(String[] headers, int[] lengths)
headers
- headers to be writtenlengths
- the corresponding lengths of each headerpublic final void write(ResultSet rs, File output)
ResultSet
into a file.public final void write(ResultSet rs, File output, String encoding)
ResultSet
into a file.public final void write(ResultSet rs, File output, Charset encoding)
ResultSet
into a file.public final void write(ResultSet rs, OutputStream output)
ResultSet
into an output stream.public final void write(ResultSet rs, OutputStream output, String encoding)
ResultSet
into an output stream.public final void write(ResultSet rs, OutputStream output, Charset encoding)
ResultSet
into an output stream.public final void parseAndWrite(Reader input, Writer output)
input
- the input data to be parsed using the settings provided in getParserSettings()
output
- the output into where the input data should be written, using the format provided in getWriterSettings()
public <T> void writeAll(Iterable<T> elements, Class<T> beanType, File output, String... headers)
T
- the type of element in the given collectionelements
- the elements to write to the outputbeanType
- the type of element in the given collectionoutput
- the output into which the given elements will be writtenheaders
- headers to use in the first row of the written result.public <T> void writeAll(Iterable<T> elements, Class<T> beanType, File output, String encoding, String[] headers)
T
- the type of element in the given collectionelements
- the elements to write to the outputbeanType
- the type of element in the given collectionoutput
- the output into which the given elements will be writtenencoding
- the output encoding to use for writingheaders
- headers to use in the first row of the written result.public <T> void writeAll(Iterable<T> elements, Class<T> beanType, File output, Charset encoding, String... headers)
T
- the type of element in the given collectionelements
- the elements to write to the outputbeanType
- the type of element in the given collectionoutput
- the output into which the given elements will be writtenencoding
- the output encoding to use for writingheaders
- headers to use in the first row of the written result.public <T> void writeAll(Iterable<T> elements, Class<T> beanType, OutputStream output, String... headers)
T
- the type of element in the given collectionelements
- the elements to write to the outputbeanType
- the type of element in the given collectionoutput
- the output into which the given elements will be writtenheaders
- headers to use in the first row of the written result.public <T> void writeAll(Iterable<T> elements, Class<T> beanType, OutputStream output, String encoding, String[] headers)
T
- the type of element in the given collectionelements
- the elements to write to the outputbeanType
- the type of element in the given collectionoutput
- the output into which the given elements will be writtenencoding
- the output encoding to use for writingheaders
- headers to use in the first row of the written result.public <T> void writeAll(Iterable<T> elements, Class<T> beanType, OutputStream output, Charset encoding, String... headers)
T
- the type of element in the given collectionelements
- the elements to write to the outputbeanType
- the type of element in the given collectionoutput
- the output into which the given elements will be writtenencoding
- the output encoding to use for writingheaders
- headers to use in the first row of the written result.public <T> void writeAll(Iterable<T> elements, Class<T> beanType, Writer output, String... headers)
T
- the type of element in the given collectionelements
- the elements to write to the outputbeanType
- the type of element in the given collectionoutput
- the output into which the given elements will be writtenheaders
- headers to use in the first row of the written result.public <T> List<T> parseAll(Class<T> beanType, File input, int expectedBeanCount)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the file to be parsedexpectedBeanCount
- 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
Iterable
that allows iterating over the input and producing instances of java beans on demand.public <T> List<T> parseAll(Class<T> beanType, File input, String encoding, int expectedBeanCount)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the file to be parsedencoding
- encoding of the given fileexpectedBeanCount
- 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
Iterable
that allows iterating over the input and producing instances of java beans on demand.public <T> List<T> parseAll(Class<T> beanType, File input, Charset encoding, int expectedBeanCount)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the file to be parsedencoding
- encoding of the given fileexpectedBeanCount
- 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
public <T> List<T> parseAll(Class<T> beanType, InputStream input, int expectedBeanCount)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the input stream to be parsedexpectedBeanCount
- 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
public <T> List<T> parseAll(Class<T> beanType, InputStream input, String encoding, int expectedBeanCount)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the input stream to be parsedencoding
- encoding of the given input streamexpectedBeanCount
- 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
public <T> List<T> parseAll(Class<T> beanType, InputStream input, Charset encoding, int expectedBeanCount)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the input stream to be parsedencoding
- encoding of the given input streamexpectedBeanCount
- 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
public <T> List<T> parseAll(Class<T> beanType, Reader input, int expectedBeanCount)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the input to be parsedexpectedBeanCount
- 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
public <T> List<T> parseAll(Class<T> beanType, File input)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the file to be parsedIterable
that allows iterating over the input and producing instances of java beans on demand.public <T> List<T> parseAll(Class<T> beanType, File input, String encoding)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the file to be parsedencoding
- encoding of the given fileIterable
that allows iterating over the input and producing instances of java beans on demand.public <T> List<T> parseAll(Class<T> beanType, File input, Charset encoding)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the file to be parsedencoding
- encoding of the given filepublic <T> List<T> parseAll(Class<T> beanType, InputStream input)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the input stream to be parsedpublic <T> List<T> parseAll(Class<T> beanType, InputStream input, String encoding)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the input stream to be parsedencoding
- encoding of the given input streampublic <T> List<T> parseAll(Class<T> beanType, InputStream input, Charset encoding)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the input stream to be parsedencoding
- encoding of the given input streampublic <T> List<T> parseAll(Class<T> beanType, Reader input)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the input to be parsedpublic <T> IterableResult<T,ParsingContext> iterate(Class<T> beanType, File input)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the file to be parsedIterable
that allows iterating over the input and producing instances of java beans on demand.public <T> IterableResult<T,ParsingContext> iterate(Class<T> beanType, File input, String encoding)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the file to be parsedencoding
- encoding of the given fileIterable
that allows iterating over the input and producing instances of java beans on demand.public <T> IterableResult<T,ParsingContext> iterate(Class<T> beanType, File input, Charset encoding)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the file to be parsedencoding
- encoding of the given fileIterable
that allows iterating over the input and producing instances of java beans on demand.public <T> IterableResult<T,ParsingContext> iterate(Class<T> beanType, InputStream input)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the input stream to be parsedIterable
that allows iterating over the input and producing instances of java beans on demand.public <T> IterableResult<T,ParsingContext> iterate(Class<T> beanType, InputStream input, String encoding)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the input stream to be parsedencoding
- encoding of the given input streamIterable
that allows iterating over the input and producing instances of java beans on demand.public <T> IterableResult<T,ParsingContext> iterate(Class<T> beanType, InputStream input, Charset encoding)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the input stream to be parsedencoding
- encoding of the given input streamIterable
that allows iterating over the input and producing instances of java beans on demand.public <T> IterableResult<T,ParsingContext> iterate(Class<T> beanType, Reader input)
T
- the type of java beans to be instantiated.beanType
- the type of java beans to be instantiated.input
- the input to be parsedIterable
that allows iterating over the input and producing instances of java beans on demand.public InputDimension getInputDimension(File input)
input
- the file to be parsedInputDimension
with information about the dimensions of the given input.public InputDimension getInputDimension(File input, String encoding)
input
- the file to be parsedencoding
- encoding of the given fileInputDimension
with information about the dimensions of the given input.public InputDimension getInputDimension(InputStream input)
input
- the input to be parsedInputDimension
with information about the dimensions of the given input.public InputDimension getInputDimension(InputStream input, String encoding)
input
- the input to be parsedencoding
- encoding of the given inputInputDimension
with information about the dimensions of the given input.public InputDimension getInputDimension(Reader input)
input
- the input to be parsedInputDimension
with information about the dimensions of the given input.public boolean getKeepResourcesOpen()
close()
(or any other cleanup method)
after a routine executes.public void setKeepResourcesOpen(boolean keepResourcesOpen)
keepResourcesOpen
- flag indicating whether to call the close()
(or any other cleanup method)
after a routine executes.public ColumnMapper getColumnMapper()
Parsed
nor
Nested
. Any mappings defined with the column mapper will take
precedence over these annotations.public void setColumnMapper(ColumnMapper columnMapper)
columnMapper
- the column mappings to useCopyright © 2020 Univocity Software Pty Ltd. All rights reserved.