com.abr.calculator
Class VariableExpression

java.lang.Object
  extended by com.abr.calculator.BaseExpression
      extended by com.abr.calculator.VariableExpression
All Implemented Interfaces:
IExpression

public class VariableExpression
extends BaseExpression

VariableExpression - A value that must be extracted from a data source at run time.


Field Summary
 
Fields inherited from class com.abr.calculator.BaseExpression
m_embeddedExpr, m_master, m_nExpressionNumber, m_nGlobalExpressionNumber, m_objVariableResolutionData, m_strExpression
 
Fields inherited from interface com.abr.calculator.IExpression
OPERATOR_ADD, OPERATOR_COLON, OPERATOR_COMMA, OPERATOR_DIV, OPERATOR_EXP, OPERATOR_MOD, OPERATOR_MULT, OPERATOR_NONE, OPERATOR_QUESTION, OPERATOR_SUB
 
Constructor Summary
VariableExpression(MasterExpression master, java.lang.String strExpression)
           
 
Method Summary
protected  java.lang.String getInvalidChars()
          DERIVED CLASSES: Override this method to customize the set of invalid characters.
 int getLogicalValueCount(IDataSource dataSource, ExpressionError error)
          Get the number of times that a caller must call this function to get all the possible data values.
 double getValue(int index, IDataSource dataSource, ExpressionError error)
          Get the value associated with this expression.
 int getValueCount(IDataSource dataSource, ExpressionError error)
          Get the number of values associated with an expression.
 java.util.Vector getVariables()
          Return a list of IExpression objects that correspond to the variable expressions for this expression.
 boolean parse(Parser parser, ExpressionError error)
          Parse this expression.
 boolean resolveVariables(IVariableResolver variableResolver)
          Resolve any variable names within this expression.
 java.lang.String toString()
           
 
Methods inherited from class com.abr.calculator.BaseExpression
getEmbeddedExpressions, getExpression, getExpressionID, getMaster, getName, getVariableResolutionData, getVariables, setEmbeddedExpression, setExpression, updateMaster
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

VariableExpression

public VariableExpression(MasterExpression master,
                          java.lang.String strExpression)
Method Detail

parse

public boolean parse(Parser parser,
                     ExpressionError error)
Description copied from interface: IExpression
Parse this expression.

Parameters:
parser - - parsing object to use
error - - error object for the expression to use
Returns:
FALSE if a parse error occurred

resolveVariables

public boolean resolveVariables(IVariableResolver variableResolver)
Description copied from interface: IExpression
Resolve any variable names within this expression. Useful when the variable names in an expression like "a+b/c" actually resolve to other things (such as "a" becomes "Table1.Field1"). All expressions must be able to resolve their embedded variables!

Specified by:
resolveVariables in interface IExpression
Overrides:
resolveVariables in class BaseExpression
Parameters:
variableResolver - - object that can supply resolution data for a given variable name
Returns:
TRUE if all variables could be resolved.

getVariables

public java.util.Vector getVariables()
Description copied from interface: IExpression
Return a list of IExpression objects that correspond to the variable expressions for this expression.

Specified by:
getVariables in interface IExpression
Overrides:
getVariables in class BaseExpression

getValue

public double getValue(int index,
                       IDataSource dataSource,
                       ExpressionError error)
Description copied from interface: IExpression
Get the value associated with this expression. Valid only after calling parse().

Parameters:
index - - index to use to extract data from data source
dataSource - - where can we extract variable data?
error - - used to store error results
Returns:
Value of the expression (a double).

getValueCount

public int getValueCount(IDataSource dataSource,
                         ExpressionError error)
Description copied from interface: IExpression
Get the number of values associated with an expression.

Parameters:
dataSource - - where can we extract variable data?
error - - used to store error results
Returns:
Number of values associated with an expression. NOTE: This method can be used by aggregate functions to iterate over all valid data points.

getLogicalValueCount

public int getLogicalValueCount(IDataSource dataSource,
                                ExpressionError error)
Description copied from interface: IExpression
Get the number of times that a caller must call this function to get all the possible data values. Many expressions (SUM, AVG, MIN, etc.) always return the same value, regardless of the times called. Thus, we return "one" for these functions.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getInvalidChars

protected java.lang.String getInvalidChars()
DERIVED CLASSES: Override this method to customize the set of invalid characters. Invalid characters disallow a variable name for parsing.