Package org.refcodes.tabular
Interface RecordWriter<T>
-
- 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
public interface RecordWriter<T> extends org.refcodes.io.RowWriter<T[]>, HeaderAccessor<T>
TheRecordWriter
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(String... aHeader)
void
writeHeader()
Writes the CSV header to the (standard) output (be it a Stream or a File).void
writeHeader(String... aHeader)
void
writeHeader(Header<T> aHeader)
Sets and writes the providedHeader
to the (standard) output (be it a Stream or a File). .void
writeNext(Record<T> aRecord)
Directly logs the providedString
instances to the (standard) output.void
writeNext(T... aRecord)
Directly logs the providedString
instances to the (standard) output.-
Methods inherited from interface java.lang.AutoCloseable
close
-
Methods inherited from interface org.refcodes.tabular.HeaderAccessor
getHeader
-
-
-
-
Method Detail
-
parseHeader
void parseHeader(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(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(T... aRecord) throws IllegalArgumentException
Directly logs the providedString
instances to the (standard) output.- Specified by:
writeNext
in interfaceorg.refcodes.io.RowWriter<T>
- Parameters:
aRecord
- TheString
instances to be logged.- Throws:
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
).
-
-