org.inria.ns.reflex.modules.io
Class WriteAction

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

public class WriteAction
extends AbstractAction

At runtime, the <io:write> element, writes the content specified by the content attribute, in the stream specified by the output attribute.

 <io:write output="{$MyFile}" content="{ expression }"
 xmlns:io="http://ns.inria.org/active-tags/io"/>
 

The mode of writing is specified when opening the file by using the mode attribute of the io:open element.

 <io:open name="MyFile"
     uri="{ expression }" mode="append"
     xmlns:io="http://ns.inria.org/active-tags/io"/>
 <io:write output="{$MyFile}" content="something to write"
     xmlns:io="http://ns.inria.org/active-tags/io"/>
 

The mode of writing in this example is append.

The write mode replaces the last content by the new one.

Author:
Philippe Poulard
See Also:
OpenAction

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
WriteAction(Expression content, Expression file, Node node, AbstractAction parent)
          Creates a new instance of WriteAction.
 
Method Summary
 void runAction(DataSet dataSet)
          Execute the action by writing the content in the file, according to the mode of writing specified in the mode attribute of the open element.
static AbstractAction unmarshal(AbstractAction parent, Element e)
          XML unmarshaller for WriteAction.
 
Methods inherited from class org.inria.ns.reflex.processor.core.AbstractAction
addAction, 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

WriteAction

public WriteAction(Expression content,
                   Expression file,
                   Node node,
                   AbstractAction parent)
Creates a new instance of WriteAction.

Parameters:
content - The content to put in the file.
source - The name of the file in which write the content.
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 e)
                                throws XMLException
XML unmarshaller for WriteAction.

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

runAction

public void runAction(DataSet dataSet)
               throws ExecutionException,
                      XPathException
Execute the action by writing the content in the file, according to the mode of writing specified in the mode attribute of the open element.

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