Class SeriesSource

java.lang.Object
org.apache.juneau.console.data.SeriesSource

public final class SeriesSource extends Object
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:

@RestGet(path="/series") public void series(RestResponse res) throws IOException { try (var rows = svc.rows()) { SeriesSource.csv(res).columns("start", "v").cap(100_000) .write(rows); } }

Since:
10.0.0
  • Field Details

  • Method Details

    • csv

      public static SeriesSource csv(RestResponse res) throws IOException
      A CSV streamer on the response: sets text/csv;charset=utf-8 and X-Content-Type-Options: nosniff.
      Parameters:
      res - The response.
      Returns:
      A new streamer.
      Throws:
      IOException - If the output stream cannot be opened.
    • ndjson

      public static SeriesSource ndjson(RestResponse res) throws IOException
      An NDJSON streamer on the response: sets application/x-ndjson;charset=utf-8 and nosniff.
      Parameters:
      res - The response.
      Returns:
      A new streamer.
      Throws:
      IOException - If the output stream cannot be opened.
    • columns

      public SeriesSource columns(String... names)
      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

      public SeriesSource cap(long value)
      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

      public void write(Stream<? extends SeriesSource.Row> rows)
      Writes the rows. Reads at most one row past the cap. The caller closes the stream.
      Parameters:
      rows - The rows.