|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Expression
Representation of a composite executable parse tree. Any expression in the Gondola language is parsed into a composite structure built upon this class. This class therefore represents an executable expression.
Any single object of this type could represent a terminal expression
that is a number such as "5
",
a unary expression such as "not(X)
",
a binary expression such as "X and Y
" or a
ternary expression. The arguments labelled above as X
and Y
would be represented by separate Expression
classes.
Those classes would however be contained by this class.
Field Summary | |
---|---|
static int |
BOOLEAN_TYPE
A boolean type that can be either TRUE or FALSE . |
static double |
FALSE
Value of FALSE |
static int |
FLOAT_QUOTE_TYPE
Represents a stock float quote type: open, close, low, high |
static int |
FLOAT_TYPE
A float type that can contain any number. |
static int |
INTEGER_QUOTE_TYPE
Represents a stock integer quote type: volume |
static int |
INTEGER_TYPE
An integer type that can contain any integer number. |
static int |
STRING_TYPE
Represents a string type that can containy any string. |
static double |
TRUE
Value of TRUE |
static double |
TRUE_LEVEL
Threshold level where a number is registered as TRUE |
Method Summary | |
---|---|
int |
checkType()
Perform type checking on the expression. |
java.lang.Object |
clone()
|
boolean |
equals(java.lang.Object object)
Returns whether this expression tree and the given expression tree are equivalent. |
double |
evaluate(Variables variables,
QuoteBundle quoteBundle,
Symbol symbol,
int day)
Evaluates the given expression and returns the result. |
Expression |
getChild(int index)
Return the given argument. |
int |
getChildCount()
Return the number of arguments of this expression. |
int |
getIndex(Expression expression)
Return the index of the given argument in the expression. |
Expression |
getParent()
Return the parent of this node. |
int |
getType()
Get the type of the expression. |
int |
hashCode()
If you override the equals(java.lang.Object) method then you should override
this method. |
boolean |
isRoot()
Return whether this node is the root node. |
java.util.Iterator |
iterator()
Return an iterator to iterate over all the nodes in this expression's tree. |
void |
setChild(Expression child,
int index)
Set the argument. |
void |
setParent(Expression parent)
Set the parent of this node. |
Expression |
simplify()
Perform simplifications and optimisations on the expression tree. |
int |
size()
Count the number of nodes in the tree. |
int |
size(int type)
Count the number of nodes in the tree with the given type. |
java.lang.String |
toString()
Convert the given expression to a string. |
Field Detail |
---|
static final int BOOLEAN_TYPE
TRUE
or FALSE
.
static final int FLOAT_TYPE
static final int INTEGER_TYPE
static final int FLOAT_QUOTE_TYPE
static final int INTEGER_QUOTE_TYPE
static final int STRING_TYPE
static final double TRUE_LEVEL
TRUE
static final double TRUE
TRUE
static final double FALSE
FALSE
Method Detail |
---|
double evaluate(Variables variables, QuoteBundle quoteBundle, Symbol symbol, int day) throws EvaluationException
variables
- variable storage area for expressionquoteBundle
- the quote bundle containing quote data to usesymbol
- the current symbolday
- current date in cache fast access format
EvaluationException
- if the expression performs an illegal
operation such as divide by zero.java.lang.String toString()
toString
in class java.lang.Object
int checkType() throws TypeMismatchException
TypeMismatchException
- if the expression has incorrect typesint getType()
BOOLEAN_TYPE
, FLOAT_TYPE
,
INTEGER_TYPE
, FLOAT_QUOTE_TYPE
or
INTEGER_QUOTE_TYPE
.int getChildCount()
Expression getParent()
void setParent(Expression parent)
parent
- the parent.java.lang.Object clone()
boolean isRoot()
TRUE
if this node has no parent.java.util.Iterator iterator()
Expression getChild(int index)
index
- the argument index
void setChild(Expression child, int index)
child
- new argument expressionindex
- index of the argument expressionExpression simplify()
a and true
then the
expression tree would be simplified to a
.
int getIndex(Expression expression)
expression
- the child expression to locate
-1
if it could
not be foundboolean equals(java.lang.Object object)
equals
in class java.lang.Object
object
- the other expressionint hashCode()
equals(java.lang.Object)
method then you should override
this method. It provides a very basic hash code function.
hashCode
in class java.lang.Object
int size()
int size(int type)
|
Venice 0.7beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |