org.nuiton.util.csv
Class Export<E>

java.lang.Object
  extended by org.nuiton.util.csv.Export<E>

public class Export<E>
extends Object

Object to realize a export from a ExportModel and some datas.

Usefull static methods

There is some usefull methods here to do operation in one line :

To export to a file

     Export.exportToFile(model, data, file);
 

To export to a writer

     Export.exportToWriter(model, data, writer);
 

To export as a string

     String exportcontent = Export.exportToString(model, data);
 

To obtain a new instance of an exporter

     Export<E> exporter = Export.newExport(model, data);
 

Since:
2.4
Author:
bleny , tchemit

Field Summary
protected  Iterable<E> data
           
protected  ExportModel<E> model
           
 
Constructor Summary
protected Export(ExportModel<E> model, Iterable<E> data)
           
 
Method Summary
static
<E> void
exportToFile(ExportModel<E> model, Iterable<E> data, File file)
           
static
<E> void
exportToFile(ExportModel<E> model, Iterable<E> data, File file, Charset charset)
           
 void exportToFile(File file)
          Deprecated. since 2.4.3, use write(java.io.File) instead.
static
<E> String
exportToString(ExportModel<E> model, Iterable<E> data)
           
static
<E> String
exportToString(ExportModel<E> model, Iterable<E> data, Charset charset)
           
static
<E> void
exportToWriter(ExportModel<E> model, Iterable<E> data, Writer writer)
           
static
<E> Export<E>
newExport(ExportModel<E> model, Iterable<E> data)
           
 InputStream startExport()
          Deprecated. since 2.4.3. It's not the role of the API to give an InputStream you can use toString(java.nio.charset.Charset) and IOUtils.toInputStream(String)
 void startExport(Writer writer)
          Deprecated. since 2.4.3, use write(java.io.Writer) instead.
 String startExportAsString()
          Deprecated. since 2.4.3, use toString(java.nio.charset.Charset) instead.
 String toString(Charset charset)
           
 void write(File file)
           
 void write(File file, Charset charset)
           
 void write(OutputStream outputStream)
           
 void write(OutputStream outputStream, Charset charset)
           
 void write(Writer writer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

model

protected ExportModel<E> model

data

protected Iterable<E> data
Constructor Detail

Export

protected Export(ExportModel<E> model,
                 Iterable<E> data)
Method Detail

newExport

public static <E> Export<E> newExport(ExportModel<E> model,
                                      Iterable<E> data)

exportToWriter

public static <E> void exportToWriter(ExportModel<E> model,
                                      Iterable<E> data,
                                      Writer writer)
                           throws Exception
Throws:
Exception

exportToFile

public static <E> void exportToFile(ExportModel<E> model,
                                    Iterable<E> data,
                                    File file)
                         throws Exception
Throws:
Exception

exportToFile

public static <E> void exportToFile(ExportModel<E> model,
                                    Iterable<E> data,
                                    File file,
                                    Charset charset)
                         throws Exception
Throws:
Exception

exportToString

public static <E> String exportToString(ExportModel<E> model,
                                        Iterable<E> data)
                             throws Exception
Throws:
Exception

exportToString

public static <E> String exportToString(ExportModel<E> model,
                                        Iterable<E> data,
                                        Charset charset)
                             throws Exception
Throws:
Exception

write

public void write(Writer writer)
           throws Exception
Throws:
Exception

write

public void write(OutputStream outputStream,
                  Charset charset)
           throws Exception
Throws:
Exception

write

public void write(OutputStream outputStream)
           throws Exception
Throws:
Exception

write

public void write(File file,
                  Charset charset)
           throws Exception
Throws:
Exception

write

public void write(File file)
           throws Exception
Throws:
Exception

toString

public String toString(Charset charset)
                throws Exception
Throws:
Exception

exportToFile

@Deprecated
public void exportToFile(File file)
                  throws Exception
Deprecated. since 2.4.3, use write(java.io.File) instead.

Throws:
Exception

startExport

@Deprecated
public void startExport(Writer writer)
                 throws Exception
Deprecated. since 2.4.3, use write(java.io.Writer) instead.

Throws:
Exception

startExportAsString

@Deprecated
public String startExportAsString()
                           throws Exception
Deprecated. since 2.4.3, use toString(java.nio.charset.Charset) instead.

Throws:
Exception

startExport

@Deprecated
public InputStream startExport()
                        throws Exception
Deprecated. since 2.4.3. It's not the role of the API to give an InputStream you can use toString(java.nio.charset.Charset) and IOUtils.toInputStream(String)

Throws:
Exception


Copyright © 2011-2012 CodeLutin. All Rights Reserved.