|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectsleep.runtime.ScriptVariables
public class ScriptVariables
Maintains variables and variable scopes for a script instance. If you want to change the way variables are handled do not override this class. This class handles all accessing of variables through an object that implements the Variable interface.
Set/Get a Variable without Parsing
script.getScriptVariables().putScalar("$var", SleepUtils.getScalar("value"));
The ScriptVariables object is the entry point for installing variables into a script's runtime environment. The above example illustrates how to set a variable named $var to a specified Scalar value.
Scalar value = script.getScriptVariables().getScalar("$var");
The code above illustrates how to retrieve a Scalar named $var from a script instance object.
Sleep has 3 levels of scope. They are (in order of precedence):
Scalar
,
ScriptInstance
,
Variable
,
Serialized FormConstructor Summary | |
---|---|
ScriptVariables()
Initializes this ScriptVariables container using a DefaultVariable object for default variable storage |
|
ScriptVariables(Variable aVariableClass)
Initializes this class with your version of variable storage |
Method Summary | |
---|---|
Variable |
getClosureVariables()
returns the current closure variable scope |
Variable |
getClosureVariables(SleepClosure closure)
returns the closure level variables for this specific script environment |
Variable |
getGlobalVariables()
returns the global variable scope |
Variable |
getLocalVariables()
returns the current local variable scope |
Scalar |
getScalar(java.lang.String key)
retrieves a scalar |
Scalar |
getScalar(java.lang.String key,
ScriptInstance i)
Returns the specified scalar, looking at each scope in order. |
Variable |
getScalarLevel(java.lang.String key,
ScriptInstance i)
retrieves the appropriate Variable container that has the specified key. |
void |
popClosureLevel()
discards the current closure variable scope |
void |
popLocalLevel()
discards the current local variable scope, making the previous local scope the current local scope again |
void |
pushClosureLevel(Variable variables)
pushes the specified variables into this closures level, once the closure has executed this should be popped |
void |
pushLocalLevel()
starts a new local variable scope. |
void |
pushLocalLevel(Variable localVariables)
makes the specified variable container active for the local scope. |
void |
putScalar(java.lang.String key,
Scalar value)
puts a scalar into the global scope |
void |
setClosureVariables(SleepClosure closure,
Variable variables)
returns the closure level variables for this specific script environment |
void |
setScalarLevel(java.lang.String key,
Scalar value,
Variable level)
Puts the specified scalar in a specific scope |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ScriptVariables()
public ScriptVariables(Variable aVariableClass)
Method Detail |
---|
public void putScalar(java.lang.String key, Scalar value)
public Scalar getScalar(java.lang.String key)
public Variable getScalarLevel(java.lang.String key, ScriptInstance i)
public Scalar getScalar(java.lang.String key, ScriptInstance i)
public void setScalarLevel(java.lang.String key, Scalar value, Variable level)
level
- the Variable container from the scope we want to store this scalar in.public Variable getLocalVariables()
public Variable getClosureVariables()
public Variable getGlobalVariables()
public Variable getClosureVariables(SleepClosure closure)
public void setClosureVariables(SleepClosure closure, Variable variables)
public void pushClosureLevel(Variable variables)
public void popClosureLevel()
public void pushLocalLevel(Variable localVariables)
public void pushLocalLevel()
public void popLocalLevel()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |