Class AbstractRoutines<P extends CommonParserSettings<?>,W extends CommonWriterSettings<?>>
- java.lang.Object
-
- com.univocity.parsers.common.routine.AbstractRoutines<P,W>
-
- Type Parameters:
P
- parser configuration classW
- writer configuration class
- Direct Known Subclasses:
CsvRoutines
,FixedWidthRoutines
,TsvRoutines
public abstract class AbstractRoutines<P extends CommonParserSettings<?>,W extends CommonWriterSettings<?>> extends java.lang.Object
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
Fields Modifier and Type Field Description private ColumnMapping
columnMapper
private boolean
keepResourcesOpen
private P
parserSettings
private java.io.Writer
previousOutput
private java.lang.String
routineDescription
private W
writerSettings
-
Constructor Summary
Constructors Constructor Description AbstractRoutines(java.lang.String routineDescription)
Creates a new instance of this routine class.AbstractRoutines(java.lang.String routineDescription, P parserSettings)
Creates a new instance of this routine class.AbstractRoutines(java.lang.String routineDescription, P parserSettings, W writerSettings)
Creates a new instance of this routine class.AbstractRoutines(java.lang.String routineDescription, W writerSettings)
Creates a new instance of this routine class.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
adjustColumnLengths(java.lang.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.private void
close(AbstractWriter writer)
protected abstract P
createDefaultParserSettings()
Creates a default parser settings configurationprotected abstract W
createDefaultWriterSettings()
Creates a default writer settings configurationprotected abstract AbstractParser<P>
createParser(P parserSettings)
Creates a new parser implementation using the given parser configurationprotected abstract AbstractWriter<W>
createWriter(java.io.Writer output, W writerSettings)
Creates a new writer implementation using the given writer configurationprivate RowProcessor
createWritingRowProcessor(java.io.Writer output)
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(java.io.File input)
Calculates the dimensions of a file (row and column count).InputDimension
getInputDimension(java.io.File input, java.lang.String encoding)
Calculates the dimensions of a file (row and column count).InputDimension
getInputDimension(java.io.InputStream input)
Calculates the dimensions of a given input (row and column count).InputDimension
getInputDimension(java.io.InputStream input, java.lang.String encoding)
Calculates the dimensions of a given input (row and column count).InputDimension
getInputDimension(java.io.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(java.lang.Class<T> beanType, java.io.File input)
Iterates over a file to produce instances of annotated java beans on demand.<T> IterableResult<T,ParsingContext>
iterate(java.lang.Class<T> beanType, java.io.File input, java.lang.String encoding)
Iterates over a file to produce instances of annotated java beans on demand.<T> IterableResult<T,ParsingContext>
iterate(java.lang.Class<T> beanType, java.io.File input, java.nio.charset.Charset encoding)
Iterates over a file to produce instances of annotated java beans on demand.<T> IterableResult<T,ParsingContext>
iterate(java.lang.Class<T> beanType, java.io.InputStream input)
Iterates over an input stream to produce instances of annotated java beans on demand.<T> IterableResult<T,ParsingContext>
iterate(java.lang.Class<T> beanType, java.io.InputStream input, java.lang.String encoding)
Iterates over an input stream to produce instances of annotated java beans on demand.<T> IterableResult<T,ParsingContext>
iterate(java.lang.Class<T> beanType, java.io.InputStream input, java.nio.charset.Charset encoding)
Iterates over an input stream to produce instances of annotated java beans on demand.<T> IterableResult<T,ParsingContext>
iterate(java.lang.Class<T> beanType, java.io.Reader input)
Iterates over an input to produce instances of annotated java beans on demand.<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.File input)
Parses a file into a list of annotated java beans<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.File input, int expectedBeanCount)
Parses a file into a list of annotated java beans<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.File input, java.lang.String encoding)
Parses a file into a list of annotated java beans<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.File input, java.lang.String encoding, int expectedBeanCount)
Parses a file into a list of annotated java beans<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.File input, java.nio.charset.Charset encoding)
Parses a file into a list of annotated java beans<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.File input, java.nio.charset.Charset encoding, int expectedBeanCount)
Parses a file into a list of annotated java beans<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.InputStream input)
Parses an input stream into a list of annotated java beans<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.InputStream input, int expectedBeanCount)
Parses an input stream into a list of annotated java beans<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.InputStream input, java.lang.String encoding)
Parses an input stream into a list of annotated java beans<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.InputStream input, java.lang.String encoding, int expectedBeanCount)
Parses an input stream into a list of annotated java beans<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.InputStream input, java.nio.charset.Charset encoding)
Parses an input stream into a list of annotated java beans<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.InputStream input, java.nio.charset.Charset encoding, int expectedBeanCount)
Parses an input stream into a list of annotated java beans<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.Reader input)
Parses the input into a list of annotated java beans<T> java.util.List<T>
parseAll(java.lang.Class<T> beanType, java.io.Reader input, int expectedBeanCount)
Parses the input into a list of annotated java beansvoid
parseAndWrite(java.io.Reader input, java.io.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.private void
setRowProcessor(RowProcessor rowProcessor)
private void
setRowWriterProcessor(RowWriterProcessor rowWriterProcessor)
void
setWriterSettings(W writerSettings)
Defines the writer configuration to be used by the routines of this utility class.java.lang.String
toString()
private void
validateParserSettings()
private void
validateWriterSettings()
void
write(java.sql.ResultSet rs, java.io.File output)
Dumps the content of aResultSet
into a file.void
write(java.sql.ResultSet rs, java.io.File output, java.lang.String encoding)
Dumps the content of aResultSet
into a file.void
write(java.sql.ResultSet rs, java.io.File output, java.nio.charset.Charset encoding)
Dumps the content of aResultSet
into a file.void
write(java.sql.ResultSet rs, java.io.OutputStream output)
Dumps the content of aResultSet
into an output stream.void
write(java.sql.ResultSet rs, java.io.OutputStream output, java.lang.String encoding)
Dumps the content of aResultSet
into an output stream.void
write(java.sql.ResultSet rs, java.io.OutputStream output, java.nio.charset.Charset encoding)
Dumps the content of aResultSet
into an output stream.void
write(java.sql.ResultSet rs, java.io.Writer output)
Dumps the content of aResultSet
.<T> void
writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.File output, java.lang.String... headers)
Writes a collection of annotated java beans to a given output.<T> void
writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.File output, java.lang.String encoding, java.lang.String[] headers)
Writes a collection of annotated java beans to a given output.<T> void
writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.File output, java.nio.charset.Charset encoding, java.lang.String... headers)
Writes a collection of annotated java beans to a given output.<T> void
writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.OutputStream output, java.lang.String... headers)
Writes a collection of annotated java beans to a given output.<T> void
writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.OutputStream output, java.lang.String encoding, java.lang.String[] headers)
Writes a collection of annotated java beans to a given output.<T> void
writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.OutputStream output, java.nio.charset.Charset encoding, java.lang.String... headers)
Writes a collection of annotated java beans to a given output.<T> void
writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.Writer output, java.lang.String... headers)
Writes a collection of annotated java beans to a given output.
-
-
-
Field Detail
-
keepResourcesOpen
private boolean keepResourcesOpen
-
previousOutput
private java.io.Writer previousOutput
-
columnMapper
private ColumnMapping columnMapper
-
routineDescription
private final java.lang.String routineDescription
-
parserSettings
private P extends CommonParserSettings<?> parserSettings
-
writerSettings
private W extends CommonWriterSettings<?> writerSettings
-
-
Constructor Detail
-
AbstractRoutines
public AbstractRoutines(java.lang.String routineDescription)
Creates a new instance of this routine class.- Parameters:
routineDescription
- description of the routines for a given format
-
AbstractRoutines
public AbstractRoutines(java.lang.String routineDescription, P parserSettings)
Creates a new instance of this routine class.- Parameters:
routineDescription
- description of the routines for a given formatparserSettings
- configuration to use for parsing
-
AbstractRoutines
public AbstractRoutines(java.lang.String routineDescription, W writerSettings)
Creates a new instance of this routine class.- Parameters:
routineDescription
- description of the routines for a given formatwriterSettings
- configuration to use for writing
-
AbstractRoutines
public AbstractRoutines(java.lang.String routineDescription, P parserSettings, W writerSettings)
Creates a new instance of this routine class.- Parameters:
routineDescription
- description of the routines for a given formatparserSettings
- configuration to use for parsingwriterSettings
- configuration to use for writing
-
-
Method Detail
-
createParser
protected abstract AbstractParser<P> createParser(P parserSettings)
Creates a new parser implementation using the given parser configuration- Parameters:
parserSettings
- the configuration for new parser- Returns:
- a parser implementation configured according to the given settings object.
-
createWriter
protected abstract AbstractWriter<W> createWriter(java.io.Writer output, W writerSettings)
Creates a new writer implementation using the given writer configuration- Parameters:
output
- target output of the routine.writerSettings
- the configuration for new writer- Returns:
- a writer implementation configured according to the given settings object.
-
createDefaultParserSettings
protected abstract P createDefaultParserSettings()
Creates a default parser settings configuration- Returns:
- a new instance of a usable parser configuration.
-
createDefaultWriterSettings
protected abstract W createDefaultWriterSettings()
Creates a default writer settings configuration- Returns:
- a new instance of a usable writer configuration.
-
validateWriterSettings
private void validateWriterSettings()
-
validateParserSettings
private void validateParserSettings()
-
getParserSettings
public final P getParserSettings()
Returns the parser configuration (if any) used by the routines of this utility class.- Returns:
- the parser configuration.
-
setParserSettings
public final void setParserSettings(P parserSettings)
Defines the parser configuration to be used by the routines of this utility class.- Parameters:
parserSettings
- the parser configuration.
-
getWriterSettings
public final W getWriterSettings()
Returns the writer configuration (if any) used by the routines of this utility class.- Returns:
- the writer configuration.
-
setWriterSettings
public final void setWriterSettings(W writerSettings)
Defines the writer configuration to be used by the routines of this utility class.- Parameters:
writerSettings
- the parser configuration.
-
adjustColumnLengths
protected void adjustColumnLengths(java.lang.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.- Parameters:
headers
- headers to be writtenlengths
- the corresponding lengths of each header
-
write
public final void write(java.sql.ResultSet rs, java.io.File output)
Dumps the content of aResultSet
into a file.- Parameters:
rs
- theResultSet
whose contents should be read and written to a given outputoutput
- the output file that will store the data in the givenResultSet
in the format specified by concrete implementations of this class.
-
write
public final void write(java.sql.ResultSet rs, java.io.File output, java.lang.String encoding)
Dumps the content of aResultSet
into a file.- Parameters:
rs
- theResultSet
whose contents should be read and written to a given outputoutput
- the output file that will store the data in the givenResultSet
in the format specified by concrete implementations of this class.encoding
- the output encoding of the file
-
write
public final void write(java.sql.ResultSet rs, java.io.File output, java.nio.charset.Charset encoding)
Dumps the content of aResultSet
into a file.- Parameters:
rs
- theResultSet
whose contents should be read and written to a given outputoutput
- the output file that will store the data in the givenResultSet
in the format specified by concrete implementations of this class.encoding
- the output encoding of the file
-
write
public final void write(java.sql.ResultSet rs, java.io.OutputStream output)
Dumps the content of aResultSet
into an output stream.- Parameters:
rs
- theResultSet
whose contents should be read and written to a given outputoutput
- the output stream that will store the data in the givenResultSet
in the format specified by concrete implementations of this class.
-
write
public final void write(java.sql.ResultSet rs, java.io.OutputStream output, java.lang.String encoding)
Dumps the content of aResultSet
into an output stream.- Parameters:
rs
- theResultSet
whose contents should be read and written to a given outputoutput
- the output file that will store the data in the givenResultSet
in the format specified by concrete implementations of this class.encoding
- the output encoding of the output stream
-
write
public final void write(java.sql.ResultSet rs, java.io.OutputStream output, java.nio.charset.Charset encoding)
Dumps the content of aResultSet
into an output stream.- Parameters:
rs
- theResultSet
whose contents should be read and written to a given outputoutput
- the output file that will store the data in the givenResultSet
in the format specified by concrete implementations of this class.encoding
- the output encoding of the output stream
-
write
public final void write(java.sql.ResultSet rs, java.io.Writer output)
Dumps the content of aResultSet
.- Parameters:
rs
- theResultSet
whose contents should be read and written to a given outputoutput
- the output that will store the data in the givenResultSet
in the format specified by concrete implementations of this class.
-
parseAndWrite
public final void parseAndWrite(java.io.Reader input, java.io.Writer output)
Reads all data from a given input and writes it to an output.- Parameters:
input
- the input data to be parsed using the settings provided ingetParserSettings()
output
- the output into where the input data should be written, using the format provided ingetWriterSettings()
-
setRowWriterProcessor
private void setRowWriterProcessor(RowWriterProcessor rowWriterProcessor)
-
setRowProcessor
private void setRowProcessor(RowProcessor rowProcessor)
-
createWritingRowProcessor
private RowProcessor createWritingRowProcessor(java.io.Writer output)
-
close
private void close(AbstractWriter writer)
-
writeAll
public <T> void writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.File output, java.lang.String... headers)
Writes a collection of annotated java beans to a given output.- Type Parameters:
T
- the type of element in the given collection- Parameters:
elements
- 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.
-
writeAll
public <T> void writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.File output, java.lang.String encoding, java.lang.String[] headers)
Writes a collection of annotated java beans to a given output.- Type Parameters:
T
- the type of element in the given collection- Parameters:
elements
- 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.
-
writeAll
public <T> void writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.File output, java.nio.charset.Charset encoding, java.lang.String... headers)
Writes a collection of annotated java beans to a given output.- Type Parameters:
T
- the type of element in the given collection- Parameters:
elements
- 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.
-
writeAll
public <T> void writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.OutputStream output, java.lang.String... headers)
Writes a collection of annotated java beans to a given output.- Type Parameters:
T
- the type of element in the given collection- Parameters:
elements
- 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.
-
writeAll
public <T> void writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.OutputStream output, java.lang.String encoding, java.lang.String[] headers)
Writes a collection of annotated java beans to a given output.- Type Parameters:
T
- the type of element in the given collection- Parameters:
elements
- 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.
-
writeAll
public <T> void writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.OutputStream output, java.nio.charset.Charset encoding, java.lang.String... headers)
Writes a collection of annotated java beans to a given output.- Type Parameters:
T
- the type of element in the given collection- Parameters:
elements
- 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.
-
writeAll
public <T> void writeAll(java.lang.Iterable<T> elements, java.lang.Class<T> beanType, java.io.Writer output, java.lang.String... headers)
Writes a collection of annotated java beans to a given output.- Type Parameters:
T
- the type of element in the given collection- Parameters:
elements
- 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.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.File input, int expectedBeanCount)
Parses a file into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
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 outputList
- Returns:
- an
Iterable
that allows iterating over the input and producing instances of java beans on demand.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.File input, java.lang.String encoding, int expectedBeanCount)
Parses a file into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
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 outputList
- Returns:
- an
Iterable
that allows iterating over the input and producing instances of java beans on demand.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.File input, java.nio.charset.Charset encoding, int expectedBeanCount)
Parses a file into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
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 outputList
- Returns:
- a list containing all java beans read from the input.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.InputStream input, int expectedBeanCount)
Parses an input stream into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
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 outputList
- Returns:
- a list containing all java beans read from the input.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.InputStream input, java.lang.String encoding, int expectedBeanCount)
Parses an input stream into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
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 outputList
- Returns:
- a list containing all java beans read from the input.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.InputStream input, java.nio.charset.Charset encoding, int expectedBeanCount)
Parses an input stream into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
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 outputList
- Returns:
- a list containing all java beans read from the input.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.Reader input, int expectedBeanCount)
Parses the input into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
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 outputList
- Returns:
- a list containing all java beans read from the input.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.File input)
Parses a file into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the file to be parsed- Returns:
- an
Iterable
that allows iterating over the input and producing instances of java beans on demand.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.File input, java.lang.String encoding)
Parses a file into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the file to be parsedencoding
- encoding of the given file- Returns:
- an
Iterable
that allows iterating over the input and producing instances of java beans on demand.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.File input, java.nio.charset.Charset encoding)
Parses a file into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the file to be parsedencoding
- encoding of the given file- Returns:
- a list containing all java beans read from the input.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.InputStream input)
Parses an input stream into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the input stream to be parsed- Returns:
- a list containing all java beans read from the input.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.InputStream input, java.lang.String encoding)
Parses an input stream into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the input stream to be parsedencoding
- encoding of the given input stream- Returns:
- a list containing all java beans read from the input.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.InputStream input, java.nio.charset.Charset encoding)
Parses an input stream into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the input stream to be parsedencoding
- encoding of the given input stream- Returns:
- a list containing all java beans read from the input.
-
parseAll
public <T> java.util.List<T> parseAll(java.lang.Class<T> beanType, java.io.Reader input)
Parses the input into a list of annotated java beans- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the input to be parsed- Returns:
- a list containing all java beans read from the input.
-
iterate
public <T> IterableResult<T,ParsingContext> iterate(java.lang.Class<T> beanType, java.io.File input)
Iterates over a file to produce instances of annotated java beans on demand.- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the file to be parsed- Returns:
- an
Iterable
that allows iterating over the input and producing instances of java beans on demand.
-
iterate
public <T> IterableResult<T,ParsingContext> iterate(java.lang.Class<T> beanType, java.io.File input, java.lang.String encoding)
Iterates over a file to produce instances of annotated java beans on demand.- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the file to be parsedencoding
- encoding of the given file- Returns:
- an
Iterable
that allows iterating over the input and producing instances of java beans on demand.
-
iterate
public <T> IterableResult<T,ParsingContext> iterate(java.lang.Class<T> beanType, java.io.File input, java.nio.charset.Charset encoding)
Iterates over a file to produce instances of annotated java beans on demand.- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the file to be parsedencoding
- encoding of the given file- Returns:
- an
Iterable
that allows iterating over the input and producing instances of java beans on demand.
-
iterate
public <T> IterableResult<T,ParsingContext> iterate(java.lang.Class<T> beanType, java.io.InputStream input)
Iterates over an input stream to produce instances of annotated java beans on demand.- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the input stream to be parsed- Returns:
- an
Iterable
that allows iterating over the input and producing instances of java beans on demand.
-
iterate
public <T> IterableResult<T,ParsingContext> iterate(java.lang.Class<T> beanType, java.io.InputStream input, java.lang.String encoding)
Iterates over an input stream to produce instances of annotated java beans on demand.- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the input stream to be parsedencoding
- encoding of the given input stream- Returns:
- an
Iterable
that allows iterating over the input and producing instances of java beans on demand.
-
iterate
public <T> IterableResult<T,ParsingContext> iterate(java.lang.Class<T> beanType, java.io.InputStream input, java.nio.charset.Charset encoding)
Iterates over an input stream to produce instances of annotated java beans on demand.- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the input stream to be parsedencoding
- encoding of the given input stream- Returns:
- an
Iterable
that allows iterating over the input and producing instances of java beans on demand.
-
iterate
public <T> IterableResult<T,ParsingContext> iterate(java.lang.Class<T> beanType, java.io.Reader input)
Iterates over an input to produce instances of annotated java beans on demand.- Type Parameters:
T
- the type of java beans to be instantiated.- Parameters:
beanType
- the type of java beans to be instantiated.input
- the input to be parsed- Returns:
- an
Iterable
that allows iterating over the input and producing instances of java beans on demand.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getInputDimension
public InputDimension getInputDimension(java.io.File input)
Calculates the dimensions of a file (row and column count).- Parameters:
input
- the file to be parsed- Returns:
- a
InputDimension
with information about the dimensions of the given input.
-
getInputDimension
public InputDimension getInputDimension(java.io.File input, java.lang.String encoding)
Calculates the dimensions of a file (row and column count).- Parameters:
input
- the file to be parsedencoding
- encoding of the given file- Returns:
- a
InputDimension
with information about the dimensions of the given input.
-
getInputDimension
public InputDimension getInputDimension(java.io.InputStream input)
Calculates the dimensions of a given input (row and column count).- Parameters:
input
- the input to be parsed- Returns:
- a
InputDimension
with information about the dimensions of the given input.
-
getInputDimension
public InputDimension getInputDimension(java.io.InputStream input, java.lang.String encoding)
Calculates the dimensions of a given input (row and column count).- Parameters:
input
- the input to be parsedencoding
- encoding of the given input- Returns:
- a
InputDimension
with information about the dimensions of the given input.
-
getInputDimension
public InputDimension getInputDimension(java.io.Reader input)
Calculates the dimensions of a given input (row and column count).- Parameters:
input
- the input to be parsed- Returns:
- a
InputDimension
with information about the dimensions of the given input.
-
getKeepResourcesOpen
public 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.- Returns:
- flag indicating whether to call the
close()
(or any other cleanup method) after a routine executes.
-
setKeepResourcesOpen
public 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.- Parameters:
keepResourcesOpen
- flag indicating whether to call theclose()
(or any other cleanup method) after a routine executes.
-
getColumnMapper
public 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. This allows users to use instances of classes that are not annotated withParsed
norNested
. Any mappings defined with the column mapper will take precedence over these annotations.- Returns:
- the column mapper
-
setColumnMapper
public void setColumnMapper(ColumnMapper columnMapper)
Copies the given column mappings over to this processor. Further changes to the given object won't be reflected on the copy stored internally.- Parameters:
columnMapper
- the column mappings to use
-
-