Venice 0.751beta

nz.org.venice.ui
Class ExpressionColumn

java.lang.Object
  extended bynz.org.venice.ui.Column
      extended bynz.org.venice.ui.ExpressionColumn
All Implemented Interfaces:
java.lang.Cloneable

public class ExpressionColumn
extends Column
implements java.lang.Cloneable

Representation of an expression column in a table. An expression column is a column in quote tables that displays the results of a user expression applied to the data in the table. The data type of the data displayed in the column will be ExpressionResult.

Author:
Andrew Leppard
See Also:
AbstractTable, AbstractTableModel, EODQuoteModel, ExpressionResult

Field Summary
 
Fields inherited from class nz.org.venice.ui.Column
ALWAYS_HIDDEN, HIDDEN, VISIBLE
 
Constructor Summary
ExpressionColumn(int number, java.lang.String fullName, java.lang.String shortName, int visible, java.lang.String expressionText, Expression expression)
          Create a new expression column.
 
Method Summary
 void calculate(QuoteBundle quoteBundle, java.util.List quotes)
          Execute the expression and calculate the result for each quote.
 java.lang.Object clone()
          Clone this expression column.
 Expression getExpression()
          Get the compiled expression.
 java.lang.String getExpressionText()
          Return the text version of the expression.
 ExpressionResult getResult(Symbol symbol, TradingDate date)
          Return the result of the expression for the given symbol on the given date.
 void setExpression(Expression expression)
          Set the compiled expression.
 void setExpressionText(java.lang.String expressionText)
          Set the text version of the expression.
 
Methods inherited from class nz.org.venice.ui.Column
getFullName, getNumber, getShortName, getType, getVisible, setFullName, setShortName
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExpressionColumn

public ExpressionColumn(int number,
                        java.lang.String fullName,
                        java.lang.String shortName,
                        int visible,
                        java.lang.String expressionText,
                        Expression expression)
Create a new expression column.

Parameters:
number - The column number
fullName - The full name of the column which appears in menus etc.
shortName - The short name of the column which appears in the table header.
visible - Either Column.HIDDEN, Column.VISIBLE or Column.ALWAYS_HIDDEN.
expressionText - Text of expression.
expression - Compiled expression.
Method Detail

getExpressionText

public java.lang.String getExpressionText()
Return the text version of the expression.

Returns:
Text version of the expression.

setExpressionText

public void setExpressionText(java.lang.String expressionText)
Set the text version of the expression.

Parameters:
expressionText - New expression text.

getExpression

public Expression getExpression()
Get the compiled expression.

Returns:
Compiled expression.

setExpression

public void setExpression(Expression expression)
Set the compiled expression.

Parameters:
expression - Compiled expression.

calculate

public void calculate(QuoteBundle quoteBundle,
                      java.util.List quotes)
               throws EvaluationException
Execute the expression and calculate the result for each quote. This function takes a list of quotes, rather than extracting them from the quote bundle, because typically the table (and therefore this column) does not display all the quotes in the quote bundle. The reason is that to display a single day's quotes requires the loading of two day's worth of quotes. Two days are needed to calculate the quote change values.

Parameters:
quoteBundle - Quote Bundle containing quotes
quotes - A list of Quotes which contain the symbols and dates to evaluate. A result will be calculated for each quote in the list.
Throws:
EvaluationException - If there was an error evaluating an expression, such as divide by zero.
See Also:
Quote

getResult

public ExpressionResult getResult(Symbol symbol,
                                  TradingDate date)
Return the result of the expression for the given symbol on the given date.

Parameters:
symbol - Query the result for this symbol.
date - Query the result for this date.
Returns:
The expression result or ExpressionResult.EMPTY if there is currently no result for the given symbol and date.

clone

public java.lang.Object clone()
Clone this expression column.

Returns:
Cloned expression column.

Venice 0.751beta