Record
- the class used for a record, that is printed to a CSV filepublic abstract class CsvPrinter<Record extends CsvRecord> extends Object implements Closeable, Flushable
Modifier | Constructor and Description |
---|---|
protected |
CsvPrinter(org.apache.commons.csv.CSVPrinter printer)
Create with specifications of a
CSVPrinter . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the printer instance.
|
void |
closeQuietly()
Closes the printer instance without throwing exceptions.
|
void |
flush()
Flushes the printer instance.
|
protected void |
print(String value)
Prints a single CSV value.
|
protected void |
printComment(String comment)
Prints a comment.
|
protected void |
println()
Prints a record separator (line break).
|
void |
printRecord(Record record)
Print a
CsvRecord followed by a record separator (line break). |
void |
printRecords(Iterable<Record> records)
Print multiple
CsvRecord objects. |
protected static String |
replaceLineBreaks(String value)
Helper function to replace line breaks in a string with <br/> before
printing.
|
protected static String |
replaceLineBreaks(String value,
String lineBreak)
Helper function to replace line breaks in a string with a custom value
before printing.
|
protected CsvPrinter(org.apache.commons.csv.CSVPrinter printer)
CSVPrinter
.printer
- the CSV printer from
commons-csvpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
- if closing failedpublic final void closeQuietly()
public void flush() throws IOException
flush
in interface Flushable
IOException
- if flushing failedprotected void print(String value) throws IOException
value
- CSV value to printIOException
- if printing failedprotected void println() throws IOException
IOException
- if printing failedprotected void printComment(String comment) throws IOException
comment
- comment to printIOException
- if printing failedpublic void printRecord(Record record) throws IOException
CsvRecord
followed by a record separator (line break).record
- record to printIOException
- if printing failedpublic void printRecords(Iterable<Record> records) throws IOException
CsvRecord
objects.records
- records to printIOException
- if printing failedprotected static String replaceLineBreaks(String value)
This method may be used by inheriting classes, if the particular format does not support line breaks.
value
- value to replaceprotected static String replaceLineBreaks(String value, String lineBreak)
This method may be used by inheriting classes, if the particular format does not support line breaks.
value
- value to replacelineBreak
- value, that is used for replacement of line breaks - if null, <br/>
is usedCopyright © 2015 OpenEstate. All rights reserved.