Package csv.impl
Class AbstractTableWriter
java.lang.Object
csv.impl.AbstractTableWriter
- All Implemented Interfaces:
TableWriter
- Direct Known Subclasses:
AbstractStreamTableWriter
Abstract implementation of writer interface.
The interface provides basic functionality being needed regardless of underlying medium
to be written to.
- Author:
- ralph
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the writer.protected ObjectConverts the value to its stream representation.Returns the mapper.intReturns the rows written.protected intIncrements the row count.protected voidinit()General initialization.voidprintComment(String comment) Prints a comment into the output stream.voidprintComment(String comment, int row, int column) Prints a comment into the output stream.voidprintRow(Collection<?> columns) Prints a single row into the CSV stream.voidPrints a new row into the CSV stream.voidPrints a single row into the CSV stream.voidsetMapper(StreamMapper mapper) Sets the mapper.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface csv.TableWriter
printRow
-
Constructor Details
-
AbstractTableWriter
public AbstractTableWriter()
-
-
Method Details
-
init
protected void init()General initialization. This implementation does nothing. -
getMapper
Returns the mapper.- Returns:
- the mapper
-
setMapper
Sets the mapper.- Parameters:
mapper- the mapper to set
-
printComment
Prints a comment into the output stream. This implementation does nothing by default.- Specified by:
printCommentin interfaceTableWriter- Parameters:
comment- the comment to write- Throws:
IOException- when an exception occurs
-
printComment
Prints a comment into the output stream. This implementation does nothing by default.- Specified by:
printCommentin interfaceTableWriter- Parameters:
comment- the comment to writerow- index of row for commentcolumn- index of column for comment- Throws:
IOException- when an exception occurs
-
close
public void close()Closes the writer. This implementation does nothing.- Specified by:
closein interfaceTableWriter
-
getRowCount
public int getRowCount()Returns the rows written.- Returns:
- the rowCount
-
incrementRowCount
protected int incrementRowCount()Increments the row count.- Returns:
- current row count
-
convert
Converts the value to its stream representation.- Parameters:
value- object- Returns:
- stream representation
-
printRow
Prints a single row into the CSV stream. The columns are written to the CSV stream as the are delivered by the collection's iterator.- Specified by:
printRowin interfaceTableWriter- Parameters:
columns- collection of column values. An iterator will be used to retrieve values from the collection.- Throws:
IOException- when an exception occurs
-
printRow
Prints a single row into the CSV stream. The columns are written to the CSV stream as delivered by the iterator.- Specified by:
printRowin interfaceTableWriter- Parameters:
columns- iterator that returns column values.size- number of values to retrieve from iterator. Method will abort at this size.- Throws:
IOException- when an exception occurs
-
printRow
Prints a new row into the CSV stream. The columns are written to the CSV stream as delivered by the iterator.- Specified by:
printRowin interfaceTableWriter- Parameters:
columns- iterator that returns column values.- Throws:
IOException- when an exception occurs
-