org.qtitools.qti.node.expression
Interface Expression

All Superinterfaces:
ExpressionParent, java.io.Serializable, Validatable, XmlNode, XmlObject
All Known Implementing Classes:
AbstractExpression, And, AnyN, BaseValue, ContainerSize, Contains, Correct, CustomOperator, Default, Delete, Divide, DurationGte, DurationLt, Equal, EqualRounded, FieldValue, Gt, Gte, Index, Inside, IntegerDivide, IntegerModulus, IntegerToFloat, IsNull, ItemSubset, LookupExpression, Lt, Lte, MapResponse, MapResponsePoint, Match, Member, Multiple, Not, Null, NumberCorrect, NumberIncorrect, NumberPresented, NumberResponded, NumberSelected, Or, Ordered, OutcomeMaximum, OutcomeMinimum, OutcomeMinMax, PatternMatch, Power, Product, Random, RandomEx, RandomExpression, RandomFloat, RandomFloatEx, RandomInteger, RandomIntegerEx, RecordEx, Round, StringMatch, Substring, Subtract, Sum, TestVariables, Truncate, Variable

public interface Expression
extends ExpressionParent

This interface is definition how to handle all expressions. Every expression must implement this interface.

Author:
Jiri Kajaba, Jonathon Hare

Field Summary
static java.lang.String DISPLAY_NAME
          Display name of this interface.
 
Fields inherited from interface org.qtitools.qti.node.XmlNode
INDENT, NEW_LINE, SIMPLE_NAME_INNER_SEPARATOR, SIMPLE_NAMES_SEPARATOR
 
Method Summary
 Value evaluate()
          Evaluates this expression.
 BaseType getBaseType()
          Gets baseType of evaluated result.
 Cardinality getCardinality()
          Gets cardinality of evaluated result.
 java.util.List<Expression> getChildren()
          Gets all children of this expression.
 ExpressionParent getParent()
          Gets parent of this expression.
 BaseType[] getProducedBaseTypes()
          Gets list of all possible produced baseTypes after evaluation (possible baseTypes of evaluated result).
 Cardinality[] getProducedCardinalities()
          Gets list of all possible produced cardinalities after evaluation (possible cardinalities of evaluated result).
 ExpressionType getType()
          Gets expression type of this expression.
 Value getValue()
          Gets evaluated result or null if this expression is not evaluated yet.
 boolean isNull()
          Returns true if evaluated result of this expression is NULL; false otherwise.
 boolean isVariable()
          Returns true if value of evaluation can change every evaluation call; false otherwise.
 void reset()
          Resets this expression and all its children state (set same state like before first evaluation).
 
Methods inherited from interface org.qtitools.qti.node.expression.ExpressionParent
getRequiredBaseTypes, getRequiredCardinalities
 
Methods inherited from interface org.qtitools.qti.node.XmlObject
getParentItem, getParentResult, getParentTest, setParent
 
Methods inherited from interface org.qtitools.qti.node.XmlNode
getAttributes, getClassTag, getFullName, getNodeGroups, getParentRoot, getSimpleName, getSourceFile, getSourceNode, getSourceString, getSourceUrl, hasChildNodes, load, load, load, load, setSourceFile, setSourceNode, setSourceString, setSourceUrl, toXmlString, toXmlString
 
Methods inherited from interface org.qtitools.qti.validation.Validatable
validate
 

Field Detail

DISPLAY_NAME

static final java.lang.String DISPLAY_NAME
Display name of this interface.

See Also:
Constant Field Values
Method Detail

getParent

ExpressionParent getParent()
Gets parent of this expression.

Specified by:
getParent in interface XmlNode
Specified by:
getParent in interface XmlObject
Returns:
parent of this expression

getType

ExpressionType getType()
Gets expression type of this expression.

Returns:
expression type of this expression

isVariable

boolean isVariable()
Returns true if value of evaluation can change every evaluation call; false otherwise. It checks this expression and all of its children (if any child is variable, this expression becomes variable too). Example of variable expressions: variable and outcome expressions.

Returns:
true if value of evaluation can change every evaluation call; false otherwise

getProducedCardinalities

Cardinality[] getProducedCardinalities()
Gets list of all possible produced cardinalities after evaluation (possible cardinalities of evaluated result). Result of this method can change in time.

Static example is expression or. Expression or can produce only single cardinality and it cannot change.

Dynamic example is expression variable. Expression variable can produce any cardinality before evaluation. After evaluation it produces cardinality of its result (and it can change every evaluation call!).

Null expression, empty containers (multiple, ordered, record), or NULL values produces all cardinalities. So they are compatible with anything.

Returns:
list of all possible produced cardinalities after evaluation

getProducedBaseTypes

BaseType[] getProducedBaseTypes()
Gets list of all possible produced baseTypes after evaluation (possible baseTypes of evaluated result). Result of this method can change in time.

Static example is expression or. Expression or can produce only boolean baseType and it cannot change.

Dynamic example is expression variable. Expression variable can produce any baseType before evaluation. After evaluation it produces baseType of its result (and it can change every evaluation call!).

Null expression, empty containers (multiple, ordered, record), or NULL values produces all baseTypes. So they are compatible with anything.

Returns:
list of all possible produced baseTypes after evaluation

getChildren

java.util.List<Expression> getChildren()
Gets all children of this expression.

Returns:
all children of this expression

reset

void reset()
Resets this expression and all its children state (set same state like before first evaluation).


evaluate

Value evaluate()
Evaluates this expression.
  1. evaluates all subexpressions (calls evaluate method for every subexpression)
  2. validates this expression (calls validate method)
  3. evaluates this expression (calls evaluateSelf method)

Returns:
result of evaluation

isNull

boolean isNull()
               throws java.lang.NullPointerException
Returns true if evaluated result of this expression is NULL; false otherwise.

Returns:
true if evaluated result of this expression is NULL; false otherwise
Throws:
java.lang.NullPointerException - if this expression is not evaluated yet

getCardinality

Cardinality getCardinality()
                           throws java.lang.NullPointerException
Gets cardinality of evaluated result.

Returns:
cardinality of evaluated result
Throws:
java.lang.NullPointerException - if this expression is not evaluated yet

getBaseType

BaseType getBaseType()
                     throws java.lang.NullPointerException
Gets baseType of evaluated result.

Returns:
baseType of evaluated result
Throws:
java.lang.NullPointerException - if this expression is not evaluated yet

getValue

Value getValue()
Gets evaluated result or null if this expression is not evaluated yet.

Returns:
evaluated result or null if this expression is not evaluated yet


Copyright © 2009. All Rights Reserved.