org.qtitools.qti.node.expression.operator
Class Equal

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.operator.Equal
All Implemented Interfaces:
java.io.Serializable, Expression, ExpressionParent, XmlNode, XmlObject, Validatable

public class Equal
extends AbstractExpression

The equal operator takes two sub-expressions which must both have single cardinality and have A numerical base-type. The result is A single boolean with A value of true if the two expressions are numerically equal and false if they are not. If either sub-expression is NULL then the operator results in NULL.

Attribute : toleranceMode [1]: toleranceMode = exact

When comparing two floating point numbers for equality it is often desirable to have A tolerance to ensure that spurious errors in scoring are not introduced by rounding errors. The tolerance mode determines whether the comparison is done exactly, using an absolute range or A relative range.

Attribute : tolerance [0..2]: floatOrTemplateRef

If the tolerance mode is absolute or relative then the tolerance must be specified. The tolerance consists of two positive numbers, t0 and t1, that define the lower and upper bounds. If only one value is given it is used for both.

In absolute mode the result of the comparison is true if the value of the second expression, y is within the following range defined by the first value, x.

x-t0,x+t1

In relative mode, t0 and t1 are treated as percentages and the following range is used instead.

x*(1-t0/100),x*(1+t1/100)

Attribute : includeLowerBound [0..1]: boolean = true

Controls whether or not the lower bound is included in the comparison

Attribute : includeUpperBound [0..1]: boolean = true

Controls whether or not the upper bound is included in the comparison

Author:
Jiri Kajaba
See Also:
Cardinality, BaseType, Serialized Form

Field Summary
static boolean ATTR_INCLUDE_LOWER_BOUND_DEFAULT_VALUE
          Default value of includeLowerBound attribute.
static java.lang.String ATTR_INCLUDE_LOWER_BOUND_NAME
          Name of includeLowerBound attribute in xml schema.
static boolean ATTR_INCLUDE_UPPER_BOUND_DEFAULT_VALUE
          Default value of incluseUpperBound attribute.
static java.lang.String ATTR_INCLUDE_UPPER_BOUND_NAME
          Name of includeUpperBound attribute in xml schema.
static java.lang.String ATTR_TOLERANCE_MODE_NAME
          Name of toleranceMode attribute in xml schema.
static java.util.List<java.lang.Double> ATTR_TOLERANCES_DEFAULT_VALUE
          Default value of tolerance attribute.
static java.lang.String ATTR_TOLERANCES_NAME
          Name of tolerance attribute in xml schema.
static java.lang.String CLASS_TAG
          Name of this class in xml schema.
 
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
Equal(ExpressionParent parent)
          Constructs expression.
 
Method Summary
protected  Value evaluateSelf(int depth)
          Evaluates this expression.
 java.lang.String getClassTag()
          Gets QTI class name of this node.
protected  double getFirstTolerance()
          Gets first tolerance if defined; zero otherwise.
 java.lang.Boolean getIncludeLowerBound()
          Gets value of includeLowerBound attribute.
 java.lang.Boolean getIncludeUpperBound()
          Gets value of includeUpperBound attribute.
protected  double getSecondTolerance()
          Gets second tolerance if defined; first tolerance otherwise.
 ToleranceMode getToleranceMode()
          Gets value of toleranceMode attribute.
 java.util.List<java.lang.Double> getTolerances()
          Gets value of tolerance attribute.
 void setIncludeLowerBound(java.lang.Boolean includeLowerBound)
          Sets new value of includeLowerBound attribute.
 void setIncludeUpperBound(java.lang.Boolean includeUpperBound)
          Sets new value of includeUpperBound attribute.
 void setToleranceMode(ToleranceMode toleranceMode)
          Sets new value of toleranceMode attribute.
protected  ValidationResult validateAttributes()
          Validates attributes of this node.
 
Methods inherited from class org.qtitools.qti.node.expression.AbstractExpression
evaluate, getBaseType, getCardinality, getChildren, getFirstChild, getParent, getParentRequiredBaseTypes, getParentRequiredCardinalities, getProducedBaseTypes, getProducedCardinalities, getProducedNumericalBaseTypes, getRequiredBaseTypes, getRequiredCardinalities, getRequiredSameBaseTypes, getRequiredSameCardinalities, getSecondChild, getType, getValue, isAnyChildNull, isNull, isVariable, 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, 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, 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, getFullName, getNodeGroups, getParentRoot, getSimpleName, getSourceFile, getSourceNode, getSourceString, getSourceUrl, hasChildNodes, load, load, load, load, setSourceFile, setSourceNode, setSourceString, setSourceUrl, toXmlString, toXmlString
 

Field Detail

CLASS_TAG

public static final java.lang.String CLASS_TAG
Name of this class in xml schema.

See Also:
Constant Field Values

ATTR_TOLERANCE_MODE_NAME

public static final java.lang.String ATTR_TOLERANCE_MODE_NAME
Name of toleranceMode attribute in xml schema.

See Also:
Constant Field Values

ATTR_TOLERANCES_NAME

public static final java.lang.String ATTR_TOLERANCES_NAME
Name of tolerance attribute in xml schema.

See Also:
Constant Field Values

ATTR_TOLERANCES_DEFAULT_VALUE

public static final java.util.List<java.lang.Double> ATTR_TOLERANCES_DEFAULT_VALUE
Default value of tolerance attribute.


ATTR_INCLUDE_LOWER_BOUND_NAME

public static final java.lang.String ATTR_INCLUDE_LOWER_BOUND_NAME
Name of includeLowerBound attribute in xml schema.

See Also:
Constant Field Values

ATTR_INCLUDE_LOWER_BOUND_DEFAULT_VALUE

public static final boolean ATTR_INCLUDE_LOWER_BOUND_DEFAULT_VALUE
Default value of includeLowerBound attribute.

See Also:
Constant Field Values

ATTR_INCLUDE_UPPER_BOUND_NAME

public static final java.lang.String ATTR_INCLUDE_UPPER_BOUND_NAME
Name of includeUpperBound attribute in xml schema.

See Also:
Constant Field Values

ATTR_INCLUDE_UPPER_BOUND_DEFAULT_VALUE

public static final boolean ATTR_INCLUDE_UPPER_BOUND_DEFAULT_VALUE
Default value of incluseUpperBound attribute.

See Also:
Constant Field Values
Constructor Detail

Equal

public Equal(ExpressionParent parent)
Constructs expression.

Parameters:
parent - parent of this expression
Method Detail

getClassTag

public java.lang.String getClassTag()
Description copied from interface: XmlNode
Gets QTI class name of this node.

QTI class name has very important role during loading/saving nodes.

For example: Java class name is AssessmentTest; QTI class name is assessmentTest.

Specified by:
getClassTag in interface XmlNode
Specified by:
getClassTag in class AbstractNode
Returns:
QTI class name of this node

getToleranceMode

public ToleranceMode getToleranceMode()
Gets value of toleranceMode attribute.

Returns:
value of toleranceMode attribute
See Also:
setToleranceMode(org.qtitools.qti.node.expression.operator.ToleranceMode)

setToleranceMode

public void setToleranceMode(ToleranceMode toleranceMode)
Sets new value of toleranceMode attribute.

Parameters:
toleranceMode - new value of toleranceMode attribute
See Also:
getToleranceMode()

getTolerances

public java.util.List<java.lang.Double> getTolerances()
Gets value of tolerance attribute.

Returns:
value of tolerance attribute

getFirstTolerance

protected double getFirstTolerance()
Gets first tolerance if defined; zero otherwise.

Returns:
first tolerance if defined; zero otherwise

getSecondTolerance

protected double getSecondTolerance()
Gets second tolerance if defined; first tolerance otherwise.

Returns:
second tolerance if defined; first tolerance otherwise

getIncludeLowerBound

public java.lang.Boolean getIncludeLowerBound()
Gets value of includeLowerBound attribute.

Returns:
value of includeLowerBound attribute
See Also:
setIncludeLowerBound(java.lang.Boolean)

setIncludeLowerBound

public void setIncludeLowerBound(java.lang.Boolean includeLowerBound)
Sets new value of includeLowerBound attribute.

Parameters:
includeLowerBound - new value of includeLowerBound attribute
See Also:
getIncludeLowerBound()

getIncludeUpperBound

public java.lang.Boolean getIncludeUpperBound()
Gets value of includeUpperBound attribute.

Returns:
value of includeUpperBound attribute
See Also:
setIncludeUpperBound(java.lang.Boolean)

setIncludeUpperBound

public void setIncludeUpperBound(java.lang.Boolean includeUpperBound)
Sets new value of includeUpperBound attribute.

Parameters:
includeUpperBound - new value of includeUpperBound attribute
See Also:
getIncludeUpperBound()

validateAttributes

protected ValidationResult validateAttributes()
Description copied from class: AbstractNode
Validates attributes of this node.

Overrides:
validateAttributes in class AbstractNode
Returns:
result of validation

evaluateSelf

protected Value evaluateSelf(int depth)
Description copied from class: AbstractExpression
Evaluates this expression. All children must be already evaluated. Contains no checks.

Specified by:
evaluateSelf in class AbstractExpression
Parameters:
depth - depth of this expression in expression tree (root's depth = 0)
Returns:
result of evaluation


Copyright © 2009. All Rights Reserved.