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

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

public class ReadAction
extends AbstractSetAction

At runtime, the <io:read> element, reads datas in the input stream specified by the input attribute.

The mode attribute specify the amount of datas to read :

A new property with the name specified in the name attribute that contains the data read, is added to the data set.

 <io:read name="myLine" input="{ expression }" mode ="line"
 xmlns:io="http://ns.inria.org/active-tags/io"/>
 
 <io:read name="myChar" input="{ expression }" mode ="char"
 xmlns:io="http://ns.inria.org/active-tags/io"/>
 
 <io:read name="myByte" input="{ expression }" mode ="byte"
 xmlns:io="http://ns.inria.org/active-tags/io"/>
 

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.AbstractSetAction
NO_VALUE
 
Fields inherited from class org.inria.ns.reflex.processor.core.AbstractAction
actions, parent, processorInstance
 
Constructor Summary
ReadAction(Expression file, int mode, Element element, AbstractAction parent)
          Create a new instance of ReadAction.
 
Method Summary
 Object getComputedValue(DataSet dataSet)
          Return the computed value of the property, by reading a file.
static AbstractAction unmarshal(AbstractAction parent, Element e)
          XML unmarshaller for ReadAction.
 
Methods inherited from class org.inria.ns.reflex.processor.core.AbstractSetAction
addProperty, getComputedName, getName, getValue, runAction, scope, unmarshalScope
 
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

ReadAction

public ReadAction(Expression file,
                  int mode,
                  Element element,
                  AbstractAction parent)
           throws XMLException
Create a new instance of ReadAction.

Parameters:
file - The file to read, that will be the value of the property, as an Expression.
mode - The amount of datas to read.
element - The element from which the action has been unmarshalled. Used for namespace prefix resolution when performing XPath expressions.
parent - The action depending from.
Throws:
XMLException
Method Detail

unmarshal

public static AbstractAction unmarshal(AbstractAction parent,
                                       Element e)
                                throws XMLException
XML unmarshaller for ReadAction.

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

getComputedValue

public Object getComputedValue(DataSet dataSet)
                        throws ExecutionException,
                               XPathException
Return the computed value of the property, by reading a file.

Specified by:
getComputedValue in interface Computable
Specified by:
getComputedValue in class AbstractSetAction
Parameters:
dataSet - The set of data used when the name is computed.
Returns:
The computed value of the property.
Throws:
ExecutionException - If the computation can't be performed.
XPathException