Class Exporter<O>
java.lang.Object
org.nuiton.csv.Exporter<O>
Exporter contains a configuration and is ready to export some data.
Exporter construction
To create a new exporter, you need to use an ExporterBuilder.
There is some useful methods such as of(ExporterConfiguration) or of(ExportModel) to
obtain directly an exporter from a legacy export model or a exporter configuration.
There is also other method to create a new export builder such as builder(), builder(ExporterConfiguration) or
builder(ExportModel). Once this is done, use the ExporterBuilder API.
Exporter usage
Once you have an exporter, use one of the methodexportTo...(...) methods.
You can export to
- File
- String
- OutputStream
- Writer
- InputStream
- Reader
- Since:
- 3.0
- Author:
- Tony Chemit - chemit@codelutin.com
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ExporterConfiguration<O> Immutable exporter configuration. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <O> ExporterBuilder<O> builder()Creates a new empty exporter builder.static <O> ExporterBuilder<O> builder(ExporterConfiguration<O> configuration) Creates a new exporter builder from the given configuration.static <O> ExporterBuilder<O> builder(ExportModel<O> model) Creates a new exporter builder from the given model.static <O> Exporter<O> of(ExporterConfiguration<O> configuration) Creates an exporter from the given configuration.static <O> Exporter<O> of(ExportModel<O> model) Creates an exporter from the given model, and using default configuration values.Creates a new exporter builder from this exporter (to reuse his configuration).voidProduces the cvs of the givendatainto the givenfile.voidProduces the cvs of the givendatainto the givenfile.voidtoFileWithoutHeader(Iterable<O> data, File file) Produces the cvs (without header) of the givendatainto the givenfile.toInputStream(Iterable<O> data) Produces the cvs of the givendataand returns it as aInputStream.toInputStream(Iterable<O> data, boolean writeHeader) Produces the cvs (without header) of the givendataand returns it as aInputStream.toInputStreamWithoutHeader(Iterable<O> data) Produces the cvs (without header) of the givendataand returns it as aInputStream.voidtoOutputStream(Iterable<O> data, boolean writeHeader, OutputStream outputStream) Produces the cvs of the givendatainto the givenoutputStream.voidtoOutputStream(Iterable<O> data, OutputStream outputStream) Produces the cvs of the givendatainto the givenoutputStream.voidtoOutputStreamWithoutHeader(Iterable<O> data, OutputStream outputStream) Produces the cvs (without header) of the givendatainto the givenoutputStream.Produces the cvs of the givendataand returns it as aReader.Produces the cvs (without header) of the givendataand returns it as aReader.toReaderWithoutHeader(Iterable<O> data) Produces the cvs (without header) of the givendataand returns it as aReader.Produces the cvs of the givendataand returns it as aString.Produces the cvs of the givendataand returns it as aString.toStringWithoutHeader(Iterable<O> data) Produces the cvs (without header) of the givendataand returns it as aString.voidProduces the cvs of the givendatainto the givenwriter.voidProduces the cvs of the givendatainto the givenwriter.voidtoWriterWithoutHeader(Iterable<O> data, Writer writer) Produces the cvs (without header) of the givendatainto the givenwriter.
-
Field Details
-
configuration
Immutable exporter configuration.
-
-
Constructor Details
-
Exporter
-
-
Method Details
-
of
Creates an exporter from the given model, and using default configuration values.- Type Parameters:
O- type of data to export- Parameters:
model- model of export- Returns:
- the exporter ready to use
-
of
Creates an exporter from the given configuration.- Type Parameters:
O- type of data to export- Parameters:
configuration- export configuration- Returns:
- the exporter ready to use
-
builder
Creates a new exporter builder from the given model.- Type Parameters:
O- type of data to export- Parameters:
model- model of export- Returns:
- the exporter builder
-
builder
Creates a new exporter builder from the given configuration.- Type Parameters:
O- type of data to export- Parameters:
configuration- configuration of export- Returns:
- the exporter builder
-
builder
Creates a new empty exporter builder.- Returns:
- the exporter builder
-
toOutputStream
Produces the cvs of the givendatainto the givenoutputStream.- Parameters:
data- data to exportoutputStream- where to perform the export- Throws:
IOException
-
toOutputStreamWithoutHeader
public void toOutputStreamWithoutHeader(Iterable<O> data, OutputStream outputStream) throws IOException Produces the cvs (without header) of the givendatainto the givenoutputStream.- Parameters:
data- data to exportoutputStream- where to perform the export- Throws:
IOException
-
toOutputStream
public void toOutputStream(Iterable<O> data, boolean writeHeader, OutputStream outputStream) throws IOException Produces the cvs of the givendatainto the givenoutputStream.- Parameters:
data- data to exportwriteHeader- write or not header (first line of the export)outputStream- where to perform the export- Throws:
IOException
-
toWriter
Produces the cvs of the givendatainto the givenwriter.- Parameters:
data- data to exportwriter- where to perform the export- Throws:
IOException
-
toWriterWithoutHeader
Produces the cvs (without header) of the givendatainto the givenwriter.- Parameters:
data- data to exportwriter- where to perform the export- Throws:
IOException
-
toWriter
Produces the cvs of the givendatainto the givenwriter.- Parameters:
data- data to exportwriteHeader- write or not header (first line of the export)writer- where to perform the export- Throws:
IOException
-
toFile
Produces the cvs of the givendatainto the givenfile.- Parameters:
data- data to exportfile- where to perform the export- Throws:
IOException
-
toFileWithoutHeader
Produces the cvs (without header) of the givendatainto the givenfile.- Parameters:
data- data to exportfile- where to perform the export- Throws:
IOException
-
toFile
Produces the cvs of the givendatainto the givenfile.- Parameters:
data- data to exportwriteHeader- write or not header (first line of the export)file- where to perform the export- Throws:
IOException
-
toString
Produces the cvs of the givendataand returns it as aString.- Parameters:
data- data to export- Returns:
- the string of the csv
- Throws:
IOException
-
toStringWithoutHeader
Produces the cvs (without header) of the givendataand returns it as aString.- Parameters:
data- data to export- Returns:
- the string of the csv
- Throws:
IOException
-
toString
Produces the cvs of the givendataand returns it as aString.- Parameters:
data- data to exportwriteHeader- write or not header (first line of the export)- Returns:
- the string of the csv
- Throws:
IOException
-
toReader
Produces the cvs of the givendataand returns it as aReader.- Parameters:
data- data to export- Returns:
- the string of the csv
- Throws:
IOException
-
toReaderWithoutHeader
Produces the cvs (without header) of the givendataand returns it as aReader.- Parameters:
data- data to export- Returns:
- the string of the csv
- Throws:
IOException
-
toReader
Produces the cvs (without header) of the givendataand returns it as aReader.- Parameters:
data- data to exportwriteHeader- write or not header (first line of the export)- Returns:
- the string of the csv
- Throws:
IOException
-
toInputStream
Produces the cvs of the givendataand returns it as aInputStream.- Parameters:
data- data to export- Returns:
- the string of the csv
- Throws:
IOException
-
toInputStreamWithoutHeader
Produces the cvs (without header) of the givendataand returns it as aInputStream.- Parameters:
data- data to export- Returns:
- the string of the csv
- Throws:
IOException
-
toInputStream
Produces the cvs (without header) of the givendataand returns it as aInputStream.- Parameters:
data- data to export- Returns:
- the string of the csv
- Throws:
IOException
-
toBuilder
Creates a new exporter builder from this exporter (to reuse his configuration).- Returns:
- the exporter builder
-