Interface VariableMap

  • All Known Subinterfaces:
    HierarchicalVariableMap, LocalVariableMap
    All Known Implementing Classes:
    BasicLocalVariableMap, MixedBasicVariableMap

    public interface VariableMap
    Manage local or global variables. One Map manages the global variables in a BASIC program. There is a map for each local level of function calls storing the local variables. This interface is also implemented by the MixedBasicVariableMap that manages the global and the local variables transparently.

    The methods may throw ScriptBasicException. The interface provides this possibility to implement features like denying case sensitive reuse of variable names. For example jScriptBasic does not allow you to use the variable Apple is ever you already used apple. In other basic implementations the casing is insensitive and the two variable names are the same. Other languages treat Apple and apple as two different variables. jScriptBasic believes that both practices are bad.

    Author:
    Peter Verhas date June 22, 2012
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.util.Set<java.lang.String> getVariableNameSet()
      Get the set of the variables stored in the variable map so that the caller can iterate through the variables.
      RightValue getVariableValue​(java.lang.String variableName)
      Get the value of a variable.
      void setVariable​(java.lang.String variableName, RightValue rightValue)
      Set the value of the variable.
      java.lang.Boolean variableDefined​(java.lang.String variableName)
      Checks that a variable exists and has a defined value in this map.
      java.lang.Boolean variableExists​(java.lang.String variableName)
      Checks that a variable exists in this map.
    • Method Detail

      • getVariableValue

        RightValue getVariableValue​(java.lang.String variableName)
                             throws ScriptBasicException
        Get the value of a variable.
        Parameters:
        variableName - parameter
        Returns:
        the right value the variable has or null if the variable is not defined or does not exists.
        Throws:
        ScriptBasicException - in case there is an exception
      • variableExists

        java.lang.Boolean variableExists​(java.lang.String variableName)
                                  throws ScriptBasicException
        Checks that a variable exists in this map.
        Parameters:
        variableName - parameter
        Returns:
        true if the variable exists, even if the variable has undefined value. false if the variable does not exist in this map.
        Throws:
        ScriptBasicException - in case there is an exception
      • variableDefined

        java.lang.Boolean variableDefined​(java.lang.String variableName)
                                   throws ScriptBasicException
        Checks that a variable exists and has a defined value in this map. Undefined value is represented by null.
        Parameters:
        variableName - parameter
        Returns:
        true if the variable exists and has a defined value.
        Throws:
        ScriptBasicException - in case there is an exception
      • setVariable

        void setVariable​(java.lang.String variableName,
                         RightValue rightValue)
                  throws ScriptBasicException
        Set the value of the variable. If the variable did not exist then the variable is automatically created. If the variable had undefined value then the new value will be the one defined by the argument.

        You can set a variable to undefined passing null to this method as rightValue.

        Parameters:
        variableName - parameter
        rightValue - the new value of the variable
        Throws:
        ScriptBasicException - in case there is an exception
      • getVariableNameSet

        java.util.Set<java.lang.String> getVariableNameSet()
        Get the set of the variables stored in the variable map so that the caller can iterate through the variables.
        Returns:
        return value