Interface RecordWriter
- All Superinterfaces:
AutoCloseable,Closeable,Flushable
- All Known Subinterfaces:
TokenWriter
- All Known Implementing Classes:
CborTokenWriter,JsonlTokenWriter,JsonTokenWriter,MsgPackTokenWriter
Public low-level whole-value push generator over a Juneau-formatted document.
Format-neutral cursor that emits one whole-value record per write(Object) call.
Single-rooted formats accept exactly one call (subsequent calls throw); multi-rooted formats
(jsonl, csv, sse) emit one line / row / event per call.
Usage:
StringBuilder
Streaming quality:
isStreaming()==true — O(1)-memory streaming. FULL-token formats return a cursor that is also aTokenWriter(the structural surface).isStreaming()==false — buffered whole-value cursor (backed byRecordAdapter);write(Object)delegates to the format's existing serializer and the structural surface is not available.
Resource ownership:
Every RecordReader / RecordWriter produced by a factory method
closes what it was handed — if the underlying input/output is Closeable,
close() closes it. This contract is symmetric across all factory methods.
See Also:
RecordReader— the pull-side counterpart.TokenWriter— structural extension for FULL-capability formats.- Serializers and Parsers
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the writer, flushing any buffered output first.voidflush()Flushes any buffered output to the underlying stream.booleanReturnstrue if this cursor is an O(1)-memory streaming cursor, orfalse if it is a buffered whole-value cursor (backed byRecordAdapter).Emits one whole-value record.
-
Method Details
-
write
Emits one whole-value record.- Parameters:
value- The value. May benull .- Returns:
- This object.
- Throws:
IOException- If a problem occurred writing to the underlying stream.
-
isStreaming
boolean isStreaming()Returnstrue if this cursor is an O(1)-memory streaming cursor, orfalse if it is a buffered whole-value cursor (backed byRecordAdapter).- Returns:
true if this cursor streams;false if it buffers.
-
flush
Flushes any buffered output to the underlying stream.- Specified by:
flushin interfaceFlushable- Throws:
IOException- If a problem occurred flushing the underlying stream.
-
close
Closes the writer, flushing any buffered output first.Implementations should be idempotent — closing a closed writer is a no-op.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-