uk.ac.starlink.fits

## Class AsciiTableStarTable

- java.lang.Object
- - uk.ac.starlink.table.AbstractStarTable
  - - uk.ac.starlink.fits.AsciiTableStarTable

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, StarTable

      public abstract class AsciiTableStarTable
      extends AbstractStarTable

  StarTable implementation for FITS (ASCII) TABLE extensions.
  Since:
    4 Mar 2022

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AsciiTableStarTable(FitsHeader hdr)` Constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static AsciiTableStarTable` | `createTable(FitsHeader hdr, InputFactory inputFact)` Creates a table instance from a TABLE HDU.
    `int` | `getColumnCount()` Returns the number of columns in this table.
    `ColumnInfo` | `getColumnInfo(int icol)` Returns the object describing the data in a given column.
    `protected int[]` | `getColumnLengths()` Returns the array of column lengths in bytes.
    `protected int[]` | `getColumnOffsets()` Returns the array of column offsets from the start of the row.
    `long` | `getRowCount()` Returns the number of rows in this table, if known.
    `protected int` | `getRowLength()` Returns the length of each row in bytes.
    `protected java.lang.Object` | `readCell(byte[] cellBuf, int icol)` Reads the content of a cell of this table from a byte buffer.
    `protected java.lang.Object[]` | `readRow(byte[] rowBuf)` Reads the content of a row of this table from a byte buffer.
    `static void` | `streamStarTable(FitsHeader hdr, BasicInput input, TableSink sink)` Reads a TABLE HDU from a stream and writes the result to a table sink.

    - ### Methods inherited from class uk.ac.starlink.table.AbstractStarTable

      `checkedLongToInt, close, getCell, getColumnAuxDataInfos, getName, getParameters, getRow, getRowAccess, getRowSequence, getRowSplittable, getURL, isRandom, setName, setParameters, setURL`

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

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

    - ### Methods inherited from interface uk.ac.starlink.table.StarTable

      `getParameterByName, setParameter`

- - ### Constructor Detail

    - #### AsciiTableStarTable

          public AsciiTableStarTable(FitsHeader hdr)
                              throws java.io.IOException

      Constructor.
      Parameters:
        `hdr` - ASCII TABLE extension header
      Throws:
        `java.io.IOException`

  - ### Method Detail

    - #### getRowCount

          public long getRowCount()

      Description copied from interface: `StarTable`
      Returns the number of rows in this table, if known. If the number of rows cannot be (easily) determined, a value of -1 will be returned.
      Specified by:
        `getRowCount` in interface `StarTable`
      Specified by:
        `getRowCount` in class `AbstractStarTable`
      Returns:
        the number of rows, or -1

    - #### getColumnCount

          public int getColumnCount()

      Description copied from interface: `StarTable`
      Returns the number of columns in this table.
      Specified by:
        `getColumnCount` in interface `StarTable`
      Specified by:
        `getColumnCount` in class `AbstractStarTable`
      Returns:
        the number of columns

    - #### getColumnInfo

          public ColumnInfo getColumnInfo(int icol)

      Description copied from interface: `StarTable`
      Returns the object describing the data in a given column.
      Specified by:
        `getColumnInfo` in interface `StarTable`
      Specified by:
        `getColumnInfo` in class `AbstractStarTable`
      Parameters:
        `icol` - the column for which header information is required
      Returns:
        a ValueInfo object for column `icol`

    - #### getRowLength

          protected int getRowLength()

      Returns the length of each row in bytes.
      Returns:
        row length

    - #### getColumnOffsets

          protected int[] getColumnOffsets()

      Returns the array of column offsets from the start of the row.
      Returns:
        ncol-length array of byte offsets from row start

    - #### getColumnLengths

          protected int[] getColumnLengths()

      Returns the array of column lengths in bytes.
      Returns:
        ncol-length array of field byte lengths

    - #### readRow

          protected java.lang.Object[] readRow(byte[] rowBuf)

      Reads the content of a row of this table from a byte buffer.
      Parameters:
        `rowBuf` - buffer containing rowLeng bytes
      Returns:
        ncol-element array of cell values

    - #### readCell

          protected java.lang.Object readCell(byte[] cellBuf,
                                              int icol)

      Reads the content of a cell of this table from a byte buffer.
      Parameters:
        `cellBuf` - buffer containing bytes for column content
        `icol` - column index
      Returns:
        cell value

    - #### createTable

          public static AsciiTableStarTable createTable(FitsHeader hdr,
                                                        InputFactory inputFact)
                                                 throws java.io.IOException

      Creates a table instance from a TABLE HDU.
      Parameters:
        `hdr` - FITS header for ASCII table
        `inputFact` - input factory for Data part of HDU
      Returns:
        new table; it will be random-access according to whether the input factory is
      Throws:
        `java.io.IOException`

    - #### streamStarTable

          public static void streamStarTable(FitsHeader hdr,
                                             BasicInput input,
                                             TableSink sink)
                                      throws java.io.IOException

      Reads a TABLE HDU from a stream and writes the result to a table sink.
      Parameters:
        `hdr` - FITS header object describing the TABLE extension
        `input` - input stream positioned at the start of the data part of the TABLE extension
        `sink` - destination for the table
      Throws:
        `java.io.IOException`