|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.univocity.parsers.common.routine.AbstractRoutines<P,W>
P - parser configuration classW - writer configuration classpublic abstract class AbstractRoutines<P extends CommonParserSettings<?>,W extends CommonWriterSettings<?>>
Basic implementation of commonly used routines around parsing/writing of data that can be reused and extended by parsers/writers of any supported format.
| Constructor Summary | |
|---|---|
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. |
|
| Method Summary | ||
|---|---|---|
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 |
|
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. |
|
|
iterate(Class<T> beanType,
File input)
Iterates over a file to produce instances of annotated java beans on demand. |
|
|
iterate(Class<T> beanType,
File input,
Charset encoding)
Iterates over a file to produce instances of annotated java beans on demand. |
|
|
iterate(Class<T> beanType,
File input,
String encoding)
Iterates over a file to produce instances of annotated java beans on demand. |
|
|
iterate(Class<T> beanType,
InputStream input)
Iterates over an input stream to produce instances of annotated java beans on demand. |
|
|
iterate(Class<T> beanType,
InputStream input,
Charset encoding)
Iterates over an input stream to produce instances of annotated java beans on demand. |
|
|
iterate(Class<T> beanType,
InputStream input,
String encoding)
Iterates over an input stream to produce instances of annotated java beans on demand. |
|
|
iterate(Class<T> beanType,
Reader input)
Iterates over an input to produce instances of annotated java beans on demand. |
|
|
parseAll(Class<T> beanType,
File input)
Parses a file into a list of annotated java beans |
|
|
parseAll(Class<T> beanType,
File input,
Charset encoding)
Parses a file into a list of annotated java beans |
|
|
parseAll(Class<T> beanType,
File input,
Charset encoding,
int expectedBeanCount)
Parses a file into a list of annotated java beans |
|
|
parseAll(Class<T> beanType,
File input,
int expectedBeanCount)
Parses a file into a list of annotated java beans |
|
|
parseAll(Class<T> beanType,
File input,
String encoding)
Parses a file into a list of annotated java beans |
|
|
parseAll(Class<T> beanType,
File input,
String encoding,
int expectedBeanCount)
Parses a file into a list of annotated java beans |
|
|
parseAll(Class<T> beanType,
InputStream input)
Parses an input stream into a list of annotated java beans |
|
|
parseAll(Class<T> beanType,
InputStream input,
Charset encoding)
Parses an input stream into a list of annotated java beans |
|
|
parseAll(Class<T> beanType,
InputStream input,
Charset encoding,
int expectedBeanCount)
Parses an input stream into a list of annotated java beans |
|
|
parseAll(Class<T> beanType,
InputStream input,
int expectedBeanCount)
Parses an input stream into a list of annotated java beans |
|
|
parseAll(Class<T> beanType,
InputStream input,
String encoding)
Parses an input stream into a list of annotated java beans |
|
|
parseAll(Class<T> beanType,
InputStream input,
String encoding,
int expectedBeanCount)
Parses an input stream into a list of annotated java beans |
|
|
parseAll(Class<T> beanType,
Reader input)
Parses the input into a list of annotated java beans |
|
|
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 |
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. |
|
|
writeAll(Iterable<T> elements,
Class<T> beanType,
File output,
Charset encoding,
String... headers)
Writes a collection of annotated java beans to a given output. |
|
|
writeAll(Iterable<T> elements,
Class<T> beanType,
File output,
String... headers)
Writes a collection of annotated java beans to a given output. |
|
|
writeAll(Iterable<T> elements,
Class<T> beanType,
File output,
String encoding,
String[] headers)
Writes a collection of annotated java beans to a given output. |
|
|
writeAll(Iterable<T> elements,
Class<T> beanType,
OutputStream output,
Charset encoding,
String... headers)
Writes a collection of annotated java beans to a given output. |
|
|
writeAll(Iterable<T> elements,
Class<T> beanType,
OutputStream output,
String... headers)
Writes a collection of annotated java beans to a given output. |
|
|
writeAll(Iterable<T> elements,
Class<T> beanType,
OutputStream output,
String encoding,
String[] headers)
Writes a collection of annotated java beans to a given output. |
|
|
writeAll(Iterable<T> elements,
Class<T> beanType,
Writer output,
String... headers)
Writes a collection of annotated java beans to a given output. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractRoutines(String routineDescription)
routineDescription - description of the routines for a given format
public AbstractRoutines(String routineDescription,
P parserSettings)
routineDescription - description of the routines for a given formatparserSettings - configuration to use for parsing
public AbstractRoutines(String routineDescription,
W writerSettings)
routineDescription - description of the routines for a given formatwriterSettings - configuration to use for writing
public 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 writing| Method Detail |
|---|
protected abstract AbstractParser<P> createParser(P parserSettings)
parserSettings - the configuration for new parser
protected abstract AbstractWriter<W> createWriter(Writer output,
W writerSettings)
output - target output of the routine.writerSettings - the configuration for new writer
protected 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 header
public final void write(ResultSet rs,
File output)
ResultSet into a file.
rs - the ResultSet whose contents should be read and written to a given outputoutput - the output file that will store the data in the given ResultSet
in the format specified by concrete implementations of this class.
public final void write(ResultSet rs,
File output,
String encoding)
ResultSet into a file.
rs - the ResultSet whose contents should be read and written to a given outputoutput - the output file that will store the data in the given ResultSet
in the format specified by concrete implementations of this class.encoding - the output encoding of the file
public final void write(ResultSet rs,
File output,
Charset encoding)
ResultSet into a file.
rs - the ResultSet whose contents should be read and written to a given outputoutput - the output file that will store the data in the given ResultSet
in the format specified by concrete implementations of this class.encoding - the output encoding of the file
public final void write(ResultSet rs,
OutputStream output)
ResultSet into an output stream.
rs - the ResultSet whose contents should be read and written to a given outputoutput - the output stream that will store the data in the given ResultSet
in the format specified by concrete implementations of this class.
public final void write(ResultSet rs,
OutputStream output,
String encoding)
ResultSet into an output stream.
rs - the ResultSet whose contents should be read and written to a given outputoutput - the output file that will store the data in the given ResultSet
in the format specified by concrete implementations of this class.encoding - the output encoding of the output stream
public final void write(ResultSet rs,
OutputStream output,
Charset encoding)
ResultSet into an output stream.
rs - the ResultSet whose contents should be read and written to a given outputoutput - the output file that will store the data in the given ResultSet
in the format specified by concrete implementations of this class.encoding - the output encoding of the output stream
public final void write(ResultSet rs,
Writer output)
ResultSet.
rs - the ResultSet whose contents should be read and written to a given outputoutput - the output that will store the data in the given ResultSet
in the format specified by concrete implementations of this class.
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 parsed
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)
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 file
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)
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 file
public <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 parsed
public <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 stream
public <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 stream
public <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 parsed
public <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 parsed
Iterable 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 file
Iterable 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 file
Iterable 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 parsed
Iterable 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 stream
Iterable 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 stream
Iterable 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 parsed
Iterable that allows iterating over the input and producing instances of java beans on demand.public String toString()
toString in class Objectpublic InputDimension getInputDimension(File input)
input - the file to be parsed
InputDimension 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 file
InputDimension with information about the dimensions of the given input.public InputDimension getInputDimension(InputStream input)
input - the input to be parsed
InputDimension 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 input
InputDimension with information about the dimensions of the given input.public InputDimension getInputDimension(Reader input)
input - the input to be parsed
InputDimension 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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||