org.qtitools.qti.node.shared
Class FieldValue

java.lang.Object
  extended by org.qtitools.qti.node.AbstractNode
      extended by org.qtitools.qti.node.AbstractObject
          extended by org.qtitools.qti.node.shared.FieldValue
All Implemented Interfaces:
java.io.Serializable, XmlNode, XmlObject, Validatable

public class FieldValue
extends AbstractObject

A class that can represent A single value of any baseType in variable declarations and result reports. The base-type is defined by the baseType attribute of the declaration except in the case of variables with record cardinality.

This class has different name (fieldValue instead of value) in specification. Name value was already taken.

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_IDENTIFIER_DEFAULT_VALUE
          Default value of fieldIdentifier attribute.
static java.lang.String ATTR_IDENTIFIER_NAME
          Name of fieldIdentifier attribute in xml schema.
static java.lang.String CLASS_TAG
          Name of this class in xml schema.
 
Fields inherited from interface org.qtitools.qti.node.XmlNode
INDENT, NEW_LINE, SIMPLE_NAME_INNER_SEPARATOR, SIMPLE_NAMES_SEPARATOR
 
Constructor Summary
FieldValue(FieldValueParent parent)
          Creates object.
 
Method Summary
protected  java.lang.String bodyToXmlString(int depth, boolean printDefaultAttributes)
          Prints body (children and/or text content) of this node into xml string.
 BaseType getBaseType()
          Gets baseType of this fieldValue.
 BaseType getBaseTypeAttrValue()
          Gets value of baseType attribute.
 java.lang.String getClassTag()
          Gets QTI class name of this node.
 java.lang.String getIdentifier()
          Gets value of fieldIdentifier attribute.
 FieldValueParent getParent()
          Gets parent of this node or null (if node is root; for example AssessmentTest).
 java.lang.String getSimpleName()
          Gets simple name of this node.
 SingleValue getSingleValue()
          Gets single value of this fieldValue.
static Value getValue(Cardinality cardinality, java.util.List<FieldValue> values)
          Constructs value (of any cardinality) from given list of fieldValues (list of single values).
static java.util.List<FieldValue> getValues(FieldValueParent parent, Value value)
          Constructs list of fieldValues (list of single values) from given value (of any cardinality).
protected  void readChildren(org.w3c.dom.Node node)
          Reads all children nodes and/or content from given xml source.
 void setBaseTypeAttrValue(BaseType baseType)
          Sets new value of baseType attribute.
 void setIdentifier(java.lang.String identifier)
          Sets new value of fieldIdentifier attribute.
 void setSingleValue(SingleValue singleValue)
          Sets new single value of this fieldValue.
protected  ValidationResult validateAttributes()
          Validates attributes of this node.
protected  ValidationResult validateChildren()
          Validates children (body) of this node.
 
Methods inherited from class org.qtitools.qti.node.AbstractObject
getParentItem, getParentResult, getParentTest, setParent
 
Methods inherited from class org.qtitools.qti.node.AbstractNode
attrToXmlString, getAttributes, getFullName, getIndent, getNode, getNode, getNode, getNodeGroups, getParentRoot, getSourceFile, getSourceNode, getSourceString, getSourceUrl, hasChildNodes, load, load, load, load, loadAttributes, readChild, setParent, setSourceFile, setSourceNode, setSourceString, setSourceUrl, toXmlString, toXmlString, validate
 
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, 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

CLASS_TAG

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

See Also:
Constant Field Values

ATTR_IDENTIFIER_NAME

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

See Also:
Constant Field Values

ATTR_IDENTIFIER_DEFAULT_VALUE

public static final java.lang.String ATTR_IDENTIFIER_DEFAULT_VALUE
Default value of fieldIdentifier attribute.


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

FieldValue

public FieldValue(FieldValueParent parent)
Creates object.

Parameters:
parent - parent of this object
Method Detail

getParent

public FieldValueParent getParent()
Description copied from interface: XmlNode
Gets parent of this node or null (if node is root; for example AssessmentTest).

While 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).

Specified by:
getParent in interface XmlNode
Specified by:
getParent in interface XmlObject
Overrides:
getParent in class AbstractObject
Returns:
parent of this node or null (if node is root; for example AssessmentTest)

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

getSimpleName

public java.lang.String getSimpleName()
Description copied from interface: XmlNode
Gets simple name of this node. Simple name contains QTI class name and some additional information to help identify node (if these informations are available).

Simple name is not so important like QTI class name. It servers mostly for displaying informations and in messages.

For example: simple name can be assessmentTest:Test (QTI class name (assessmentTest) + identifier (Test)).

Specified by:
getSimpleName in interface XmlNode
Overrides:
getSimpleName in class AbstractNode
Returns:
simple name of this node
See Also:
XmlNode.getFullName()

getIdentifier

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

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

setIdentifier

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

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

getBaseTypeAttrValue

public BaseType getBaseTypeAttrValue()
Gets value of baseType attribute.

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

setBaseTypeAttrValue

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

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

getBaseType

public BaseType getBaseType()
Gets baseType of this fieldValue.
  1. if cardinality of parent variableDeclaration is not record, uses parent's baseType
  2. if cardinality of parent variableDeclaration is record, uses its own baseType

Returns:
baseType of this fieldValue

getSingleValue

public SingleValue getSingleValue()
Gets single value of this fieldValue.

Returns:
single value of this fieldValue
See Also:
setSingleValue(org.qtitools.qti.value.SingleValue)

setSingleValue

public void setSingleValue(SingleValue singleValue)
Sets new single value of this fieldValue.

Parameters:
singleValue - new single value of this fieldValue
See Also:
getSingleValue()

readChildren

protected void readChildren(org.w3c.dom.Node node)
Description copied from class: AbstractNode
Reads all children nodes and/or content from given xml source. Every subclass must implement its own children nodes and/or content reading. If there are no children nodes and content do nothing (you don't even need to override this method).

Overrides:
readChildren in class AbstractNode
Parameters:
node - xml source

bodyToXmlString

protected java.lang.String bodyToXmlString(int depth,
                                           boolean printDefaultAttributes)
Description copied from class: AbstractNode
Prints body (children and/or text content) of this node into xml string.

Overrides:
bodyToXmlString in class AbstractNode
Parameters:
depth - depth in xml tree (root = 0)
printDefaultAttributes - whether print attributes with default values
Returns:
xml string with printed body (children and/or text content) of this node

validateAttributes

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

Overrides:
validateAttributes in class AbstractNode
Returns:
result of validation

validateChildren

protected ValidationResult validateChildren()
Description copied from class: AbstractNode
Validates children (body) of this node.

Overrides:
validateChildren in class AbstractNode
Returns:
result of validation

getValue

public static Value getValue(Cardinality cardinality,
                             java.util.List<FieldValue> values)
Constructs value (of any cardinality) from given list of fieldValues (list of single values). If list of fieldValues is empty returns NullValue.

Parameters:
cardinality - requested cardinality
values - given list of fieldValues (list of single values)
Returns:
value (of any cardinality) from given list of fieldValues (list of single values)
See Also:
getValues(org.qtitools.qti.node.shared.FieldValueParent, org.qtitools.qti.value.Value)

getValues

public static java.util.List<FieldValue> getValues(FieldValueParent parent,
                                                   Value value)
Constructs list of fieldValues (list of single values) from given value (of any cardinality). If given value is null (java) or NULL (qti) returns empty list.

Parameters:
parent - parent of constructed fieldValues
value - given value (of any cardinality)
Returns:
list of fieldValues (list of single values) from given value (of any cardinality)
See Also:
getValue(org.qtitools.qti.value.Cardinality, java.util.List)


Copyright © 2009. All Rights Reserved.