Interface Variable

  • All Superinterfaces:
    java.io.Serializable
    All Known Implementing Classes:
    DefaultVariable

    public interface Variable
    extends java.io.Serializable

    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 Detail

      • scalarExists

        boolean scalarExists​(java.lang.String key)
        true if a scalar named key exists in this variable environment
      • getScalar

        Scalar getScalar​(java.lang.String key)
        returns the specified scalar, if scalarExists says it is in the environment, this method has to return a scalar
      • putScalar

        Scalar putScalar​(java.lang.String key,
                         Scalar value)
        put a scalar into this variable environment
      • removeScalar

        void removeScalar​(java.lang.String key)
        remove a scalar from this variable environment
      • createLocalVariableContainer

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

        Variable createInternalVariableContainer()
        returns which variable environment is used to store non-global / non-local variables. this is also used to create the global scope for a forked script environment.