edu.williams.cs.ljil.introspector
Class AbstractStepIntrospector

java.lang.Object
  extended by edu.williams.cs.ljil.introspector.AbstractStepIntrospector

public abstract class AbstractStepIntrospector
extends java.lang.Object

This class allows one to ask questions about a step and the process that it comes from.


Field Summary
protected  laser.littlejil.AbstractStep abstractStep
          The step being introspected.
 
Constructor Summary
protected AbstractStepIntrospector()
          Constructs an introspector for a step.
 
Method Summary
 boolean acquiresAgent()
          Method acquiresAgent.
static AbstractStepIntrospector createStepIntrospector(laser.littlejil.AbstractStep step)
          Factory method that constructs the appropriate class of introspector based on the class of the step passed in
 laser.littlejil.SubstepBinding getBindingToParent()
           
abstract  laser.littlejil.Step getConcreteStep()
           
 java.util.Iterator getExceptions()
           
protected abstract  java.util.Iterator getFirstSubsteps()
           
 laser.littlejil.HandlerBinding getHandlerFor(java.lang.String exceptionName)
          Method getHandlerFor returns the exception handler for a given exception.
 java.util.Iterator getHandlers()
          Method getHandlers.
 java.util.Iterator getInputParameterNames()
           
 java.lang.Class[] getInputParamTypes()
           
 int getMaxCardinality()
           
 int getMinCardinality()
           
 java.lang.String getName()
           
 java.util.Iterator getOutputParameterNames()
           
 java.lang.Class[] getOutputParamTypes()
           
 java.util.Iterator getParameterNames()
           
 java.lang.Class[] getParamTypes()
           
 laser.littlejil.RequisiteBinding getPostrequisiteBinding()
           
 laser.littlejil.AbstractStep getPostrequisiteRoot()
           
 laser.littlejil.RequisiteBinding getPrerequisiteBinding()
           
 laser.littlejil.AbstractStep getPrerequisiteRoot()
           
 java.util.Collection getReachableLeaves()
           
protected  java.util.Collection getReachableLeaves(java.util.Collection visitedSteps)
           
 java.util.Iterator getResourceAcquisitionParameterNames()
           
 laser.littlejil.AbstractStep getSubstep(int n)
           
 java.util.Iterator getSubstepBindings()
           
 int getSubstepIndex(laser.littlejil.AbstractStep step)
           
 java.util.Iterator getSubsteps()
           
 boolean hasDeadline()
          Method hasDeadline.
 boolean hasPostrequisite()
           
 boolean hasPrerequisite()
           
 boolean isChoice()
           
 boolean isLeaf()
           
 boolean isOptional()
           
 boolean isParallel()
           
 boolean isSequential()
           
 boolean isTry()
           
 int numExceptions()
           
 int numHandledExceptions()
          Method numHandledExceptions.
 int numInputParams()
           
 int numOutputParams()
           
 int numParams()
           
 int numResourcesAcquired()
          Method numResourcesAcquired.
 int numSubsteps()
           
protected static java.util.Collection visit(laser.littlejil.AbstractStep step, java.util.Collection visitedSteps)
          Visit this step looking for reachable leaves.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

abstractStep

protected laser.littlejil.AbstractStep abstractStep
The step being introspected. This may be a reference or a real step.

Constructor Detail

AbstractStepIntrospector

protected AbstractStepIntrospector()
Constructs an introspector for a step.

Method Detail

createStepIntrospector

public static AbstractStepIntrospector createStepIntrospector(laser.littlejil.AbstractStep step)
                                                       throws NullStepException
Factory method that constructs the appropriate class of introspector based on the class of the step passed in

Parameters:
theStep - the step that will be introspected
Throws:
NullStepException - thrown if theStep is null or its type is NullStep

getName

public java.lang.String getName()
Returns:
the name of the step being introspected

getConcreteStep

public abstract laser.littlejil.Step getConcreteStep()
Returns:
the step definition (not a reference) that corresponds to this step

isLeaf

public boolean isLeaf()
Returns:
true if the step is a leaf step

isSequential

public boolean isSequential()
Returns:
true if the step is a sequential step

isParallel

public boolean isParallel()
Returns:
true if the step is a parallel step

isChoice

public boolean isChoice()
Returns:
true if the step is a choice step

isTry

public boolean isTry()
Returns:
true if the step is a try step

numParams

public int numParams()
Returns:
the number of parameters to the step

numOutputParams

public int numOutputParams()
Returns:
the number of out and in/out parameters to the step

numInputParams

public int numInputParams()
Returns:
the number of in and in/out parameters to the step

getParamTypes

public java.lang.Class[] getParamTypes()
Returns:
an array of the classes of the parameters to a step

getInputParamTypes

public java.lang.Class[] getInputParamTypes()
Returns:
an array of the classes of the in and in-out parameters to a step

getOutputParamTypes

public java.lang.Class[] getOutputParamTypes()
Returns:
an array of the classes of the out and in-out parameters to a step

getParameterNames

public java.util.Iterator getParameterNames()
Returns:
an iterator containing Strings whose values are the names of the parameters

getInputParameterNames

public java.util.Iterator getInputParameterNames()
Returns:
an iterator containing Strings whose values are the names of the input parameters

getOutputParameterNames

public java.util.Iterator getOutputParameterNames()
Returns:
an iterator containing Strings whose values are the names of the output parameters

getResourceAcquisitionParameterNames

public java.util.Iterator getResourceAcquisitionParameterNames()
Returns:
an iterator containing Strings whose values are the names of the resource acquisition parameters

numExceptions

public int numExceptions()
Returns:
the number of exceptions the step declares that it throws

getExceptions

public java.util.Iterator getExceptions()
Returns:
the exceptions that the step may throw

getReachableLeaves

public java.util.Collection getReachableLeaves()
Returns:
the names of all the leaf steps that are reachable as first steps from here

getReachableLeaves

protected java.util.Collection getReachableLeaves(java.util.Collection visitedSteps)
Parameters:
visitedSteps - the steps that have already been visited during this search for reachable leaves. We need this information to avoid infinite recursion if the process is recursive.
Returns:
the names of all the leaf steps that are reachable as first steps from here

visit

protected static java.util.Collection visit(laser.littlejil.AbstractStep step,
                                            java.util.Collection visitedSteps)
                                     throws NullStepException
Visit this step looking for reachable leaves. If the step has already been visited, it does nothing.

Parameters:
step - the step to visit
visitedSteps - the steps that have already been visited.
Throws:
NullStepException - thrown if step is null

getFirstSubsteps

protected abstract java.util.Iterator getFirstSubsteps()
Returns:
an iterator over all the steps that may be first when this step executes. The type of the elements in the iterator should be AbstractStep.

getSubstep

public laser.littlejil.AbstractStep getSubstep(int n)
                                        throws NoSuchSubstepException
Parameters:
n - the index of the substep to return. The first substep has index 0
Returns:
the nth substep
Throws:
NoSuchSubstepException - thrown if the step is a leaf or if n is not a valid substep index for this step

getSubsteps

public java.util.Iterator getSubsteps()
Returns:
an iterator over the substeps of a step. The type of the elements in the iterator is AbstractStep. Returns an empty iterator for leaf steps and for non-leafs with no children

getSubstepBindings

public java.util.Iterator getSubstepBindings()
Returns:
an enumeration over the substep bindings of a step. The type of the elements in the enumeration is SubstepBinding. Returns an empty enumeration for leaf steps and for non-leafs with no children

numSubsteps

public int numSubsteps()
Returns:
the number of substeps a step has

getSubstepIndex

public int getSubstepIndex(laser.littlejil.AbstractStep step)
                    throws NoSuchSubstepException
Parameters:
substep - the substep to look for
Returns:
the index of the position of a given step with its parent
Throws:
NoSuchSubstepException - thrown if the substep is not found

isOptional

public boolean isOptional()
Returns:
true if the step is optional

getBindingToParent

public laser.littlejil.SubstepBinding getBindingToParent()
Returns:
the binding to the parent. Returns null if we are introspecting the root.

getMinCardinality

public int getMinCardinality()
Returns:
the minimum cardinality for the step this agenda item represents

getMaxCardinality

public int getMaxCardinality()
Returns:
the maximum cardinality for the step this agenda item represents

hasPrerequisite

public boolean hasPrerequisite()
Returns:
true if the step has a prerequisite attached

getPrerequisiteBinding

public laser.littlejil.RequisiteBinding getPrerequisiteBinding()
Returns:
the binding to a prerequisite. Returns null if the step does not have a prerequisite

getPrerequisiteRoot

public laser.littlejil.AbstractStep getPrerequisiteRoot()
Returns:
the root step in a prerequisite. Returns null if the step does not have a prerequisite

getPostrequisiteBinding

public laser.littlejil.RequisiteBinding getPostrequisiteBinding()
Returns:
the binding to a postrequisite. Returns null if the step does not have a postrequisite

hasPostrequisite

public boolean hasPostrequisite()
Returns:
true if the step has a postrequisite attached

getPostrequisiteRoot

public laser.littlejil.AbstractStep getPostrequisiteRoot()
Returns:
the root step in a postrequisite. Returns null if the step does not have a postrequisite

hasDeadline

public boolean hasDeadline()
Method hasDeadline.

Returns:
true if the step has a deadline attached to it

numResourcesAcquired

public int numResourcesAcquired()
Method numResourcesAcquired.

Returns:
the number of resources acquired by this step, including the agent

acquiresAgent

public boolean acquiresAgent()
Method acquiresAgent.

Returns:
true if this step acquires an agent

numHandledExceptions

public int numHandledExceptions()
Method numHandledExceptions.

Returns:
The number of exceptions handled by the step

getHandlers

public java.util.Iterator getHandlers()
Method getHandlers.

Returns:
Iterator

getHandlerFor

public laser.littlejil.HandlerBinding getHandlerFor(java.lang.String exceptionName)
Method getHandlerFor returns the exception handler for a given exception. This assumes that exception handlers are matched using only their name, which is not really accurate. Returns null if there is no handler for this exception.

Parameters:
The - name of the exception whose handler we should find.
Returns:
The HandlerBinding for an exception with a given name.