uk.ac.starlink.ttools.filter
Class AddColumnsTable

java.lang.Object
  extended by uk.ac.starlink.table.WrapperStarTable
      extended by uk.ac.starlink.ttools.filter.AddColumnsTable
All Implemented Interfaces:
uk.ac.starlink.table.StarTable

public abstract class AddColumnsTable
extends uk.ac.starlink.table.WrapperStarTable

Modifies a table by adding a set of columns to it which are calculated as a function of existing columns. Concrete subclasses must provide an implementation of the calculateValues(java.lang.Object[]) method.

Some attempt is made to arrange things so that if the output columns are read for the same row, the calculateValues method is called only once, for the sake of efficiency.

Since:
30 Aug 2005
Author:
Mark Taylor

Field Summary
 
Fields inherited from class uk.ac.starlink.table.WrapperStarTable
baseTable
 
Constructor Summary
AddColumnsTable(uk.ac.starlink.table.StarTable baseTable, int[] inColIndices, uk.ac.starlink.table.ColumnInfo[] outColInfos, int ipos)
          Constructor.
 
Method Summary
protected abstract  Object[] calculateValues(Object[] inValues)
          Calcuates the values for the new columns added to this table based on the values from the relevant columns from the base table.
 Object getCell(long irow, int icol)
           
 int getColumnCount()
           
 uk.ac.starlink.table.ColumnInfo getColumnInfo(int icol)
           
 Object[] getRow(long irow)
           
 uk.ac.starlink.table.RowSequence getRowSequence()
           
 
Methods inherited from class uk.ac.starlink.table.WrapperStarTable
checkedLongToInt, getBaseTable, getColumnAuxDataInfos, getName, getParameterByName, getParameters, getRowCount, getURL, isRandom, setName, setParameter, setURL, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AddColumnsTable

public AddColumnsTable(uk.ac.starlink.table.StarTable baseTable,
                       int[] inColIndices,
                       uk.ac.starlink.table.ColumnInfo[] outColInfos,
                       int ipos)
Constructor.

Parameters:
baseTable - base table
inColIndices - array of indices of the columns in the base table which are used to calculate the new columns in the resulting table
outColInfos - array of column info headers for each of the new columns which are added in the resulting table
ipos - position which the first of the new columns is to occupy in the resulting table (other new columns follow immediately)
Method Detail

calculateValues

protected abstract Object[] calculateValues(Object[] inValues)
Calcuates the values for the new columns added to this table based on the values from the relevant columns from the base table.

Parameters:
inValues - array of values from the base table, one from each of the columns indicated by the inColIndices array
Returns:
array of values to be included in this table, one for each of the columns indicated by the outColInfos array

getColumnCount

public int getColumnCount()
Specified by:
getColumnCount in interface uk.ac.starlink.table.StarTable
Overrides:
getColumnCount in class uk.ac.starlink.table.WrapperStarTable

getColumnInfo

public uk.ac.starlink.table.ColumnInfo getColumnInfo(int icol)
Specified by:
getColumnInfo in interface uk.ac.starlink.table.StarTable
Overrides:
getColumnInfo in class uk.ac.starlink.table.WrapperStarTable

getCell

public Object getCell(long irow,
                      int icol)
               throws IOException
Specified by:
getCell in interface uk.ac.starlink.table.StarTable
Overrides:
getCell in class uk.ac.starlink.table.WrapperStarTable
Throws:
IOException

getRow

public Object[] getRow(long irow)
                throws IOException
Specified by:
getRow in interface uk.ac.starlink.table.StarTable
Overrides:
getRow in class uk.ac.starlink.table.WrapperStarTable
Throws:
IOException

getRowSequence

public uk.ac.starlink.table.RowSequence getRowSequence()
                                                throws IOException
Specified by:
getRowSequence in interface uk.ac.starlink.table.StarTable
Overrides:
getRowSequence in class uk.ac.starlink.table.WrapperStarTable
Throws:
IOException


Copyright © 2009 Central Laboratory of the Research Councils. All Rights Reserved.