|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.qtitools.qti.node.AbstractNode
org.qtitools.qti.node.AbstractObject
org.qtitools.qti.node.expression.AbstractExpression
public abstract class AbstractExpression
Abstract super class for all expressions.
Cardinality,
BaseType,
Serialized Form| Field Summary | |
|---|---|
protected static org.slf4j.Logger |
logger
Expression logger. |
| Fields inherited from interface org.qtitools.qti.node.expression.Expression |
|---|
DISPLAY_NAME |
| Fields inherited from interface org.qtitools.qti.node.XmlNode |
|---|
INDENT, NEW_LINE, SIMPLE_NAME_INNER_SEPARATOR, SIMPLE_NAMES_SEPARATOR |
| Constructor Summary | |
|---|---|
AbstractExpression(ExpressionParent parent)
Constructs expression. |
|
| Method Summary | |
|---|---|
Value |
evaluate()
Evaluates this expression. |
protected abstract Value |
evaluateSelf(int depth)
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. |
protected Expression |
getFirstChild()
Returns first subexpression. |
ExpressionParent |
getParent()
Gets parent of this node or null (if node is root; for example AssessmentTest). |
protected BaseType[] |
getParentRequiredBaseTypes()
Gets list of all acceptable baseTypes for this expression from its parent. |
protected Cardinality[] |
getParentRequiredCardinalities()
Gets list of all acceptable cardinalities for this expression from its parent. |
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). |
protected BaseType[] |
getProducedNumericalBaseTypes()
Gets list of all possible produced baseTypes after evaluation (possible baseTypes of evaluated result). |
BaseType[] |
getRequiredBaseTypes(int index)
Gets list of all acceptable baseTypes which can child expression at given position produce. |
Cardinality[] |
getRequiredCardinalities(int index)
Gets list of all acceptable cardinalities which can child expression at given position produce. |
protected BaseType[] |
getRequiredSameBaseTypes(int index,
boolean includeParent)
Gets list of all acceptable baseTypes which can child expression at given position produce. |
protected Cardinality[] |
getRequiredSameCardinalities(int index,
boolean includeParent)
Gets list of all acceptable cardinalities which can child expression at given position produce. |
protected Expression |
getSecondChild()
Returns second subexpression. |
ExpressionType |
getType()
Gets expression type of this expression. |
Value |
getValue()
Gets evaluated result or null if this expression is not evaluated yet. |
protected boolean |
isAnyChildNull()
Returns true if any subexpression is NULL; false otherwise. |
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). |
java.lang.String |
toString()
|
ValidationResult |
validate()
Validates this object. |
| Methods inherited from class org.qtitools.qti.node.AbstractObject |
|---|
getParentItem, getParentResult, getParentTest, setParent |
| Methods inherited from class org.qtitools.qti.node.AbstractNode |
|---|
attrToXmlString, bodyToXmlString, getAttributes, getClassTag, getFullName, getIndent, getNode, getNode, getNode, getNodeGroups, getParentRoot, getSimpleName, getSourceFile, getSourceNode, getSourceString, getSourceUrl, hasChildNodes, load, load, load, load, loadAttributes, readChild, readChildren, setParent, setSourceFile, setSourceNode, setSourceString, setSourceUrl, toXmlString, toXmlString, validateAttributes, validateChildren |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| 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 |
| Field Detail |
|---|
protected static org.slf4j.Logger logger
| Constructor Detail |
|---|
public AbstractExpression(ExpressionParent parent)
parent - parent of this expression| Method Detail |
|---|
public ExpressionParent getParent()
XmlNodeWhile testing some nodes (for example expressions) don't have properly set parent, but it is usable only for testing. (Some nodes cannot exists without parent even for testing).
getParent in interface ExpressiongetParent in interface XmlNodegetParent in interface XmlObjectgetParent in class AbstractObjectpublic ExpressionType getType()
Expression
getType in interface Expressionpublic boolean isVariable()
Expression
isVariable in interface Expressionpublic Cardinality[] getRequiredCardinalities(int index)
ExpressionParentFor example delete expression returns single cardinality for index 0 and list of multiple and ordered cardinality for index 1.
Result of this method can change in time.
Static example is expression or. Expression or accepts only single cardinality for any index.
Dynamic example is expression match. Expression match accepts any cardinality of its children, but this cardinality must be same for all its children.
getRequiredCardinalities in interface ExpressionParentindex - position of child expression in this parent
protected Cardinality[] getRequiredSameCardinalities(int index,
boolean includeParent)
This method is used when same cardinality is required (contains, match).
index - position of child expression in this parentincludeParent - whether parent requirements should be used during calculation
getRequiredCardinalities(int)public BaseType[] getRequiredBaseTypes(int index)
ExpressionParentResult of this method can change in time.
Static example is expression or. Expression or accepts only boolean baseType for any index.
Dynamic example is expression match. Expression match accepts any baseType of its children. but this baseType must be same for all its children.
getRequiredBaseTypes in interface ExpressionParentindex - position of child expression in this parent
protected BaseType[] getRequiredSameBaseTypes(int index,
boolean includeParent)
This method is used when same baseType is required (contains, delete, index, match, ...).
index - position of child expression in this parentincludeParent - whether parent requirements should be used during calculation
getRequiredBaseTypes(int)public Cardinality[] getProducedCardinalities()
ExpressionStatic 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.
getProducedCardinalities in interface Expressionpublic BaseType[] getProducedBaseTypes()
ExpressionStatic 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.
getProducedBaseTypes in interface Expressionprotected BaseType[] getProducedNumericalBaseTypes()
This method is used in numerical expressions (product, subtract, sum).
getProducedBaseTypes()protected Cardinality[] getParentRequiredCardinalities()
getRequiredCardinalities(index) method
protected BaseType[] getParentRequiredBaseTypes()
getRequiredBaseTypes(index) method
public ValidationResult validate()
Validatable
validate in interface Validatablevalidate in class AbstractNodepublic java.util.List<Expression> getChildren()
Expression
getChildren in interface Expressionprotected boolean isAnyChildNull()
protected Expression getFirstChild()
getChildren().get(0).
protected Expression getSecondChild()
getChildren().get(1).
public void reset()
Expression
reset in interface Expressionpublic Value evaluate()
Expressionevaluate method for every subexpression)
validate method)
evaluateSelf method)
evaluate in interface Expressionprotected abstract Value evaluateSelf(int depth)
depth - depth of this expression in expression tree (root's depth = 0)
public boolean isNull()
throws java.lang.NullPointerException
Expression
isNull in interface Expressionjava.lang.NullPointerException - if this expression is not evaluated yet
public Cardinality getCardinality()
throws java.lang.NullPointerException
Expression
getCardinality in interface Expressionjava.lang.NullPointerException - if this expression is not evaluated yet
public BaseType getBaseType()
throws java.lang.NullPointerException
Expression
getBaseType in interface Expressionjava.lang.NullPointerException - if this expression is not evaluated yet
public Value getValue()
throws java.lang.NullPointerException
Expression
getValue in interface Expressionjava.lang.NullPointerExceptionpublic java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||