org.qtitools.qti.node.shared
Class VariableDeclaration

java.lang.Object
  extended by org.qtitools.qti.node.AbstractNode
      extended by org.qtitools.qti.node.AbstractObject
          extended by org.qtitools.qti.node.UniqueObject
              extended by org.qtitools.qti.node.shared.VariableDeclaration
All Implemented Interfaces:
java.io.Serializable, XmlNode, XmlObject, Validatable
Direct Known Subclasses:
OutcomeDeclaration, ResponseDeclaration, TemplateDeclaration

public abstract class VariableDeclaration
extends UniqueObject

Item variables are declared by variable declarations. All variables must be declared except for the built-in session variables which are declared implicitly and must not be declared. The purpose of the declaration is to associate an identifier with the variable and to identify the runtime type of the variable's value.

Author:
Jiri Kajaba
See Also:
Serialized Form

Field Summary
static BaseType ATTR_BASE_TYPE_DEFAULT_VALUE
          Default value of baseType attribute.
static java.lang.String ATTR_BASE_TYPE_NAME
          Name of baseType attribute in xml schema.
static java.lang.String ATTR_CARDINALITY_NAME
          Name of cardinality attribute in xml schema.
 
Fields inherited from class org.qtitools.qti.node.UniqueObject
ATTR_IDENTIFIER_NAME
 
Fields inherited from interface org.qtitools.qti.node.XmlNode
INDENT, NEW_LINE, SIMPLE_NAME_INNER_SEPARATOR, SIMPLE_NAMES_SEPARATOR
 
Constructor Summary
VariableDeclaration(UniqueObject parent)
          Creates object.
 
Method Summary
 BaseType getBaseType()
          Gets value of baseType attribute.
 Cardinality getCardinality()
          Gets value of cardinality attribute.
 DefaultValue getDefaultValue()
          Gets defaultValue child.
 Value getValue()
          Gets value of this variableDeclaration.
 void resetValue()
          Resets value of this variableDeclaration to default.
 void setBaseType(BaseType baseType)
          Sets new value of baseType attribute.
 void setCardinality(Cardinality cardinality)
          Sets new value of cardinality attribute.
 void setDefaultValue(DefaultValue defaultValue)
          Sets new defaultValue child.
 void setValue(Value value)
          Sets new value of this variableDeclaration.
protected  ValidationResult validateAttributes()
          Validates attributes of this node.
 
Methods inherited from class org.qtitools.qti.node.UniqueObject
getIdentifier, getSimpleName, setIdentifier
 
Methods inherited from class org.qtitools.qti.node.AbstractObject
getParent, getParentItem, getParentResult, getParentTest, setParent
 
Methods inherited from class org.qtitools.qti.node.AbstractNode
attrToXmlString, bodyToXmlString, getAttributes, getClassTag, getFullName, getIndent, getNode, getNode, getNode, getNodeGroups, getParentRoot, getSourceFile, getSourceNode, getSourceString, getSourceUrl, hasChildNodes, load, load, load, load, loadAttributes, readChild, readChildren, setParent, setSourceFile, setSourceNode, setSourceString, setSourceUrl, toXmlString, toXmlString, validate, validateChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.qtitools.qti.node.XmlNode
getAttributes, getClassTag, getFullName, getNodeGroups, getParentRoot, 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

ATTR_CARDINALITY_NAME

public static final java.lang.String ATTR_CARDINALITY_NAME
Name of cardinality attribute in xml schema.

See Also:
Constant Field Values

ATTR_BASE_TYPE_NAME

public static final java.lang.String ATTR_BASE_TYPE_NAME
Name of baseType attribute in xml schema.

See Also:
Constant Field Values

ATTR_BASE_TYPE_DEFAULT_VALUE

public static final BaseType ATTR_BASE_TYPE_DEFAULT_VALUE
Default value of baseType attribute.

Constructor Detail

VariableDeclaration

public VariableDeclaration(UniqueObject parent)
Creates object.

Parameters:
parent - parent of this object
Method Detail

getCardinality

public Cardinality getCardinality()
Gets value of cardinality attribute.

Returns:
value of cardinality attribute
See Also:
setCardinality(org.qtitools.qti.value.Cardinality)

setCardinality

public void setCardinality(Cardinality cardinality)
Sets new value of cardinality attribute.

Parameters:
cardinality - new value of cardinality attribute
See Also:
getCardinality()

getBaseType

public BaseType getBaseType()
Gets value of baseType attribute.

Returns:
value of baseType attribute
See Also:
setBaseType(org.qtitools.qti.value.BaseType)

setBaseType

public void setBaseType(BaseType baseType)
Sets new value of baseType attribute.

Parameters:
baseType - new value of baseType attribute
See Also:
getBaseType()

getDefaultValue

public DefaultValue getDefaultValue()
Gets defaultValue child.

Returns:
defaultValue child
See Also:
setDefaultValue(org.qtitools.qti.node.shared.declaration.DefaultValue)

setDefaultValue

public void setDefaultValue(DefaultValue defaultValue)
Sets new defaultValue child.

Parameters:
defaultValue - new defaultValue child
See Also:
getDefaultValue()

getValue

public Value getValue()
Gets value of this variableDeclaration.

Returns:
value of this variableDeclaration
See Also:
setValue(org.qtitools.qti.value.Value)

setValue

public void setValue(Value value)
Sets new value of this variableDeclaration.

Parameters:
value - new value of this variableDeclaration
See Also:
getValue()

resetValue

public void resetValue()
Resets value of this variableDeclaration to default.
  1. if contains defaultValue, uses its value
  2. if single cardinality and numeric baseType, sets value to 0 or 0.0
  3. sets null otherwise


validateAttributes

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

Overrides:
validateAttributes in class UniqueObject
Returns:
result of validation


Copyright © 2009. All Rights Reserved.