org.specrunner.plugins.core.flow
Class PluginWhile

java.lang.Object
  extended by org.specrunner.parameters.core.ParameterHolder
      extended by org.specrunner.plugins.core.AbstractPlugin
          extended by org.specrunner.plugins.core.AbstractPluginNamed
              extended by org.specrunner.plugins.core.AbstractPluginScoped
                  extended by org.specrunner.plugins.core.AbstractPluginValue
                      extended by org.specrunner.plugins.core.flow.PluginWhile
All Implemented Interfaces:
IParameterHolder, IActionType, IParalelPlugin, IPlugin, ISleepPlugin, ITestPlugin, ITimedPlugin, IWaitPlugin

public class PluginWhile
extends AbstractPluginValue

Performs a conditional loop.

Example:

While the number of elements x (initially 10) is bigger than 5 (x>5), calculate:
x square cubic
${x} ${x * x} ${x * x * x}

The CSS annotated version:

 <div>
 While the number of elements <span class="local" name="x" value="10">x (initially 10)</span> is bigger than 5 (x>5), calculate:
 <table border=1>
 <tr>
 <th>x</th>
 <th>square</th>
 <th>cubic</th>
 </tr>
 <tbody class="while" test="x>5">
 <tr >
 <td>${x}</td>
 <td>${x * x}</td>
 <td>${x * x * x}</td>
 </tr>
 <local scope="div" name="x" value="x-1"/>
 <tbody>
 </table>
 </div>
 
Alternative version using "condition". * The CSS annotated version:
 <div>
 While the number of elements <span class="local" name="x" value="10">x (initially 10)</span> is bigger than 5 (<span class="condition" name="cond1">x>5</span>), calculate:
 <table border=1>
 <tr>
 <th>x</th>
 <th>square</th>
 <th>cubic</th>
 </tr>
 <tbody class="while" name="cond1">
 <tr >
 <td>${x}</td>
 <td>${x * x}</td>
 <td>${x * x * x}</td>
 </tr>
 <local scope="div" name="x" value="x-1"/>
 <tbody>
 </table>
 </div>
 

Author:
Thiago Santos

Field Summary
 
Fields inherited from class org.specrunner.plugins.core.AbstractPlugin
FEATURE_CONDITION, FEATURE_NORMALIZED, FEATURE_SLEEP, FEATURE_THREADSAFE, FEATURE_TIMEOUT, FEATURE_WAIT
 
Constructor Summary
PluginWhile()
           
 
Method Summary
protected  boolean checkCondition(String test, IContext context)
          Check condition.
 ENext doStart(IContext context, IResultSet result)
          Performs the start action. i.e. create a database schema.
 ActionType getActionType()
          Get the plugin type.
 
Methods inherited from class org.specrunner.plugins.core.AbstractPluginValue
getValue, getValue, isEval, setEval, setValue
 
Methods inherited from class org.specrunner.plugins.core.AbstractPluginScoped
getScope, saveGlobal, saveLocal, saveStrict, setScope
 
Methods inherited from class org.specrunner.plugins.core.AbstractPluginNamed
getName, setName
 
Methods inherited from class org.specrunner.plugins.core.AbstractPlugin
copy, doEnd, getCondition, getConditionModel, getNormalized, getNormalized, getParent, getSleep, getSleepModel, getThreadsafe, getTimeout, getTimeoutModel, getWait, getWaitModel, initialize, setCondition, setConditionModel, setNormalized, setParent, setSleep, setSleepModel, setThreadsafe, setTimeout, setTimeoutModel, setWait, setWaitModel, toString
 
Methods inherited from class org.specrunner.parameters.core.ParameterHolder
getParameters, setParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.specrunner.parameters.IParameterHolder
getParameters, setParameters
 

Constructor Detail

PluginWhile

public PluginWhile()
Method Detail

getActionType

public ActionType getActionType()
Description copied from interface: IActionType
Get the plugin type.

Returns:
The type.

doStart

public ENext doStart(IContext context,
                     IResultSet result)
              throws PluginException
Description copied from interface: IPlugin
Performs the start action. i.e. create a database schema. Performed after initialization.

Specified by:
doStart in interface IPlugin
Overrides:
doStart in class AbstractPlugin
Parameters:
context - The context.
result - The result set.
Returns:
SKIP, to skip node, DEEP, to go deep into the node.
Throws:
PluginException - On execution errors.

checkCondition

protected boolean checkCondition(String test,
                                 IContext context)
                          throws PluginException
Check condition.

Parameters:
test - The condition.
context - The context.
Returns:
true, if condition is valid, false, otherwise.
Throws:
PluginException - On evaluation errors.


Copyright © 2014. All rights reserved.