sleep.interfaces
Interface Variable

All Known Implementing Classes:
DefaultVariable

public interface Variable

A variable bridge is a container for storing scalars. A variable bridge is nothing more than a container. It is possible to use a new variable container to alter how scalars are stored and accessed. All scalars, scalar arrays, and scalar hashes are stored using this system.

A Variable bridge is installed by creating a new script variable manager with the new variable bridge. The variable manager is then installed into a given script.

 ScriptVariables variableManager = new ScriptVariable(new MyVariable());
 script.setScriptVariables(variableManager);
 

Sleep scripts can share variables by using the same instance of ScriptVariables. A Variable bridge can be used to create built in variables. Every time a certain scalar is accessed the bridge might call a method and return the value of the method as the value of the accessed scalar.


Method Summary
 Variable createInternalVariableContainer()
          returns which variable environment is used to store non-global / non-local variables.
 Variable createLocalVariableContainer()
          returns which variable environment is used to temporarily store local variables.
 Scalar getScalar(String key)
          returns the specified scalar, if scalarExists says it is in the environment, this method has to return a scalar
 Scalar putScalar(String key, Scalar value)
          put a scalar into this variable environment
 void removeScalar(String key)
          remove a scalar from this variable environment
 boolean scalarExists(String key)
          true if a scalar named key exists in this variable environment
 

Method Detail

scalarExists

public boolean scalarExists(String key)
true if a scalar named key exists in this variable environment


getScalar

public Scalar getScalar(String key)
returns the specified scalar, if scalarExists says it is in the environment, this method has to return a scalar


putScalar

public Scalar putScalar(String key,
                        Scalar value)
put a scalar into this variable environment


removeScalar

public void removeScalar(String key)
remove a scalar from this variable environment


createLocalVariableContainer

public Variable createLocalVariableContainer()
returns which variable environment is used to temporarily store local variables.


createInternalVariableContainer

public Variable createInternalVariableContainer()
returns which variable environment is used to store non-global / non-local variables.