Class ColumnStarTable

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, StarTable
    Direct Known Subclasses:
    LoopStarTable

    public abstract class ColumnStarTable
    extends RandomStarTable
    A random-access StarTable that manages its data in columns. The data in each column is managed by a ColumnData object which can be accessed directly using the getColumnData(int) method. Columns can be added and substituted. If the columns permit it then table cells can be written to as well as read from.

    Concrete subclasses of this abstract class must implement getRowCount(). If you just need a ColumnStarTable with a fixed number of rows you can use the static convenience method makeTableWithRows(long).

    Author:
    Mark Taylor (Starlink)
    • Field Detail

      • columns_

        public java.util.List<ColumnData> columns_
    • Constructor Detail

      • ColumnStarTable

        public ColumnStarTable()
        Default constructor.
      • ColumnStarTable

        public ColumnStarTable​(StarTable template)
        Initialises a ColumnStarTable using a template StarTable to provide per-table metadata. The newly constructed object will have copies of the template's name, parameters etc.
        Parameters:
        template - the template StarTable
    • Method Detail

      • getRowCount

        public abstract long getRowCount()
        Gets the number of rows in the table (which must be applicable to all the columns). Since this is a RandomStarTable the return value must be non-negative.
        Specified by:
        getRowCount in interface StarTable
        Specified by:
        getRowCount in class RandomStarTable
        Returns:
        number of rows
      • 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
      • getCell

        public java.lang.Object getCell​(long lrow,
                                        int icol)
                                 throws java.io.IOException
        Description copied from class: RandomStarTable
        Implementations of this method must be safe for concurrent calls from multiple threads.
        Specified by:
        getCell in interface StarTable
        Specified by:
        getCell in class RandomStarTable
        Parameters:
        lrow - 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
      • setCell

        public void setCell​(long lrow,
                            int icol,
                            java.lang.Object value)
                     throws java.io.IOException
        Stores an object in a given cell of the table.
        Parameters:
        lrow - the row index
        icol - the column index
        value - the value to store
        Throws:
        java.io.IOException - if an I/O error occurs
        java.lang.UnsupportedOperationException - if column icol is not writable (!getColumnData(icol).isWritable());
      • getColumnData

        public ColumnData getColumnData​(int icol)
        Returns the ColumnData object for a given column.
        Parameters:
        icol - the index of the column for which the result is required
        Returns:
        the ColumnData for column icol
      • addColumn

        public void addColumn​(ColumnData coldata)
        Appends a new column to the end of this model.
        Parameters:
        coldata - the new column object to add
      • setColumn

        public void setColumn​(int icol,
                              ColumnData coldata)
        Substitutes a new column for the one which is currently in a given position. The old one is discarded.
        Parameters:
        icol - the column index to change
        coldata - the new column data object
      • makeTableWithRows

        public static ColumnStarTable makeTableWithRows​(long nrow)
        Convenience method to return a ColumnStarTable with a fixed number of rows.
        Parameters:
        nrow - the number of rows this table will have