com.waveset.object
Class VariableScope

java.lang.Object
  extended bycom.waveset.util.AbstractXmlObject
      extended bycom.waveset.object.VariableScope
All Implemented Interfaces:
javax.naming.Referenceable, VariableResolver, XmlObject
Direct Known Subclasses:
WFCase, WFCase.Result, WFCase.Step

public abstract class VariableScope
extends AbstractXmlObject
implements VariableResolver

An class inherited by classes in a workflow Case that maintain values for variables. This is used with a custom ExState object to allow resolution of external variables referenced by ExNode expressions, through a hierarchy of scopes.

Only used by workflow, might have other uses.

This extends AbstractXmlObject since you usually want that too.


Field Summary
static java.lang.String code_id
           
 
Fields inherited from class com.waveset.util.AbstractXmlObject
_trace
 
Constructor Summary
VariableScope()
           
 
Method Summary
 void assimilateLocalVariables(java.util.Map src)
          Assimilate a collection of variables.
 void clearLocalVariables()
          Remove all local variables.
 java.lang.String expandVariables(java.lang.String src, VariableResolver resolver)
          Expand any variable references in a string.
 java.lang.Object getLocalVariable(java.lang.String name)
          Get a variable from the local scope.
 GenericObject getLocalVariables()
          Get all the variables stored in the scope.
abstract  VariableScope getParentScope()
          Return the parent scope.
 java.lang.Object getVariable(java.lang.String path)
          Resolve a variable starting from this scope, forwarding to the parent scope if not defined here.
 GenericObject getVariables(java.util.List paths)
          Build a single object containing a flat set of values.
 void getVariables(java.util.Map map)
          Add all variables within this scope into the map, then add our parent's variables.
abstract  boolean isVariableDefined(java.lang.String name)
          Test to see if the variable is defined in this scope.
 void pruneGenericObjects()
          Method to make workflow TaskInstances smaller.
 void removeLocalVariable(java.lang.String name)
          Remove a variable in the local scope.
 java.lang.Object resolveVariable(java.lang.String name)
          The method defined by the VariableResolver interface.
 void setLocalVariable(java.lang.String name, java.lang.Object value)
          Set a variable in the local scope.
 void setLocalVariables(java.util.Map src)
          Set all of the local variables at once.
 void setVariable(java.lang.String path, java.lang.Object value)
          Assign the value of a variable.
 
Methods inherited from class com.waveset.util.AbstractXmlObject
addXmlHeader, cloneObject, dump, dumpFile, getElementName, getReference, println, setTrace, toIdentityString, toVerboseString, toVerboseString, toXml, toXml, toXml, toXml
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

code_id

public static final java.lang.String code_id
See Also:
Constant Field Values
Constructor Detail

VariableScope

public VariableScope()
Method Detail

getParentScope

public abstract VariableScope getParentScope()
Return the parent scope.


isVariableDefined

public abstract boolean isVariableDefined(java.lang.String name)
                                   throws WavesetException
Test to see if the variable is defined in this scope.

Throws:
WavesetException

expandVariables

public java.lang.String expandVariables(java.lang.String src,
                                        VariableResolver resolver)
                                 throws WavesetException
Expand any variable references in a string. Currently necessary because the mechanics of handling are done outside.

VariableExpander takes a VariableResolver interface, which we implement.

Throws:
WavesetException

getLocalVariables

public GenericObject getLocalVariables()
Get all the variables stored in the scope. Normally this is used only for iteration, you need to check with the subclass to see if its ok to modify these directly.


getLocalVariable

public java.lang.Object getLocalVariable(java.lang.String name)
Get a variable from the local scope.


setLocalVariable

public void setLocalVariable(java.lang.String name,
                             java.lang.Object value)
Set a variable in the local scope.


removeLocalVariable

public void removeLocalVariable(java.lang.String name)
Remove a variable in the local scope. This is semantically the same as setting the variable to null since we don't expose a containsKey method like Maps. Workflow uses this to prevent cluttering up the TaskInstance XML with null values


clearLocalVariables

public void clearLocalVariables()
Remove all local variables. Used by workflow to cleanup state for steps that are no longer active.


setLocalVariables

public void setLocalVariables(java.util.Map src)
                       throws WavesetException
Set all of the local variables at once.

Throws:
WavesetException

assimilateLocalVariables

public void assimilateLocalVariables(java.util.Map src)
                              throws WavesetException
Assimilate a collection of variables.

Throws:
WavesetException

getVariables

public void getVariables(java.util.Map map)
Add all variables within this scope into the map, then add our parent's variables. The effect is to create a single flat map of all variables visible from a particular scope.


getVariables

public GenericObject getVariables(java.util.List paths)
                           throws WavesetException
Build a single object containing a flat set of values.

Throws:
WavesetException

pruneGenericObjects

public void pruneGenericObjects()
Method to make workflow TaskInstances smaller. Iterate over the variables defined in this scope and remove any GenericObjects we find. These are often large, and can be duplicated several times in the process if they are passed among actions and subprocesses.


getVariable

public java.lang.Object getVariable(java.lang.String path)
                             throws WavesetException
Resolve a variable starting from this scope, forwarding to the parent scope if not defined here. // Always check for a local binding first, even if the scope // returns false for isVariableDefined. This allows us to deposit // values for undeclared variables in a scope and see them. // It is used in workflow to hold the WF_ACTION_RESULT // which is a builtin variable that isn't normally declared. // // I don't especially like this since setVaraible won't behave // the same way, but the alternative is to force all the builtin // workflow variables to be explicitly declared. // This behavior is also consistent with getVariables() which will make // any non-null value in the map appear even if it is undeclared.

Throws:
WavesetException

setVariable

public void setVariable(java.lang.String path,
                        java.lang.Object value)
                 throws WavesetException
Assign the value of a variable. If the variable is not defined in this scope, it is forward to the parent.

Throws:
WavesetException

resolveVariable

public java.lang.Object resolveVariable(java.lang.String name)
                                 throws WavesetException
The method defined by the VariableResolver interface. We implement it so that a VariableScope may be passed into VariableExpander.

Specified by:
resolveVariable in interface VariableResolver
Throws:
WavesetException