org.qtitools.qti.node.expression.general
Class LookupExpression

java.lang.Object
  extended by org.qtitools.qti.node.AbstractNode
      extended by org.qtitools.qti.node.AbstractObject
          extended by org.qtitools.qti.node.expression.AbstractExpression
              extended by org.qtitools.qti.node.expression.general.LookupExpression
All Implemented Interfaces:
java.io.Serializable, Expression, ExpressionParent, XmlNode, XmlObject, Validatable
Direct Known Subclasses:
Correct, Default, Variable

public abstract class LookupExpression
extends AbstractExpression

Parent of correct, default and variable expression.

Author:
Jiri Kajaba, Jonathon Hare
See Also:
Serialized Form

Field Summary
static java.lang.String ATTR_IDENTIFIER_NAME
          Name of identifier attribute in xml schema.
static java.lang.String IDENTIFIER_SEPARATOR
          Separator between two parts of compound identifier.
 
Fields inherited from class org.qtitools.qti.node.expression.AbstractExpression
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
LookupExpression(ExpressionParent parent)
          Constructs expression.
 
Method Summary
protected  java.lang.String getFirstPart()
          Gets first part of compound identifier or whole identifier if identifier is not compound.
 java.lang.String getIdentifier()
          Gets value of identifier attribute.
 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  java.lang.String getSecondPart()
          Gets second part of compound identifier or null if identifier is not compound.
protected  boolean hasMoreParts()
          Returns true if identifier is compound from two parts separated with dot; false otherwise.
protected  boolean isValid(ValidationResult result)
          Returns true if identifier is valid; false otherwise.
 boolean isVariable()
          Returns true if value of evaluation can change every evaluation call; false otherwise.
protected  VariableDeclaration lookupDeclaration()
           
protected  VariableDeclaration lookupDeclaration(AssessmentItem item, java.lang.String identifier)
          Looks up for variable declaration.
 void setIdentifier(java.lang.String identifier)
          Sets new value of identifier attribute.
 
Methods inherited from class org.qtitools.qti.node.expression.AbstractExpression
evaluate, evaluateSelf, getBaseType, getCardinality, getChildren, getFirstChild, getParent, getParentRequiredBaseTypes, getParentRequiredCardinalities, getProducedNumericalBaseTypes, getRequiredBaseTypes, getRequiredCardinalities, getRequiredSameBaseTypes, getRequiredSameCardinalities, getSecondChild, getType, getValue, isAnyChildNull, isNull, reset, toString, validate
 
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

ATTR_IDENTIFIER_NAME

public static final java.lang.String ATTR_IDENTIFIER_NAME
Name of identifier attribute in xml schema.

See Also:
Constant Field Values

IDENTIFIER_SEPARATOR

public static final java.lang.String IDENTIFIER_SEPARATOR
Separator between two parts of compound identifier.

See Also:
Constant Field Values
Constructor Detail

LookupExpression

public LookupExpression(ExpressionParent parent)
Constructs expression.

Parameters:
parent - parent of this expression
Method Detail

getIdentifier

public java.lang.String getIdentifier()
Gets value of identifier attribute.

Returns:
value of identifier attribute
See Also:
setIdentifier(java.lang.String)

setIdentifier

public void setIdentifier(java.lang.String identifier)
Sets new value of identifier attribute.

Parameters:
identifier - new value of identifier attribute
See Also:
getIdentifier()

hasMoreParts

protected boolean hasMoreParts()
Returns true if identifier is compound from two parts separated with dot; false otherwise.

Returns:
true if identifier is compound from two parts separated with dot; false otherwise

getFirstPart

protected java.lang.String getFirstPart()
Gets first part of compound identifier or whole identifier if identifier is not compound.

Returns:
first part of compound identifier or whole identifier if identifier is not compound

getSecondPart

protected java.lang.String getSecondPart()
Gets second part of compound identifier or null if identifier is not compound.

Returns:
second part of compound identifier or null if identifier is not compound

isValid

protected boolean isValid(ValidationResult result)
Returns true if identifier is valid; false otherwise.

This method checks:

Parameters:
result - validation result where to store eventual validation messages
Returns:
true if identifier is valid; false otherwise

lookupDeclaration

protected VariableDeclaration lookupDeclaration(AssessmentItem item,
                                                java.lang.String identifier)
Looks up for variable declaration.

Parameters:
item - where to look up
identifier - identifier of requested variable declaration
Returns:
variable declaration with given identifier or null

isVariable

public boolean isVariable()
Description copied from interface: Expression
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.

Specified by:
isVariable in interface Expression
Overrides:
isVariable in class AbstractExpression
Returns:
true if value of evaluation can change every evaluation call; false otherwise

lookupDeclaration

protected VariableDeclaration lookupDeclaration()

getProducedBaseTypes

public BaseType[] getProducedBaseTypes()
Description copied from interface: Expression
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.

Specified by:
getProducedBaseTypes in interface Expression
Overrides:
getProducedBaseTypes in class AbstractExpression
Returns:
list of all possible produced baseTypes after evaluation

getProducedCardinalities

public Cardinality[] getProducedCardinalities()
Description copied from interface: Expression
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.

Specified by:
getProducedCardinalities in interface Expression
Overrides:
getProducedCardinalities in class AbstractExpression
Returns:
list of all possible produced cardinalities after evaluation


Copyright © 2009. All Rights Reserved.