- java.lang.Object
-
- org.refcodes.tabular.CsvRecordWriter<T>
-
- Type Parameters:
T
- The type of theRecord
instances being used.
- All Implemented Interfaces:
AutoCloseable
,org.refcodes.io.RowWriter<T[]>
,org.refcodes.mixin.DelimiterAccessor
,org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<org.refcodes.textual.CsvMixin>
,org.refcodes.mixin.DelimiterAccessor.DelimiterMutator
,org.refcodes.mixin.DelimiterAccessor.DelimiterProperty
,org.refcodes.mixin.TrimAccessor
,org.refcodes.mixin.TrimAccessor.TrimBuilder<org.refcodes.textual.CsvMixin>
,org.refcodes.mixin.TrimAccessor.TrimMutator
,org.refcodes.mixin.TrimAccessor.TrimProperty
,HeaderAccessor<T>
,RecordWriter<T>
,org.refcodes.textual.CsvEscapeModeAccessor
,org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeBuilder<org.refcodes.textual.CsvMixin>
,org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeMutator
,org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeProperty
,org.refcodes.textual.CsvMixin
- Direct Known Subclasses:
CsvStringRecordWriter
public class CsvRecordWriter<T> extends Object implements org.refcodes.textual.CsvMixin, RecordWriter<T>
TheCsvRecordWriter
writes CSV-Data.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.textual.CsvEscapeModeAccessor
org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeBuilder<B extends org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeBuilder<?>>, org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeMutator, org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeProperty
-
Nested classes/interfaces inherited from interface org.refcodes.mixin.DelimiterAccessor
org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B extends org.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<B>>, org.refcodes.mixin.DelimiterAccessor.DelimiterMutator, org.refcodes.mixin.DelimiterAccessor.DelimiterProperty
-
Nested classes/interfaces inherited from interface org.refcodes.tabular.HeaderAccessor
HeaderAccessor.HeaderBuilder<T extends HeaderAccessor.HeaderBuilder<?>>, HeaderAccessor.HeaderMutator<T>, HeaderAccessor.HeaderProperty<T>
-
-
Field Summary
Fields Modifier and Type Field Description protected org.refcodes.textual.CsvBuilder
_csvBuilder
protected Header<T>
_header
protected PrintStream
_outputStream
-
Constructor Summary
Constructors Modifier Constructor Description CsvRecordWriter(File aCsvFile)
Constructs aCsvRecordWriter
.CsvRecordWriter(File aCsvFile, char aCsvDelimiter)
Constructs aCsvRecordWriter
.CsvRecordWriter(File aCsvFile, Charset aEncoding)
Constructs aCsvRecordWriter
.CsvRecordWriter(File aCsvFile, Charset aEncoding, char aCsvDelimiter)
Constructs aCsvRecordWriter
.CsvRecordWriter(OutputStream aCsvOutputStream)
Constructs aCsvRecordWriter
.CsvRecordWriter(OutputStream aCsvOutputStream, Charset aEncoding)
Constructs aCsvRecordWriter
.CsvRecordWriter(PrintStream aPrintStream)
Constructs aCsvRecordWriter
.CsvRecordWriter(ColumnFactory<T> aColumnFactory, File aCsvFile)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(ColumnFactory<T> aColumnFactory, File aCsvFile, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(ColumnFactory<T> aColumnFactory, File aCsvFile, Charset aEncoding)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(ColumnFactory<T> aColumnFactory, File aCsvFile, Charset aEncoding, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(ColumnFactory<T> aColumnFactory, OutputStream aCsvOutputStream)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(ColumnFactory<T> aColumnFactory, OutputStream aCsvOutputStream, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(ColumnFactory<T> aColumnFactory, OutputStream aCsvOutputStream, Charset aEncoding)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(ColumnFactory<T> aColumnFactory, OutputStream aCsvOutputStream, Charset aEncoding, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(ColumnFactory<T> aColumnFactory, PrintStream aPrintStream)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(ColumnFactory<T> aColumnFactory, PrintStream aPrintStream, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(Header<T> aHeader, File aCsvFile)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(Header<T> aHeader, File aCsvFile, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(Header<T> aHeader, File aCsvFile, Charset aEncoding)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(Header<T> aHeader, File aCsvFile, Charset aEncoding, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(Header<T> aHeader, OutputStream aCsvOutputStream)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(Header<T> aHeader, OutputStream aCsvOutputStream, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(Header<T> aHeader, OutputStream aCsvOutputStream, Charset aEncoding)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(Header<T> aHeader, OutputStream aCsvOutputStream, Charset aEncoding, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(Header<T> aHeader, PrintStream aPrintStream)
Constructs aCsvRecordWriter
with the given header for logging.CsvRecordWriter(Header<T> aHeader, PrintStream aPrintStream, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.protected
CsvRecordWriter(Header<T> aHeader, ColumnFactory<T> aColumnFactory, PrintStream aPrintStream, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCommentPrefixes()
void
close()
String[]
getCommentPrefixes()
org.refcodes.textual.CsvEscapeMode
getCsvEscapeMode()
char
getDelimiter()
Header<T>
getHeader()
Retrieves theHeader
property.boolean
isTrim()
void
parseHeader(String... aHeader)
void
setCommentPrefixes(String... aCommentPrefixes)
void
setCsvEscapeMode(org.refcodes.textual.CsvEscapeMode aCsvEscapeMode)
void
setDelimiter(char aCsvDelimiter)
void
setTrim(boolean isTrim)
CsvRecordWriter<T>
withCommentPrefixes(String... aCommentPrefixes)
CsvRecordWriter<T>
withCsvEscapeMode(org.refcodes.textual.CsvEscapeMode aCsvEscapeMode)
CsvRecordWriter<T>
withDelimiter(char aCsvDelimiter)
CsvRecordWriter<T>
withTrim(boolean isTrimRecords)
void
writeComment(String aComment)
Writes a comment by using the fist defined comment prefix as ofgetCommentPrefixes()
suffixed with a space (" ") followed by the comment (as of theCsvMixin.toComment(String)
).void
writeHeader()
Writes the CSV header to the writer (be it a Stream or a File).void
writeHeader(String... aHeader)
void
writeHeader(Header<T> aHeader)
Sets and writes the providedHeader
to the writer (be it a Stream or a File). .void
writeHeaderComment()
void
writeHeaderComment(String... aHeader)
void
writeHeaderComment(Header<T> aHeader)
void
writeNext(Record<T> aRecord)
Directly logs the providedString
instances to the writer.void
writeNext(T... aRecord)
Directly logs the provided instances to the writer.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeProperty
letCsvEscapeMode
-
Methods inherited from interface org.refcodes.mixin.DelimiterAccessor.DelimiterProperty
letDelimiter
-
Methods inherited from interface org.refcodes.tabular.RecordWriter
writeNextLine, writeNextType
-
-
-
-
Field Detail
-
_outputStream
protected PrintStream _outputStream
-
_csvBuilder
protected org.refcodes.textual.CsvBuilder _csvBuilder
-
-
Constructor Detail
-
CsvRecordWriter
public CsvRecordWriter(Header<T> aHeader, File aCsvFile) throws FileNotFoundException
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aHeader
- The header used for logging in the correct format.aCsvFile
- TheFile
to be used for printing.- Throws:
FileNotFoundException
- If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file.
-
CsvRecordWriter
public CsvRecordWriter(Header<T> aHeader, File aCsvFile, char aCsvDelimiter) throws FileNotFoundException
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aHeader
- The header used for logging in the correct format.aCsvFile
- TheFile
to be used for printing.aCsvDelimiter
- The separator to be used when separating the CSV values in the log output.- Throws:
FileNotFoundException
- If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file.
-
CsvRecordWriter
public CsvRecordWriter(File aCsvFile) throws FileNotFoundException
Constructs aCsvRecordWriter
.- Parameters:
aCsvFile
- TheFile
to be used for printing output.- Throws:
FileNotFoundException
- If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file.
-
CsvRecordWriter
public CsvRecordWriter(File aCsvFile, char aCsvDelimiter) throws FileNotFoundException
Constructs aCsvRecordWriter
.- Parameters:
aCsvFile
- TheFile
to be used for printing output. aCsvDelimiter The separator to be used when separating the CSV values in the log output.aCsvDelimiter
- The separator to be used when separating the CSV values in the log output.- Throws:
FileNotFoundException
- If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file.
-
CsvRecordWriter
public CsvRecordWriter(Header<T> aHeader, OutputStream aCsvOutputStream)
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aHeader
- The header used for logging in the correct format.aCsvOutputStream
- TheOutputStream
to be used for printing.
-
CsvRecordWriter
public CsvRecordWriter(Header<T> aHeader, OutputStream aCsvOutputStream, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aHeader
- The header used for logging in the correct format.aCsvOutputStream
- TheOutputStream
to be used for printing.aCsvDelimiter
- The separator to be used when separating the CSV values in the log output.
-
CsvRecordWriter
public CsvRecordWriter(OutputStream aCsvOutputStream)
Constructs aCsvRecordWriter
.- Parameters:
aCsvOutputStream
- TheOutputStream
to be used for printing output.
-
CsvRecordWriter
public CsvRecordWriter(ColumnFactory<T> aColumnFactory, File aCsvFile) throws FileNotFoundException
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aColumnFactory
- The header used for logging in the correct format.aCsvFile
- TheFile
to be used for printing.- Throws:
FileNotFoundException
- If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file.
-
CsvRecordWriter
public CsvRecordWriter(ColumnFactory<T> aColumnFactory, File aCsvFile, char aCsvDelimiter) throws FileNotFoundException
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aColumnFactory
- The header used for logging in the correct format.aCsvFile
- TheFile
to be used for printing.aCsvDelimiter
- The separator to be used when separating the CSV values in the log output.- Throws:
FileNotFoundException
- If the given file object does not denote an existing, writable regular file and a new regular file of that name cannot be created, or if some other error occurs while opening or creating the file.
-
CsvRecordWriter
public CsvRecordWriter(ColumnFactory<T> aColumnFactory, OutputStream aCsvOutputStream)
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aColumnFactory
- The header used for logging in the correct format.aCsvOutputStream
- TheOutputStream
to be used for printing.
-
CsvRecordWriter
public CsvRecordWriter(ColumnFactory<T> aColumnFactory, OutputStream aCsvOutputStream, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aColumnFactory
- The header used for logging in the correct format.aCsvOutputStream
- TheOutputStream
to be used for printing.aCsvDelimiter
- The separator to be used when separating the CSV values in the log output.
-
CsvRecordWriter
public CsvRecordWriter(Header<T> aHeader, File aCsvFile, Charset aEncoding) throws IOException
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aHeader
- The header used for logging in the correct format.aCsvFile
- TheFile
to be used for printing.aEncoding
- TheCharset
for the character encoding to use.- Throws:
IOException
- in case the file is not found or the encoding is not supported.
-
CsvRecordWriter
public CsvRecordWriter(Header<T> aHeader, File aCsvFile, Charset aEncoding, char aCsvDelimiter) throws IOException
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aHeader
- The header used for logging in the correct format.aCsvFile
- TheFile
to be used for printing.aEncoding
- TheCharset
for the character encoding to use.aCsvDelimiter
- The separator to be used when separating the CSV values in the log output.- Throws:
IOException
- in case the file is not found or the encoding is not supported.
-
CsvRecordWriter
public CsvRecordWriter(File aCsvFile, Charset aEncoding) throws IOException
Constructs aCsvRecordWriter
.- Parameters:
aCsvFile
- TheFile
to be used for printing output.aEncoding
- the encoding- Throws:
IOException
- in case the file is not found or the encoding is not supported.
-
CsvRecordWriter
public CsvRecordWriter(File aCsvFile, Charset aEncoding, char aCsvDelimiter) throws IOException
Constructs aCsvRecordWriter
.- Parameters:
aCsvFile
- TheFile
to be used for printing output. aCsvDelimiter The separator to be used when separating the CSV values in the log output.aEncoding
- the encodingaCsvDelimiter
- The separator to be used when separating the CSV values in the log output.- Throws:
IOException
- in case the file is not found or the encoding is not supported.
-
CsvRecordWriter
public CsvRecordWriter(Header<T> aHeader, OutputStream aCsvOutputStream, Charset aEncoding) throws UnsupportedEncodingException
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aHeader
- The header used for logging in the correct format.aCsvOutputStream
- TheOutputStream
to be used for printing.aEncoding
- TheCharset
for the character encoding to use.- Throws:
UnsupportedEncodingException
- thrown in case an unsupported encoding (Charset
) has been provided.
-
CsvRecordWriter
public CsvRecordWriter(Header<T> aHeader, OutputStream aCsvOutputStream, Charset aEncoding, char aCsvDelimiter) throws UnsupportedEncodingException
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aHeader
- The header used for logging in the correct format.aCsvOutputStream
- TheOutputStream
to be used for printing.aEncoding
- TheCharset
for the character encoding to use.aCsvDelimiter
- The separator to be used when separating the CSV values in the log output.- Throws:
UnsupportedEncodingException
- thrown in case an unsupported encoding (Charset
) has been provided.
-
CsvRecordWriter
public CsvRecordWriter(OutputStream aCsvOutputStream, Charset aEncoding) throws UnsupportedEncodingException
Constructs aCsvRecordWriter
.- Parameters:
aCsvOutputStream
- TheOutputStream
to be used for printing output.aEncoding
- the encoding- Throws:
UnsupportedEncodingException
- thrown in case an unsupported encoding (Charset
) has been provided.
-
CsvRecordWriter
public CsvRecordWriter(ColumnFactory<T> aColumnFactory, File aCsvFile, Charset aEncoding) throws IOException
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aColumnFactory
- The header used for logging in the correct format.aCsvFile
- TheFile
to be used for printing.aEncoding
- TheCharset
for the character encoding to use.- Throws:
IOException
- in case the file is not found or the encoding is not supported.
-
CsvRecordWriter
public CsvRecordWriter(ColumnFactory<T> aColumnFactory, File aCsvFile, Charset aEncoding, char aCsvDelimiter) throws IOException
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aColumnFactory
- The header used for logging in the correct format.aCsvFile
- TheFile
to be used for printing.aEncoding
- TheCharset
for the character encoding to use.aCsvDelimiter
- The separator to be used when separating the CSV values in the log output.- Throws:
IOException
- in case the file is not found or the encoding is not supported.
-
CsvRecordWriter
public CsvRecordWriter(ColumnFactory<T> aColumnFactory, OutputStream aCsvOutputStream, Charset aEncoding) throws UnsupportedEncodingException
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aColumnFactory
- The header used for logging in the correct format.aCsvOutputStream
- TheOutputStream
to be used for printing.aEncoding
- TheCharset
for the character encoding to use.- Throws:
UnsupportedEncodingException
- thrown in case an unsupported encoding (Charset
) has been provided.
-
CsvRecordWriter
public CsvRecordWriter(ColumnFactory<T> aColumnFactory, OutputStream aCsvOutputStream, Charset aEncoding, char aCsvDelimiter) throws UnsupportedEncodingException
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aColumnFactory
- The header used for logging in the correct format.aCsvOutputStream
- TheOutputStream
to be used for printing.aEncoding
- TheCharset
for the character encoding to use.aCsvDelimiter
- The separator to be used when separating the CSV values in the log output.- Throws:
UnsupportedEncodingException
- thrown in case an unsupported encoding (Charset
) has been provided.
-
CsvRecordWriter
public CsvRecordWriter(PrintStream aPrintStream)
Constructs aCsvRecordWriter
.- Parameters:
aPrintStream
- ThePrintStream
to be used for printing.
-
CsvRecordWriter
public CsvRecordWriter(ColumnFactory<T> aColumnFactory, PrintStream aPrintStream)
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aColumnFactory
- The header used for logging in the correct format.aPrintStream
- ThePrintStream
to be used for printing.
-
CsvRecordWriter
public CsvRecordWriter(Header<T> aHeader, PrintStream aPrintStream, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aHeader
- The header used for logging in the correct format.aPrintStream
- ThePrintStream
to be used for printing.aCsvDelimiter
- The separator to be used when separating the CSV values in the log output.
-
CsvRecordWriter
public CsvRecordWriter(Header<T> aHeader, PrintStream aPrintStream)
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aHeader
- The header used for logging in the correct format.aPrintStream
- ThePrintStream
to be used for printing.
-
CsvRecordWriter
public CsvRecordWriter(ColumnFactory<T> aColumnFactory, PrintStream aPrintStream, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aColumnFactory
- AColumnFactory
to be used to generateColumn
instances from the top line of the CSF file, required for parsing the CSV lines and converting them toRecord
instances.aPrintStream
- ThePrintStream
to be used for printing output.aCsvDelimiter
- The separator to be used when separating the CSV values in the log output.
-
CsvRecordWriter
protected CsvRecordWriter(Header<T> aHeader, ColumnFactory<T> aColumnFactory, PrintStream aPrintStream, char aCsvDelimiter)
Constructs aCsvRecordWriter
with the given header for logging.- Parameters:
aHeader
- The header used for logging in the correct format.aColumnFactory
- AColumnFactory
to be used to generateColumn
instances from the top line of the CSF file, required for parsing the CSV lines and converting them toRecord
instances.aPrintStream
- ThePrintStream
to be used for printing output.aCsvDelimiter
- The separator to be used when separating the CSV values in the log output.
-
-
Method Detail
-
setCommentPrefixes
public void setCommentPrefixes(String... aCommentPrefixes)
- Specified by:
setCommentPrefixes
in interfaceorg.refcodes.textual.CsvMixin
-
getCommentPrefixes
public String[] getCommentPrefixes()
- Specified by:
getCommentPrefixes
in interfaceorg.refcodes.textual.CsvMixin
-
clearCommentPrefixes
public void clearCommentPrefixes()
- Specified by:
clearCommentPrefixes
in interfaceorg.refcodes.textual.CsvMixin
-
withCommentPrefixes
public CsvRecordWriter<T> withCommentPrefixes(String... aCommentPrefixes)
- Specified by:
withCommentPrefixes
in interfaceorg.refcodes.textual.CsvMixin
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Throws:
IOException
-
getCsvEscapeMode
public org.refcodes.textual.CsvEscapeMode getCsvEscapeMode()
- Specified by:
getCsvEscapeMode
in interfaceorg.refcodes.textual.CsvEscapeModeAccessor
-
isTrim
public boolean isTrim()
- Specified by:
isTrim
in interfaceorg.refcodes.mixin.TrimAccessor
-
getDelimiter
public char getDelimiter()
- Specified by:
getDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor
-
setTrim
public void setTrim(boolean isTrim)
- Specified by:
setTrim
in interfaceorg.refcodes.mixin.TrimAccessor.TrimMutator
-
setDelimiter
public void setDelimiter(char aCsvDelimiter)
- Specified by:
setDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor.DelimiterMutator
-
withTrim
public CsvRecordWriter<T> withTrim(boolean isTrimRecords)
- Specified by:
withTrim
in interfaceorg.refcodes.mixin.TrimAccessor.TrimBuilder<T>
-
withCsvEscapeMode
public CsvRecordWriter<T> withCsvEscapeMode(org.refcodes.textual.CsvEscapeMode aCsvEscapeMode)
- Specified by:
withCsvEscapeMode
in interfaceorg.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeBuilder<T>
-
withDelimiter
public CsvRecordWriter<T> withDelimiter(char aCsvDelimiter)
- Specified by:
withDelimiter
in interfaceorg.refcodes.mixin.DelimiterAccessor.DelimiterBuilder<T>
-
setCsvEscapeMode
public void setCsvEscapeMode(org.refcodes.textual.CsvEscapeMode aCsvEscapeMode)
- Specified by:
setCsvEscapeMode
in interfaceorg.refcodes.textual.CsvEscapeModeAccessor.CsvEscapeModeMutator
-
parseHeader
public void parseHeader(String... aHeader)
Parses and sets theHeader
from the providedString
. You must have provided aColumnFactory
for this operation to succeed.- Specified by:
parseHeader
in interfaceRecordWriter<T>
- Parameters:
aHeader
- The header to be created.
-
writeHeader
public void writeHeader(String... aHeader)
Parses and sets theHeader
from the providedString
arguments and writes the CSV header to the writer (be it a Stream or a File). You must have provided aColumnFactory
for this operation to succeed.- Specified by:
writeHeader
in interfaceRecordWriter<T>
- Parameters:
aHeader
- The header to be created.
-
writeHeader
public void writeHeader(Header<T> aHeader)
Sets and writes the providedHeader
to the writer (be it a Stream or a File). .- Specified by:
writeHeader
in interfaceRecordWriter<T>
- Parameters:
aHeader
- The header to be created.
-
writeHeader
public void writeHeader()
Writes the CSV header to the writer (be it a Stream or a File). You must have provided aHeader
for this operation to succeed.- Specified by:
writeHeader
in interfaceRecordWriter<T>
-
writeNext
public void writeNext(T... aRecord) throws IllegalArgumentException
Directly logs the provided instances to the writer.- Specified by:
writeNext
in interfaceRecordWriter<T>
- Specified by:
writeNext
in interfaceorg.refcodes.io.RowWriter<T>
- Parameters:
aRecord
- The instances to be logged.- Throws:
IllegalArgumentException
- thrown in case the provided objects do not align with the header (as ofHeaderAccessor.getHeader()
).
-
writeNext
public void writeNext(Record<T> aRecord) throws ColumnMismatchException, HeaderMismatchException
Directly logs the providedString
instances to the writer.- Specified by:
writeNext
in interfaceRecordWriter<T>
- Parameters:
aRecord
- TheString
instances to be logged.- Throws:
ColumnMismatchException
- Thrown in case a value was found in the e.g. in aRecord
of the wrong type than specified by a providedColumn
(of for example aHeader
).HeaderMismatchException
- Thrown in case there is a mismatch between the givenHeaderMismatchException
and theRow
, i.e. the index for the given key in the header may be out of index of the given row or the given key does not exist in theHeader
.
-
writeComment
public void writeComment(String aComment) throws IllegalStateException
Writes a comment by using the fist defined comment prefix as ofgetCommentPrefixes()
suffixed with a space (" ") followed by the comment (as of theCsvMixin.toComment(String)
). If no prefix has been set, then anIllegalStateException
will be thrown.- Parameters:
aComment
- The comment to be written.- Throws:
IllegalStateException
- in case no comment prefixes have been set viasetCommentPrefixes(String...)
orwithCommentPrefixes(String...)
.
-
writeHeaderComment
public void writeHeaderComment(String... aHeader)
- Parameters:
aHeader
- TheHeader
to be written as a comment.
-
writeHeaderComment
public void writeHeaderComment(Header<T> aHeader)
- Parameters:
aHeader
- TheHeader
to be written as a comment.
-
writeHeaderComment
public void writeHeaderComment()
-
-