org.inria.ns.reflex.processor.asl
Class AbstractStepAction

java.lang.Object
  extended by org.inria.ns.reflex.processor.core.AbstractAction
      extended by org.inria.ns.reflex.processor.asl.AbstractStepAction
All Implemented Interfaces:
Executable, Identifiable, Presentable, NamespaceContextFactory
Direct Known Subclasses:
AbstractPrimitiveModelAction, AttributeAction, AttributeDefinitionAction, ContainerStepAction, ElementAction, ElementDefinitionAction, InterimStepAction, TextAction, TypeAction

public abstract class AbstractStepAction
extends AbstractAction
implements Identifiable

An abstract representation common to most ASL elements.

Author:
Philippe Poulard

Nested Class Summary
 class AbstractStepAction.ItemsLists
          A set of items lists.
 
Nested classes/interfaces inherited from class org.inria.ns.reflex.processor.core.AbstractAction
AbstractAction.ParameterAdapter, AbstractAction.UselessAction
 
Field Summary
static BubbleMessage STEP_USED_BUBBLE_MESSAGE
          A bubble message that indicates that a step was used.
 
Fields inherited from class org.inria.ns.reflex.processor.core.AbstractAction
actions, parent, processorInstance
 
Constructor Summary
AbstractStepAction(Element element, AbstractAction parent)
          Creates a new instance of AbstractStepAction with a stable repeating mode.
AbstractStepAction(Expression minOccurs, Expression maxOccurs, Element element, AbstractAction parent)
          Creates a new instance of AbstractStepAction with a stable repeating mode.
AbstractStepAction(Expression minOccurs, Expression maxOccurs, int repeating, Element element, AbstractAction parent)
          Creates a new instance of AbstractStepAction.
AbstractStepAction(int repeating, Element element, AbstractAction parent)
          Creates a new instance of AbstractStepAction.
 
Method Summary
 void computeOccurs(DataSet dataSet)
          Compute safely the minimal times number that this step must occur, and the maximal times number that this step may occur.
 QName getId()
          Returns the ID of this object.
 int getMaxOccurs(DataSet dataSet)
          Return the current max-occurs value.
 int getMinOccurs(DataSet dataSet)
          Return the current min-occurs value.
 boolean invokeHandler(boolean hasBeenUsed, DataSet dataSet, SchemaClientHandler client, int minOccurs, int maxOccurs, AbstractStepAction.ItemsLists itemsLists)
          Invoke the client handler with items lists as long as allowed by the boundaries.
 void runAction(DataSet dataSet)
          Run the subactions.
 boolean stableRun(boolean hasBeenUsed, DataSet dataSet, SchemaClientHandler client)
          Run the subactions in a stable mode.
 boolean unstableRun(boolean hasBeenUsed, DataSet dataSet, SchemaClientHandler client)
          Run the subactions in an unstable mode.
 
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

STEP_USED_BUBBLE_MESSAGE

public static final BubbleMessage STEP_USED_BUBBLE_MESSAGE
A bubble message that indicates that a step was used.

Constructor Detail

AbstractStepAction

public AbstractStepAction(Expression minOccurs,
                          Expression maxOccurs,
                          int repeating,
                          Element element,
                          AbstractAction parent)
Creates a new instance of AbstractStepAction.

Parameters:
minOccurs - The minimum number of times this step must be repeated. By default, the step will be repeated once at least.
maxOccurs - The maximum number of times this step may be repeated. By default, the step will be repeated once at most.
repeating - The repeating mode of this step, that can be stable, unstable, or delegate
node - The node from which the action has been unmarshalled. Used for namespace prefix resolution when performing XPath expressions.
parent - The action depending from.

AbstractStepAction

public AbstractStepAction(Expression minOccurs,
                          Expression maxOccurs,
                          Element element,
                          AbstractAction parent)
Creates a new instance of AbstractStepAction with a stable repeating mode.

Parameters:
minOccurs - The min occurs when repeating this step.
maxOccurs - The max occurs when repeating this step.
node - The node from which the action has been unmarshalled. Used for namespace prefix resolution when performing XPath expressions.
parent - The action depending from.

AbstractStepAction

public AbstractStepAction(Element element,
                          AbstractAction parent)
                   throws XPathException
Creates a new instance of AbstractStepAction with a stable repeating mode. Min and max occurs are unmarshalled from the element.

Parameters:
repeating - The repeating mode of this step, that can be stable, unstable, or delegate
node - The node from which the action has been unmarshalled. Used for namespace prefix resolution when performing XPath expressions.
parent - The action depending from.
Throws:
XPathException

AbstractStepAction

public AbstractStepAction(int repeating,
                          Element element,
                          AbstractAction parent)
                   throws XPathException
Creates a new instance of AbstractStepAction. Min and max occurs are unmarshalled from the element with the min-occurs and max-occurs attributes.

Parameters:
repeating - The repeating mode of this step, that can be stable, unstable, or delegate
node - The node from which the action has been unmarshalled. Used for namespace prefix resolution when performing XPath expressions.
parent - The action depending from.
Throws:
XPathException
Method Detail

computeOccurs

public void computeOccurs(DataSet dataSet)
                   throws XPathException
Compute safely the minimal times number that this step must occur, and the maximal times number that this step may occur.

The min-occurs value may refer to the max-occurs one thanks to the $asl:max-occurs property. The max-occurs value may refer to the min-occurs one thanks to the $asl:min-occurs property. The computation prevent infinite loop if min-occurs uses max-occurs that uses min-occurs or if min-occurs uses directly min-occurs, and vice-versa. The min and max values are added to the given dataset. This method calls computeMinOccurs() and computeMaxOccurs().

Parameters:
dataSet - The set of datas used when the action is running.
Throws:
XPathException - When an expression can't be computed.

getMinOccurs

public int getMinOccurs(DataSet dataSet)
                 throws ExecutionException,
                        XPathException
Return the current min-occurs value. The computeOccurs() method must be invoked for this step before, otherwise the value will be those of the upper step if any.

Parameters:
dataSet - The set of datas used when the action is running.
Returns:
The min occurs value.
Throws:
ExecutionException
XPathException
See Also:
MinOccursProperty, MaxOccursProperty, getMaxOccurs(DataSet), computeOccurs(DataSet)

getMaxOccurs

public int getMaxOccurs(DataSet dataSet)
                 throws ExecutionException,
                        XPathException
Return the current max-occurs value. The computeOccurs() method must be invoked for this step before, otherwise the value will be those of the upper step if any.

Parameters:
dataSet - The set of datas used when the action is running.
Returns:
The max occurs value.
Throws:
ExecutionException
XPathException
See Also:
MinOccursProperty, MaxOccursProperty, getMaxOccurs(DataSet), computeOccurs(DataSet)

getId

public QName getId()
Returns the ID of this object.

Specified by:
getId in interface Identifiable
Returns:
The ID of this object.

runAction

public void runAction(DataSet dataSet)
               throws ExecutionException,
                      XPathException
Run the subactions.

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

stableRun

public boolean stableRun(boolean hasBeenUsed,
                         DataSet dataSet,
                         SchemaClientHandler client)
                  throws ExecutionException,
                         XPathException
Run the subactions in a stable mode. At each loop, the same lists are provided to the schema client handler. Boundaries occurrence are not recomputed.

Parameters:
hasBeenUsed - Indicates if this step has been used.
dataSet - The set of datas used when the action is running.
client - The schema client handler to call.
Returns:
true if this method really used the step. Returns the previous value of hasBeenUsed otherwise.
Throws:
ExecutionException - If the action can't be performed.
XPathException

invokeHandler

public boolean invokeHandler(boolean hasBeenUsed,
                             DataSet dataSet,
                             SchemaClientHandler client,
                             int minOccurs,
                             int maxOccurs,
                             AbstractStepAction.ItemsLists itemsLists)
                      throws ExecutionException,
                             XPathException
Invoke the client handler with items lists as long as allowed by the boundaries.

Parameters:
hasBeenUsed - Indicates if this step has been used.
dataSet - The set of datas used when the action is running.
client - The schema client handler to call.
minOccurs - The minimum number of times the list must be processed.
maxOccurs - The maximum number of times the list may be processed.
itemsLists - The lists to process.
Returns:
true if this method really used the step. Returns the previous value of hasBeenUsed otherwise.
Throws:
ExecutionException - If the action can't be performed.
XPathException

unstableRun

public boolean unstableRun(boolean hasBeenUsed,
                           DataSet dataSet,
                           SchemaClientHandler client)
                    throws ExecutionException,
                           XPathException
Run the subactions in an unstable mode. At each loop, the lists are refactoried before provided them to the schema client handler. Boundaries occurrence are recomputed.

Parameters:
hasBeenUsed - Indicates if this step has been used.
dataSet - The set of datas used when the action is running.
client - The schema client handler to call.
Returns:
true if this method really used the step. Returns the previous value of hasBeenUsed otherwise.
Throws:
ExecutionException - If the action can't be performed.
XPathException