uk.ac.starlink.cdf

## Class CdfStarTable

- java.lang.Object
- - uk.ac.starlink.table.AbstractStarTable
  - - uk.ac.starlink.cdf.CdfStarTable

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

      public class CdfStarTable
      extends AbstractStarTable

  StarTable implementation for CDF files.
  Since:
    24 Jun 2013

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `CdfStarTable(uk.ac.bristol.star.cdf.CdfContent content, CdfTableProfile profile, uk.ac.bristol.star.cdf.Variable dependVar)` Constructor.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.Object` | `getCell(long irow, int icol)` The `AbstractStarTable` implementation of this method throws an `UnsupportedOperationException`, since unless otherwise provided there is no random access.
    `int` | `getColumnCount()` Returns the number of columns in this table.
    `ColumnInfo` | `getColumnInfo(int icol)` Returns the object describing the data in a given column.
    `RowAccess` | `getRowAccess()` Returns an object which can provide random access to this table's data, if random access is implemented.
    `long` | `getRowCount()` Returns the number of rows in this table, if known.
    `RowSequence` | `getRowSequence()` Returns an object which can iterate over all the rows in the table sequentially.
    `static java.lang.String` | `getStringEntry(uk.ac.bristol.star.cdf.VariableAttribute att, uk.ac.bristol.star.cdf.Variable var)` Gets a variable's attribute value expected to be of string type.
    `boolean` | `isRandom()` The `AbstractStarTable` implementation of this method returns `false`.

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

      `checkedLongToInt, close, getColumnAuxDataInfos, getName, getParameters, getRow, getRowSplittable, getURL, 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

    - #### CdfStarTable

          public CdfStarTable(uk.ac.bristol.star.cdf.CdfContent content,
                              CdfTableProfile profile,
                              uk.ac.bristol.star.cdf.Variable dependVar)
                       throws java.io.IOException

      Constructor.

      The optional `dependVar` parameter provides an effective grouping of columns, and corresponds to the DEPEND_0 variable attribute defined by the ISTP Metadata Guidelines. CDF files contain multiple variables that are not necessarily all columns of the same table; at least within the ISTP guidelines a table is effectively defined by an independent epoch variable and a number of other variables depending on that (and thus presumably having the same number of values/rows). This interpretation is not exactly explicit in ISTP, but it looks like our best bet for turning CDF content into a thing or things that look like StarTables. If `dependVar` is null, we just have to assume that all the variables are effectively columns in the same table. In case that they don't all have the same multiplicity, just guess something and issue a warning.

      Parameters:
        `content` - CDF data content object
        `profile` - parameterisation of how CDFs should get turned into StarTables
        `dependVar` - independent variable on which other columns depend, or null
      Throws:
        `java.io.IOException` - in case of error

  - ### Method Detail

    - #### 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

    - #### 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

    - #### 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`

    - #### isRandom

          public boolean isRandom()

      Description copied from class: `AbstractStarTable`
      The `AbstractStarTable` implementation of this method returns `false`.
      Specified by:
        `isRandom` in interface `StarTable`
      Overrides:
        `isRandom` in class `AbstractStarTable`
      Returns:
        `true` if table random access methods are available

    - #### getCell

          public java.lang.Object getCell(long irow,
                                          int icol)
                                   throws java.io.IOException

      Description copied from class: `AbstractStarTable`
      The `AbstractStarTable` implementation of this method throws an `UnsupportedOperationException`, since unless otherwise provided there is no random access.
      Specified by:
        `getCell` in interface `StarTable`
      Overrides:
        `getCell` in class `AbstractStarTable`
      Parameters:
        `irow` - the index of the cell's row
        `icol` - the index of the cell's column
      Returns:
        the contents of this cell
      Throws:
        `java.io.IOException` - if there is an error reading the data

    - #### getRowSequence

          public RowSequence getRowSequence()
                                     throws java.io.IOException

      Description copied from interface: `StarTable`
      Returns an object which can iterate over all the rows in the table sequentially. Each such returned object is safe for use within a single thread, but not in general from multiple threads concurrently.
      Specified by:
        `getRowSequence` in interface `StarTable`
      Specified by:
        `getRowSequence` in class `AbstractStarTable`
      Returns:
        new RowSequence
      Throws:
        `java.io.IOException` - if there is an error providing access

    - #### getRowAccess

          public RowAccess getRowAccess()
                                 throws java.io.IOException

      Description copied from interface: `StarTable`
      Returns an object which can provide random access to this table's data, if random access is implemented. Each such returned object is safe for use within a single thread, but not in general from multiple threads concurrently.
      Specified by:
        `getRowAccess` in interface `StarTable`
      Overrides:
        `getRowAccess` in class `AbstractStarTable`
      Returns:
        new RowAccess
      Throws:
        `java.io.IOException` - if there is an error setting up access

    - #### getStringEntry

          public static java.lang.String getStringEntry(uk.ac.bristol.star.cdf.VariableAttribute att,
                                                        uk.ac.bristol.star.cdf.Variable var)

      Gets a variable's attribute value expected to be of string type.
      Parameters:
        `att` - attribute
        `var` - variable
      Returns:
        string value of att for var, or null if it doesn't exist or has the wrong type