org.inria.ns.reflex.processor.xcl
Class IfAction

java.lang.Object
  extended by org.inria.ns.reflex.processor.core.AbstractAction
      extended by org.inria.ns.reflex.processor.xcl.IfAction
All Implemented Interfaces:
Executable, Presentable, NamespaceContextFactory

public class IfAction
extends AbstractAction

The <xcl:if> element selects one alternative depending on the evaluation given by the expression specified in the test attribute.

<xcl:if test="{expression}">
    <xcl:then>
        <!-- do something -->
    </xcl:then>
    <xcl:else>
        <!-- do something -->
    </xcl:else>
</xcl:if>

Author:
Philippe Poulard
See Also:
IfAttr, AlternativeAction

Nested Class Summary
 
Nested classes/interfaces inherited from class org.inria.ns.reflex.processor.core.AbstractAction
AbstractAction.ParameterAdapter, AbstractAction.UselessAction
 
Field Summary
 
Fields inherited from class org.inria.ns.reflex.processor.core.AbstractAction
actions, parent, processorInstance
 
Constructor Summary
IfAction(Expression test, Node node, AbstractAction parent)
          Creates a new instance of IfAction.
 
Method Summary
 void addAction(AbstractAction action)
          Handle <xcl:then> and <xcl:else> elements, and subelements of an element hosting the @xcl:if foreign attribute.
 void runAction(DataSet dataSet)
          Execute the action by evaluating the test and executing the dependent actions in the then branch or in the else branch, if any.
static AbstractAction unmarshal(AbstractAction parent, Element element)
          XML unmarshaller for IfAction.
 
Methods inherited from class org.inria.ns.reflex.processor.core.AbstractAction
addFallbackAction, createContext, getCanonicalPath, getFallbackAction, getLocalFallbackAction, getLogger, getNamespaceContext, getNode, getParent, recover, recover, removeFallbackAction, reorganize, run, runActions, toPrettyString, toPrettyString, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IfAction

public IfAction(Expression test,
                Node node,
                AbstractAction parent)
Creates a new instance of IfAction.

Parameters:
test - The test to evaluate.
node - The node from which the action has been unmarshalled. Used for namespace prefix resolution when performing XPath expressions.
parent - The action depending from.
Method Detail

unmarshal

public static AbstractAction unmarshal(AbstractAction parent,
                                       Element element)
                                throws XMLException
XML unmarshaller for IfAction.

Parameters:
parent - The action depending from.
element - The XML element to unmarshall.
Returns:
The IfAction created.
Throws:
UnmarshalException - When the element and its content is not those expected.
XMLException

addAction

public void addAction(AbstractAction action)
Handle <xcl:then> and <xcl:else> elements, and subelements of an element hosting the @xcl:if foreign attribute.

Overrides:
addAction in class AbstractAction
Parameters:
action - A subelement.
See Also:
AlternativeAction, AbstractAction.addAction(org.inria.ns.reflex.processor.core.AbstractAction)

runAction

public void runAction(DataSet dataSet)
               throws ExecutionException,
                      XPathException
Execute the action by evaluating the test and executing the dependent actions in the then branch or in the else branch, if any.

Overrides:
runAction in class AbstractAction
Parameters:
dataSet - The set of datas used when the action is running.
Throws:
ExecutionException - If the action can't be performed.
XPathException