Package org.apache.juneau.console.data
Class SeriesSource
java.lang.Object
org.apache.juneau.console.data.SeriesSource
Streams rows to a console data source as CSV or NDJSON.
Rows are written in order and flushed every 1000 rows or 65536 characters, so the
browser can parse while the response is still arriving. With cap(long) the stream stops after that many
rows and, when more rows exist, writes the truncation sentinel the browser reports as E-JS-102. Times are written
as ISO-8601 UTC; a LocalDate is the start of that day in UTC, and a LocalDateTime is read as UTC.
Example:
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe output format.static interfaceOne row;SeriesSource.Row.get(String)returns the value for a column, or null. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCharacters written between flushes.static final intRows written between flushes. -
Method Summary
Modifier and TypeMethodDescriptioncap(long value) The most rows to write.The columns to write, in order.static SeriesSourcecsv(RestResponse res) A CSV streamer on the response: setstext/csv;charset=utf-8 andX-Content-Type-Options: nosniff .static SeriesSourcendjson(RestResponse res) An NDJSON streamer on the response: setsapplication/x-ndjson;charset=utf-8 andnosniff .voidwrite(Stream<? extends SeriesSource.Row> rows) Writes the rows.
-
Field Details
-
FLUSH_ROWS
Rows written between flushes.- See Also:
-
FLUSH_CHARS
Characters written between flushes.- See Also:
-
-
Method Details
-
csv
A CSV streamer on the response: setstext/csv;charset=utf-8 andX-Content-Type-Options: nosniff .- Parameters:
res- The response.- Returns:
- A new streamer.
- Throws:
IOException- If the output stream cannot be opened.
-
ndjson
An NDJSON streamer on the response: setsapplication/x-ndjson;charset=utf-8 andnosniff .- Parameters:
res- The response.- Returns:
- A new streamer.
- Throws:
IOException- If the output stream cannot be opened.
-
columns
The columns to write, in order. CSV writes them as the header row.- Parameters:
names- The column names. At least one.- Returns:
- This object.
-
cap
The most rows to write. When more rows exist, the truncation sentinel follows them.- Parameters:
value- The cap. At least 1.- Returns:
- This object.
-
write
Writes the rows. Reads at most one row past the cap. The caller closes the stream.- Parameters:
rows- The rows.
-