org.inria.ns.reflex.processor.core
Class AbstractSetAction

java.lang.Object
  extended by org.inria.ns.reflex.processor.core.AbstractAction
      extended by org.inria.ns.reflex.processor.core.AbstractSetAction
All Implemented Interfaces:
Computable, Executable, Presentable, NamespaceContextFactory
Direct Known Subclasses:
AbstractFilterAction, ConnectAction, CreateDirAction, FileAction, ForEachAction, InvokeAction, OpenAction, ParseAction, ParseFilterAction, ParseHTMLAction, ParseSchemaAction, ParseStylesheetAction, ParseTypeAction, QueryAction, ReadAction, RequestAction, SetAction, TransformAction, UnmarshalAction, XMLDocument

public abstract class AbstractSetAction
extends AbstractAction
implements Computable

Provides basic infrastructure for actions that will set a property to the data set at runtime.

Such action must defines the following attributes :

and optionnaly :

The attributes name and value may appeared in the action element with other names. See the documentation of such element to know which attributes take the role of name and value .

At runtime, a property is added to the data set. Its name is computed with the data set given. Its value depends on the sub-classe implementation. If the name was omitted (tha attribute was missing), the value computed is set as the current object.

At runtime, if the name's property is a QName (qualified name), then the corresponding namespace must be declared on the action element or one of its ancestors.

Scope

A property may be local,global, or shared according to the value of the scope attribute :

When a property is required, it is searched first within the local properties, then within the global properties, and last within the shared properties.

According to its scope, a property may be shadowed by another property with the same name and a higher accessed priority.

Extension

A concrete implementation of AbstractSetAction shouldn't override the runAction(DataSet) method, that adds the property to the data set, but rather the getComputedValue(DataSet dataSet) method.

Author:
Philippe Poulard
See Also:
DataSet, QName

Nested Class Summary
 
Nested classes/interfaces inherited from class org.inria.ns.reflex.processor.core.AbstractAction
AbstractAction.ParameterAdapter, AbstractAction.UselessAction
 
Field Summary
static Object NO_VALUE
          Indicates that this is not a value.
 
Fields inherited from class org.inria.ns.reflex.processor.core.AbstractAction
actions, parent, processorInstance
 
Constructor Summary
AbstractSetAction(Expression value, Element element, AbstractAction parent)
          Create a new instance of AbstractSetAction.
AbstractSetAction(QExpression name, Expression value, Element element, AbstractAction parent)
          Create a new instance of AbstractSetAction.
 
Method Summary
 void addProperty(QName name, Object value, DataSet dataSet)
          Add the property to the data set, with the appropriate scope.
 QName getComputedName(DataSet dataSet)
          Return the QName of the property.
abstract  Object getComputedValue(DataSet dataSet)
          Return the computed value of the property.
 QExpression getName()
          Return the name of the property.
 Expression getValue()
          Return the value of the property.
 void runAction(DataSet dataSet)
          Execute the action by setting the named property with its value to the data set.
 int scope()
          Return The scope of the property.
static int unmarshalScope(Element element)
          XML unmarshaller for scope attribute.
 
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, unmarshal
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NO_VALUE

public static final Object NO_VALUE
Indicates that this is not a value.

Constructor Detail

AbstractSetAction

public AbstractSetAction(QExpression name,
                         Expression value,
                         Element element,
                         AbstractAction parent)
Create a new instance of AbstractSetAction.

Parameters:
name - The qualified name of the property to add to the data set, as a QExpression.
value - The value of the property, as an Expression.
element - The element from which the action has been unmarshalled. Used for namespace prefix resolution when performing XPath expressions.
parent - The action depending from.

AbstractSetAction

public AbstractSetAction(Expression value,
                         Element element,
                         AbstractAction parent)
                  throws XMLException
Create a new instance of AbstractSetAction.

Parameters:
value - The value of the property, as an Expression.
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 - When the "name" attribute is not a valid value template.
Method Detail

unmarshalScope

public static int unmarshalScope(Element element)
XML unmarshaller for scope attribute.

Parameters:
element - The XML element to unmarshall.
Returns:
true if the scope of the property is local (default), false if it is global .

scope

public int scope()
Return The scope of the property.

Returns:
The scope of the property.

getName

public QExpression getName()
Return the name of the property.

Returns:
The name of the property.

getValue

public Expression getValue()
Return the value of the property.

Returns:
The value of the property.

getComputedName

public QName getComputedName(DataSet dataSet)
                      throws XPathException
Return the QName of the property.

Parameters:
dataSet - The set of datas used when the name is computed.
Returns:
The QName of the property, maybe null.
Throws:
XPathException - If the XPath expression is invalid.

getComputedValue

public abstract Object getComputedValue(DataSet dataSet)
                                 throws ExecutionException,
                                        XPathException
Return the computed value of the property.

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

addProperty

public void addProperty(QName name,
                        Object value,
                        DataSet dataSet)
                 throws ExecutionException
Add the property to the data set, with the appropriate scope.

Parameters:
name - The name of the property.
value - The value of the property.
dataSet - The set of datas for which the property is added.
Throws:
ExecutionException

runAction

public void runAction(DataSet dataSet)
               throws ExecutionException,
                      XPathException
Execute the action by setting the named property with its value to the data set. The name and the value of the property are computed before adding the property to the data set.

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