- Type Parameters:
T
- The type of theRecord
instances being used.
- All Superinterfaces:
AutoCloseable
,HeaderAccessor<T>
,org.refcodes.io.RowWriter<T[]>
- All Known Implementing Classes:
CsvRecordWriter
,CsvStringRecordWriter
The
RecordWriter
writes data.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.tabular.HeaderAccessor
HeaderAccessor.HeaderBuilder<T extends HeaderAccessor.HeaderBuilder<?>>, HeaderAccessor.HeaderMutator<T>, HeaderAccessor.HeaderProperty<T>
-
Method Summary
Modifier and TypeMethodDescriptionvoid
parseHeader
(String... aHeader) void
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
Directly logs the providedString
instances to the writer.void
Directly logs the provided instances to the writer.default <TYPE> void
writeNextLine
(String... aRecord) Directly writes the provided instance to the writer.default <TYPE> void
writeNextType
(TYPE aRecord) Directly logs the provided instance to the writer.Methods inherited from interface java.lang.AutoCloseable
close
Methods inherited from interface org.refcodes.tabular.HeaderAccessor
getHeader
-
Method Details
-
parseHeader
Parses and sets theHeader
from the providedString
. You must have provided aColumnFactory
for this operation to succeed.- Parameters:
aHeader
- The header to be created.
-
writeHeader
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.- Parameters:
aHeader
- The header to be created.
-
writeHeader
Sets and writes the providedHeader
to the writer (be it a Stream or a File). .- Parameters:
aHeader
- The header to be created.
-
writeHeader
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. -
writeNext
Directly logs the provided instances to the writer.- 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()
).
-
writeNextType
Directly logs the provided instance to the writer. The properties of the given type matching the header are written accordingly.- Type Parameters:
TYPE
- the generic type- Parameters:
aRecord
- The instance to be logged.- Throws:
IllegalArgumentException
- thrown in case the provided objects do not align with the header (as ofHeaderAccessor.getHeader()
).
-
writeNextLine
default <TYPE> void writeNextLine(String... aRecord) throws IllegalArgumentException, ColumnMismatchException, HeaderMismatchException, ParseException Directly writes the provided instance to the writer. The properties of the given type in the given order matching the header are written accordingly.- Type Parameters:
TYPE
- the generic type- Parameters:
aRecord
- The instance to be logged.- Throws:
IllegalArgumentException
- thrown in case the provided objects do not align with the header (as ofHeaderAccessor.getHeader()
).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 givenHeader
and aRow
(or anotherHeader
), i.e. the index for the given key in a header may be out of index of a given row or the given key does not exist in aHeader
.ParseException
- in case parsing the input was not possible.
-
writeNext
Directly logs the providedString
instances to the writer.- 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
.
-