junit.extensions.xml.elements
Class ForeachTagHandler

java.lang.Object
  extended byjunit.extensions.xml.elements.AbstractTagHandler
      extended byjunit.extensions.xml.elements.ForeachTagHandler
All Implemented Interfaces:
XMLConstants

public class ForeachTagHandler
extends AbstractTagHandler

Title: class ForeachTagHandler

Description: This tag handler implements a looping construct to visit each cell or index in a table or list.

Summary

<for-each id="propname" refid="componentname" type="tablecell|listitem" [row="rownumber"] [column="columnumber"]/>

Required

id - property name for the output values

refid - component to be iterated over.

type - tablecell or listitem depending on the component type. If tablecell then the refid object is assumed to be a JTable instance. If listitem then the refid object is assumed to be a JList object or JComboBox.

Optional

row - row will only be used when type = tablecell. when row is set the row specified will be scanned. column - column will only be used when type = tabecell. When column is set only the column specified will be iterated.

Children

The child nodes of this element will be processed.

Outputs

The following will be the outputs for type = listitem. The id will be replaced by the value of the id attribute:

id is the value of model item being iterated.

id.index where id will be replaced by the value of the id attribute. The value of the index wil be the index of the item being iterated.

The following will be the outputs for type = tablecell. The id will be replaced by the value of the id attribute:

id is the value of model item being iterated.

id.row row number of the current cell

id.column column number of the current cell

Examples

Iterate over all cells of a table.

 <for-each type="tablecell" refid="Table" id="cell" />
     <echo message="tablecell(${cell.row}, ${cell.column}) = ${cell}" mode="stdout"/>
 </for-each>
 
Iterate over a column of a table.


 <for-each type="tablecell" refid="Table" id="cell" column="1"/>
     <echo message="tablecell(${cell.row}, ${cell.column}) = ${cell}" mode="stdout"/>
 </for-each>
 
Iterate over a row of a table.

 <for-each type="tablecell" refid="Table" id="cell" row="1"/>
     <echo message="tablecell(${cell.row}, ${cell.column}) = ${cell}" mode="stdout"/>
 </for-each>
 
Iterate over a list.

 <for-each type="listitem" refid="List" id="item"/>
     <echo message="listitem(${item.index}) = ${item}"
     mode="stdout"/>
 </for-each>
 

Copyright: Copyright (c) 2003

Company:

Version:
1.0
Author:
not attributable

Field Summary
 
Fields inherited from class junit.extensions.xml.elements.AbstractTagHandler
 
Fields inherited from interface junit.extensions.xml.XMLConstants
ACTION, ACTUALOBJ, ACTUALREFID, ADD, ASSERTENABLED, ASSERTEQUALS, ASSERTNOTEQUALS, ASSERTNOTNULL, ASSERTNOTSAME, ASSERTNULL, ASSERTSAME, CALL, CASE, CHOOSE, CLASSNAME, COLUMN, CONFIRM, DEBUG, DEFAULT, DELIMITER, DIALOG, DUMP, ECHO, ENABLED, ENCODING, EVALUATE, EXPECTEDOBJ, EXPECTEDREFID, FAIL, FILE, FOCUS, FOREACH, ID, INDEX, JFCFILELOC, LESSTHAN, LISTITEM, LOG, MARK, MESSAGE, METHOD, MODE, NAME, OTHERWISE, PATHREFID, PROCEDURE, PROPERTY, RECURSIVE, REFID, RELATIVE, REMOVE, ROW, SAVE, STDERR, STDOUT, STOPWATCH, SUITE, SWITCH, TABLECELL, TAGHANDLERS, TAGNAME, TEST, TYPE, USERE, VALUE, WHEN, WHILE
 
Constructor Summary
ForeachTagHandler(org.w3c.dom.Element element, IXMLTestCase testCase)
          Constructor.
 
Method Summary
 void processElement()
          process the element.
 void validateElement()
          Validate that the element is correct.
 
Methods inherited from class junit.extensions.xml.elements.AbstractTagHandler
checkAtLeastOneRequiredAttribute, checkAtLeastOneRequiredAttribute, checkElementTagName, checkOneRequiredAttribute, checkOneRequiredAttribute, checkRequiredAttribute, checkRequiredAttribute, getBoolean, getBoolean, getBoolean, getBoolean, getElement, getInt, getInt, getLong, getLong, getPoint, getPoint, getString, getString, getString, getString, getTagName, getTest, getTestCase, getXMLTestCase, getXMLTestSuite, resolveVariables
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForeachTagHandler

public ForeachTagHandler(org.w3c.dom.Element element,
                         IXMLTestCase testCase)
Constructor.

Parameters:
element - Element to be processed.
testCase - Test case processing tag handler.
Method Detail

processElement

public void processElement()
                    throws XMLException
process the element.

Specified by:
processElement in class AbstractTagHandler
Throws:
XMLException - is thrown if the element cannot be understood.

validateElement

public void validateElement()
                     throws XMLException
Validate that the element is correct.

Overrides:
validateElement in class AbstractTagHandler
Throws:
XMLException - may be thrown.


Licensed under: GNU Lesser General Public License, Ver 2.1, February 1999