uk.ac.starlink.hapi

## Class HapiTableReader

- java.lang.Object
- - uk.ac.starlink.hapi.HapiTableReader

-     public class HapiTableReader
      extends java.lang.Object

  Converts HAPI metadata and input streams to StarTables.
  Since:
    12 Jan 2024

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HapiTableReader(HapiParam[] params)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `RowSequence` | `createRowSequence(java.io.InputStream in, java.lang.Byte byte0, java.lang.String fmt)` Returns a row sequence given a HAPI data stream with no header.
    `RowSequence` | `createRowSequenceUsingHeader(java.io.InputStream in)` Returns a row sequence given a HAPI data stream including the prepended commented header (info JSON object) information.
    `StarTable` | `createStarTable(IOSupplier<RowSequence> rseqSupplier)` Produces a StarTable based on this metadata given a source of row sequence data.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### HapiTableReader

          public HapiTableReader(HapiParam[] params)

      Constructor.
      Parameters:
        `params` - array of parameters that will be read

  - ### Method Detail

    - #### createStarTable

          public StarTable createStarTable(IOSupplier<RowSequence> rseqSupplier)

      Produces a StarTable based on this metadata given a source of row sequence data. This may be obtained using other methods of this class.

      If a null RowSequence supplier is provided, the resulting table will be data-less; its metadata methods will work, but attempts to read its data will fail.

      Parameters:
        `rseqSupplier` - provides sequential data for the table, or null
      Returns:
        table

    - #### createRowSequenceUsingHeader

          public RowSequence createRowSequenceUsingHeader(java.io.InputStream in)
                                                   throws java.io.IOException

      Returns a row sequence given a HAPI data stream including the prepended commented header (info JSON object) information. The header is used to determine the serialization format, though not the table metadata, of the data part of the input stream.

      The supplied input stream will be used as is, so any buffering should be applied before calling this method.

      Parameters:
        `in` - input stream including prepended HAPI header
      Returns:
        row sequence
      Throws:
        `java.io.IOException`

    - #### createRowSequence

          public RowSequence createRowSequence(java.io.InputStream in,
                                               java.lang.Byte byte0,
                                               java.lang.String fmt)
                                        throws java.io.IOException

      Returns a row sequence given a HAPI data stream with no header. The first byte may optionally be supplied separately.

      The supplied input stream will be used as is, so any buffering should be applied before calling this method.

      Parameters:
        `in` - input stream ready for use
        `byte0` - byte to read at start of input sequence, or null
        `fmt` - data stream format, one of "csv" or "binary"
      Returns:
        row sequence
      Throws:
        `java.io.IOException`