uk.ac.starlink.topcat
Class SyntheticColumn

java.lang.Object
  extended by uk.ac.starlink.table.ColumnData
      extended by uk.ac.starlink.topcat.SyntheticColumn

public class SyntheticColumn
extends uk.ac.starlink.table.ColumnData

A column which produces read-only values based on an algebraic expression. This expression may include other columns in the table referenced by column name, and can use any of the java language expression constructs as well as the static methods in the java.lang.Math class. This list could be extended quite easily if new arithmetic tricks were required.

The engine used for expression evaluation is the GNU Java Expressions Library (JEL).

Author:
Mark Taylor (Starlink)
See Also:
JEL

Constructor Summary
SyntheticColumn(uk.ac.starlink.table.ColumnInfo cinfo, String expression, Class resultType, uk.ac.starlink.ttools.jel.RandomJELRowReader rowReader)
          Constructs a new synthetic column from an algebraic expression applied to a table.
 
Method Summary
 String getExpression()
          Returns the JEL expression that provides this column's value.
 Object readValue(long lrow)
           
 void setExpression(String expression, Class resultType, uk.ac.starlink.ttools.jel.RandomJELRowReader rowReader)
          Sets the algebraic expression which this column uses to calculate its results.
 
Methods inherited from class uk.ac.starlink.table.ColumnData
getColumnInfo, isWritable, setColumnInfo, storeValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SyntheticColumn

public SyntheticColumn(uk.ac.starlink.table.ColumnInfo cinfo,
                       String expression,
                       Class resultType,
                       uk.ac.starlink.ttools.jel.RandomJELRowReader rowReader)
                throws gnu.jel.CompilationException
Constructs a new synthetic column from an algebraic expression applied to a table.

Parameters:
cinfo - metadata for the new column; note this object may be modified as required by the supplied expression
expression - algebraic expression for the value of this column
resultType - a Class for the result, presumably one of the primitive wrapper types or String.class. If null a suitable class is chosen automatically.
rowReader - context for JEL expression evaluation
Throws:
gnu.jel.CompilationException
Method Detail

setExpression

public void setExpression(String expression,
                          Class resultType,
                          uk.ac.starlink.ttools.jel.RandomJELRowReader rowReader)
                   throws gnu.jel.CompilationException
Sets the algebraic expression which this column uses to calculate its results. Column names are used to refer to values of cells in other columns of this table in the same row as that for which the result is being generated.

Parameters:
expression - the string giving the algebraic exprssion for this column's value in terms of other columns
resultType - a Class for the result, presumably one of the primitive wrapper types or String.class. If null a suitable class is chosen automatically.
rowReader - context for JEL expression evaluation
Throws:
gnu.jel.CompilationException

getExpression

public String getExpression()
Returns the JEL expression that provides this column's value.

Returns:
expression

readValue

public Object readValue(long lrow)
                 throws IOException
Specified by:
readValue in class uk.ac.starlink.table.ColumnData
Throws:
IOException


Copyright © 2003-2018 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.