Package sleep.runtime

Class ScriptVariables

  • All Implemented Interfaces:
    java.io.Serializable

    public class ScriptVariables
    extends java.lang.Object
    implements java.io.Serializable
    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):

  • Local - discarded after use
  • Closure - specific to the current executing closure
  • Global - global to all scripts sharing this script variables instance
See Also:
Scalar, ScriptInstance, Variable, Serialized Form