Class CalculatorColumnSupplement

  • All Implemented Interfaces:
    ColumnSupplement

    public abstract class CalculatorColumnSupplement
    extends java.lang.Object
    implements ColumnSupplement
    ColumnSupplement whose columns are derived by calculating values based on all the columns of another table. To generate any of the columns of this table, a whole row of the input supplement must be read. Concrete implementations of this abstract class must implement the calculate(java.lang.Object[]) method.
    Since:
    2 Apr 2012
    Author:
    Mark Taylor
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract java.lang.Object[] calculate​(java.lang.Object[] inRow)
      Performs the calculations which populate the columns of this table.
      SupplementSequence createSequence​(uk.ac.starlink.table.RowSequence rseq)
      Returns a new iterator over the values in the columns defined by this object.
      java.lang.Object getCell​(long irow, int icol)
      Random access read of a cell defined by this object.
      int getColumnCount()
      Returns the number of columns defined by this object.
      uk.ac.starlink.table.ColumnInfo getColumnInfo​(int icol)
      Returns the column metadata object for a given column.
      static double getDouble​(java.lang.Object value)
      Utility method to turn an Object into a floating point value.
      java.lang.Object[] getRow​(long irow)
      Random access read of a row defined by this object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CalculatorColumnSupplement

        public CalculatorColumnSupplement​(ColumnSupplement baseSup,
                                          uk.ac.starlink.table.ColumnInfo[] outColInfos)
        Constructor.
        Parameters:
        baseSup - base supplement
        outColInfos - column metadata for the supplementary columns (length defines column count)
    • Method Detail

      • calculate

        protected abstract java.lang.Object[] calculate​(java.lang.Object[] inRow)
                                                 throws java.io.IOException
        Performs the calculations which populate the columns of this table. The input is a row of the base table, and the output is the row of this table.

        The implementation must return a new array each time, not repopulate the same Object[] array object.

        Parameters:
        inRow - input column values
        Returns:
        output column values (same size as column count)
        Throws:
        java.io.IOException
      • getColumnCount

        public int getColumnCount()
        Description copied from interface: ColumnSupplement
        Returns the number of columns defined by this object.
        Specified by:
        getColumnCount in interface ColumnSupplement
        Returns:
        number of columns
      • getColumnInfo

        public uk.ac.starlink.table.ColumnInfo getColumnInfo​(int icol)
        Description copied from interface: ColumnSupplement
        Returns the column metadata object for a given column.
        Specified by:
        getColumnInfo in interface ColumnSupplement
        Parameters:
        icol - column index within this object
        Returns:
        column metadata for the icol'th column defined by this object
      • getRow

        public java.lang.Object[] getRow​(long irow)
                                  throws java.io.IOException
        Description copied from interface: ColumnSupplement
        Random access read of a row defined by this object.
        Specified by:
        getRow in interface ColumnSupplement
        Parameters:
        irow - row index
        Returns:
        array of cell contents for all the cells in this row
        Throws:
        java.io.IOException
      • getCell

        public java.lang.Object getCell​(long irow,
                                        int icol)
                                 throws java.io.IOException
        Description copied from interface: ColumnSupplement
        Random access read of a cell defined by this object.
        Specified by:
        getCell in interface ColumnSupplement
        Parameters:
        irow - row index
        icol - column index
        Returns:
        cell content
        Throws:
        java.io.IOException
      • createSequence

        public SupplementSequence createSequence​(uk.ac.starlink.table.RowSequence rseq)
                                          throws java.io.IOException
        Description copied from interface: ColumnSupplement
        Returns a new iterator over the values in the columns defined by this object. The supplied row sequence must be from an appropriate host table; if not, behaviour is undefined.
        Specified by:
        createSequence in interface ColumnSupplement
        Parameters:
        rseq - row sequence providing data from the host table
        Returns:
        iterator over row data from supplementary columns
        Throws:
        java.io.IOException
      • getDouble

        public static double getDouble​(java.lang.Object value)
        Utility method to turn an Object into a floating point value. If the submitted value is not a Number (including if it is null), NaN will be returned.
        Parameters:
        value - object value
        Returns:
        floating point value