org.qtitools.qti.attribute
Class AttributeList

java.lang.Object
  extended by org.qtitools.qti.attribute.AttributeList
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<Attribute>, Validatable

public class AttributeList
extends java.lang.Object
implements Validatable, java.lang.Iterable<Attribute>

Container for all attributes of one node.

Author:
Jiri Kajaba
See Also:
Serialized Form

Field Summary
static java.lang.String ATTRIBUTES_SEPARATOR
          Separator between two attributes (valid only if attributes are printed on one line).
static int LINE_WRAP_LIMIT
          Line wrap limit while printing attributes.
 
Constructor Summary
AttributeList(XmlNode parent)
          Constructs container.
 
Method Summary
 void add(Attribute attribute)
          Adds given attribute into this container.
 void add(int index, Attribute attribute)
          Adds given attribute into this container at given position.
 void clear()
          Removed all attributes (children) from this container.
 boolean contains(java.lang.String name)
          Returns true if this container contains specified attribute; false otherwise.
 Attribute get(int index)
          Gets attribute at given index.
 Attribute get(java.lang.String name)
          Gets attribute with given name.
 BaseTypeAttribute getBaseTypeAttribute(java.lang.String name)
          Gets attribute with given name.
 BooleanAttribute getBooleanAttribute(java.lang.String name)
          Gets attribute with given name.
 CardinalityAttribute getCardinalityAttribute(java.lang.String name)
          Gets attribute with given name.
 CoordsAttribute getCoordsAttribute(java.lang.String name)
          Gets attribute with given name.
 DateAttribute getDateAttribute(java.lang.String name)
          Gets attribute with given name.
 DurationAttribute getDurationAttribute(java.lang.String name)
          Gets attribute with given name.
 FloatAttribute getFloatAttribute(java.lang.String name)
          Gets attribute with given name.
 FloatMultipleAttribute getFloatMultipleAttribute(java.lang.String name)
          Gets attribute with given name.
 IdentifierAttribute getIdentifierAttribute(java.lang.String name)
          Gets attribute with given name.
 IdentifierMultipleAttribute getIdentifierMultipleAttribute(java.lang.String name)
          Gets attribute with given name.
 IntegerAttribute getIntegerAttribute(java.lang.String name)
          Gets attribute with given name.
 LongAttribute getLongAttribute(java.lang.String name)
          Gets attribute with given name.
 NavigationModeAttribute getNavigationModeAttribute(java.lang.String name)
          Gets attribute with given name.
 OrientationAttribute getOrientationAttribute(java.lang.String name)
          Gets attribute with given name.
 ParamTypeAttribute getParamTypeAttribute(java.lang.String name)
          Gets attribute with given name.
 XmlNode getParent()
          Gets parent of this container.
 RoundingModeAttribute getRoundingModeAttribute(java.lang.String name)
          Gets attribute with given name.
 SessionStatusAttribute getSessionStatusAttribute(java.lang.String name)
          Gets attribute with given name.
 ShapeAttribute getShapeAttribute(java.lang.String name)
          Gets attribute with given name.
 SingleValueAttribute getSingleValueAttribute(java.lang.String name)
          Gets attribute with given name.
 StringAttribute getStringAttribute(java.lang.String name)
          Gets attribute with given name.
 StringMultipleAttribute getStringMultipleAttribute(java.lang.String name)
          Gets attribute with given name.
 SubmissionModeAttribute getSubmissionModeAttribuye(java.lang.String name)
          Gets attribute with given name.
 TableCellScopeAttribute getTableCellScopeAttribute(java.lang.String name)
          Gets attribute with given name.
 TestFeedbackAccessAttribute getTestFeedbackAttribute(java.lang.String name)
          Gets attribute with given name.
 TextFormatAttribute getTextFormatAttribute(java.lang.String name)
          Gets attribute with given name.
 ToleranceModeAttribute getToleranceModeAttribute(java.lang.String name)
          Gets attribute with given name.
 UriAttribute getUriAttribute(java.lang.String name)
          Gets attribute with given name.
 ViewMultipleAttribute getViewMultipleAttribute(java.lang.String name)
          Gets attribute with given name.
 VisibilityModeAttribute getVisibilityModeAttribute(java.lang.String name)
          Gets attribute with given name.
 java.util.Iterator<Attribute> iterator()
           
 void load(org.w3c.dom.Node node)
          Loads attribute's values from given source node.
 void remove(Attribute attribute)
          Removes given attribute from this container.
 int size()
          Gets number of attributes in this container.
 java.lang.String toXmlString(int depth, boolean printDefaultValues)
          Prints attributes into string.
 ValidationResult validate()
          Validates this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ATTRIBUTES_SEPARATOR

public static final java.lang.String ATTRIBUTES_SEPARATOR
Separator between two attributes (valid only if attributes are printed on one line).

See Also:
Constant Field Values

LINE_WRAP_LIMIT

public static final int LINE_WRAP_LIMIT
Line wrap limit while printing attributes.

See Also:
Constant Field Values
Constructor Detail

AttributeList

public AttributeList(XmlNode parent)
Constructs container.

Parameters:
parent - parent of constructed container
Method Detail

getParent

public XmlNode getParent()
Gets parent of this container.

Returns:
parent of this container

size

public int size()
Gets number of attributes in this container.

Returns:
number of attributes in this container

add

public void add(Attribute attribute)
         throws QTIAttributeException
Adds given attribute into this container. Checks duplicities in attribute's names.

Parameters:
attribute - given attribute
Throws:
QTIAttributeException - if container already contains attribute with same name

remove

public void remove(Attribute attribute)
Removes given attribute from this container.

Parameters:
attribute - given attribute

add

public void add(int index,
                Attribute attribute)
         throws QTIAttributeException
Adds given attribute into this container at given position. Checks duplicities in attribute's names.

Parameters:
index - position
attribute - attribute
Throws:
QTIAttributeException - if container already contains attribute with same name

load

public void load(org.w3c.dom.Node node)
Loads attribute's values from given source node. If there is unsupported (unknown) attribute, it creates new optional StringAttribute with set unsupported flag.

Parameters:
node - source node

clear

public void clear()
Removed all attributes (children) from this container.


contains

public boolean contains(java.lang.String name)
Returns true if this container contains specified attribute; false otherwise.

Parameters:
name - attribute's name
Returns:
true if this container contains specified attribute; false otherwise

get

public Attribute get(int index)
Gets attribute at given index.

Parameters:
index - index of requested attribute
Returns:
attribute at given index

get

public Attribute get(java.lang.String name)
              throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

iterator

public java.util.Iterator<Attribute> iterator()
Specified by:
iterator in interface java.lang.Iterable<Attribute>

toXmlString

public java.lang.String toXmlString(int depth,
                                    boolean printDefaultValues)
Prints attributes into string.

Parameters:
depth - left indent (used only if printed line is too long)
printDefaultValues - if true, prints all attributes; if false, prints only attributes with not default values
Returns:
printed attributes

validate

public ValidationResult validate()
Description copied from interface: Validatable
Validates this object.

Specified by:
validate in interface Validatable
Returns:
validation result

getBaseTypeAttribute

public BaseTypeAttribute getBaseTypeAttribute(java.lang.String name)
                                       throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getBooleanAttribute

public BooleanAttribute getBooleanAttribute(java.lang.String name)
                                     throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getCardinalityAttribute

public CardinalityAttribute getCardinalityAttribute(java.lang.String name)
                                             throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getDateAttribute

public DateAttribute getDateAttribute(java.lang.String name)
                               throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getDurationAttribute

public DurationAttribute getDurationAttribute(java.lang.String name)
                                       throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getFloatAttribute

public FloatAttribute getFloatAttribute(java.lang.String name)
                                 throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getFloatMultipleAttribute

public FloatMultipleAttribute getFloatMultipleAttribute(java.lang.String name)
                                                 throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getIdentifierAttribute

public IdentifierAttribute getIdentifierAttribute(java.lang.String name)
                                           throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getIdentifierMultipleAttribute

public IdentifierMultipleAttribute getIdentifierMultipleAttribute(java.lang.String name)
                                                           throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getIntegerAttribute

public IntegerAttribute getIntegerAttribute(java.lang.String name)
                                     throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getCoordsAttribute

public CoordsAttribute getCoordsAttribute(java.lang.String name)
                                   throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getLongAttribute

public LongAttribute getLongAttribute(java.lang.String name)
                               throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getNavigationModeAttribute

public NavigationModeAttribute getNavigationModeAttribute(java.lang.String name)
                                                   throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getRoundingModeAttribute

public RoundingModeAttribute getRoundingModeAttribute(java.lang.String name)
                                               throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getSessionStatusAttribute

public SessionStatusAttribute getSessionStatusAttribute(java.lang.String name)
                                                 throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getShapeAttribute

public ShapeAttribute getShapeAttribute(java.lang.String name)
                                 throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getSingleValueAttribute

public SingleValueAttribute getSingleValueAttribute(java.lang.String name)
                                             throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getStringAttribute

public StringAttribute getStringAttribute(java.lang.String name)
                                   throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getStringMultipleAttribute

public StringMultipleAttribute getStringMultipleAttribute(java.lang.String name)
                                                   throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getSubmissionModeAttribuye

public SubmissionModeAttribute getSubmissionModeAttribuye(java.lang.String name)
                                                   throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getTestFeedbackAttribute

public TestFeedbackAccessAttribute getTestFeedbackAttribute(java.lang.String name)
                                                     throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getToleranceModeAttribute

public ToleranceModeAttribute getToleranceModeAttribute(java.lang.String name)
                                                 throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getUriAttribute

public UriAttribute getUriAttribute(java.lang.String name)
                             throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getViewMultipleAttribute

public ViewMultipleAttribute getViewMultipleAttribute(java.lang.String name)
                                               throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getVisibilityModeAttribute

public VisibilityModeAttribute getVisibilityModeAttribute(java.lang.String name)
                                                   throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getOrientationAttribute

public OrientationAttribute getOrientationAttribute(java.lang.String name)
                                             throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getParamTypeAttribute

public ParamTypeAttribute getParamTypeAttribute(java.lang.String name)
                                         throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getTableCellScopeAttribute

public TableCellScopeAttribute getTableCellScopeAttribute(java.lang.String name)
                                                   throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found

getTextFormatAttribute

public TextFormatAttribute getTextFormatAttribute(java.lang.String name)
                                           throws QTIAttributeException
Gets attribute with given name.

Parameters:
name - name of requested attribute
Returns:
attribute with given name
Throws:
QTIAttributeException - if attribute is not found


Copyright © 2009. All Rights Reserved.