Package org.refcodes.tabular
Interface RecordsWriter<T>
-
- Type Parameters:
T
- The type of theRecord
instances being used.
- All Superinterfaces:
java.lang.AutoCloseable
,HeaderAccessor<T>
- All Known Implementing Classes:
CsvRecordsWriter
,CsvStringRecordsWriter
public interface RecordsWriter<T> extends java.lang.AutoCloseable, HeaderAccessor<T>
TheRecordsWriter
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
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
parseHeader(java.lang.String... aHeader)
Parses and sets theHeader
from the providedString
.void
writeHeader()
Writes the CSV header to the (standard) output (be it a Stream or a File).void
writeHeader(java.lang.String... aHeader)
Parses and sets theHeader
from the providedString
arguments and writes the CSV header to the (standard) output (be it a Stream or a File).void
writeHeader(Header<T> aHeader)
Sets and writes the providedHeader
to the (standard) output (be it a Stream or a File). .void
writeNext(java.lang.Object... aRecord)
Directly logs the providedString
instances to the (standard) output.void
writeNext(Record<T> aRecord)
Directly logs the providedString
instances to the (standard) output.-
Methods inherited from interface org.refcodes.tabular.HeaderAccessor
getHeader
-
-
-
-
Method Detail
-
parseHeader
void parseHeader(java.lang.String... aHeader)
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
void writeHeader(java.lang.String... aHeader)
Parses and sets theHeader
from the providedString
arguments and writes the CSV header to the (standard) output (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
void writeHeader(Header<T> aHeader)
Sets and writes the providedHeader
to the (standard) output (be it a Stream or a File). .- Parameters:
aHeader
- The header to be created.
-
writeHeader
void writeHeader()
Writes the CSV header to the (standard) output (be it a Stream or a File). You must have provided aHeader
for this operation to succeed.
-
writeNext
void writeNext(java.lang.Object... aRecord) throws java.lang.IllegalArgumentException
Directly logs the providedString
instances to the (standard) output.- Parameters:
aRecord
- TheString
instances to be logged.- Throws:
java.lang.IllegalArgumentException
- thrown in case the provided objects do not align with the header (as ofHeaderAccessor.getHeader()
).
-
writeNext
void writeNext(Record<T> aRecord) throws ColumnMismatchException, HeaderMismatchException
Directly logs the providedString
instances to the (standard) output.- Parameters:
aRecord
- TheString
instances to be logged.- Throws:
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
.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
).
-
-