- Type Parameters:
T- The type of theRecordinstances 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 TypeMethodDescriptionvoidparseHeader(String... aHeader) voidWrites the CSV header to the writer (be it a Stream or a File).voidwriteHeader(String... aHeader) voidwriteHeader(Header<T> aHeader) Sets and writes the providedHeaderto the writer (be it a Stream or a File). .voidDirectly logs the providedStringinstances to the writer.voidDirectly logs the provided instances to the writer.default <TYPE> voidwriteNextLine(String... aRecord) Directly writes the provided instance to the writer.default <TYPE> voidwriteNextType(TYPE aRecord) Directly logs the provided instance to the writer.Methods inherited from interface java.lang.AutoCloseable
closeMethods inherited from interface org.refcodes.tabular.HeaderAccessor
getHeader
-
Method Details
-
parseHeader
Parses and sets theHeaderfrom the providedString. You must have provided aColumnFactoryfor this operation to succeed.- Parameters:
aHeader- The header to be created.
-
writeHeader
Parses and sets theHeaderfrom the providedStringarguments and writes the CSV header to the writer (be it a Stream or a File). You must have provided aColumnFactoryfor this operation to succeed.- Parameters:
aHeader- The header to be created.
-
writeHeader
Sets and writes the providedHeaderto 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 aHeaderfor this operation to succeed. -
writeNext
Directly logs the provided instances to the writer.- Specified by:
writeNextin 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 aRecordof the wrong type than specified by a providedColumn(of for example aHeader).HeaderMismatchException- Thrown in case there is a mismatch between the givenHeaderand 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 providedStringinstances to the writer.- Parameters:
aRecord- TheStringinstances to be logged.- Throws:
ColumnMismatchException- Thrown in case a value was found in the e.g. in aRecordof the wrong type than specified by a providedColumn(of for example aHeader).HeaderMismatchException- Thrown in case there is a mismatch between the givenHeaderMismatchExceptionand 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.
-