Class MixedBasicVariableMap

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected java.lang.String converted​(java.lang.String name)
      Converts the name of a variable in a way that if the name 'a' and name 'b' results the same string converted then 'a' and 'b' are treated from some aspects as the same variable name.
      void createVariablesOnTheFly()
      Inform the object that variables have to be created on the fly without previous proper registration.
      void defaultVariableScopeShallBeGlobal()
      Inform the object that when a variable is created on the fly without prior declaration that would have specified if the variable is local or global, then the variable has to be global by default.
      void defaultVariableScopeShallBeLocal()
      Inform the object that when a variable is created on the fly without prior declaration that would have specified if the variable is local or global, then the variable has to be local by default.
      VariableMap getGlobalMap()  
      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 registerGlobalVariable​(java.lang.String variableName)
      Register a variable as a global variable.
      void requireVariableDeclaration()
      Inform the object that variables should not be created on the fly, but first a variable has to be registered and can only be used afterwards.
      void setCaseFreak()
      Tell the object that the variable names has to be cased only one way.
      void setCaseIgnorant()
      Tell the object that the variable handling is case insensitive.
      void setCaseSensitive()
      Tell the object that the variable names are handled in a case sensitive way.
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MixedBasicVariableMap

        public MixedBasicVariableMap()
    • Method Detail

      • variableExists

        public java.lang.Boolean variableExists​(java.lang.String variableName)
                                         throws ScriptBasicException
        Description copied from interface: VariableMap
        Checks that a variable exists in this map.
        Specified by:
        variableExists in interface VariableMap
        Overrides:
        variableExists in class BasicLocalVariableMap
        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
      • requireVariableDeclaration

        public void requireVariableDeclaration()
        Inform the object that variables should not be created on the fly, but first a variable has to be registered and can only be used afterwards.
      • createVariablesOnTheFly

        public void createVariablesOnTheFly()
        Inform the object that variables have to be created on the fly without previous proper registration. This is the usual BASIC way that BASIC programmers got used to, though this is more dangerous.

        Nevertheless this is the default behavior.

      • defaultVariableScopeShallBeLocal

        public void defaultVariableScopeShallBeLocal()
        Inform the object that when a variable is created on the fly without prior declaration that would have specified if the variable is local or global, then the variable has to be local by default.

        This is the safer solution and this is the default, since there is no previous BASIC style in this aspect.

      • defaultVariableScopeShallBeGlobal

        public void defaultVariableScopeShallBeGlobal()
        Inform the object that when a variable is created on the fly without prior declaration that would have specified if the variable is local or global, then the variable has to be global by default.

        This is generally dangerous, however it is up to the programmer embedding the interpreter to his/her application.

      • registerGlobalVariable

        public void registerGlobalVariable​(java.lang.String variableName)
                                    throws ScriptBasicException
        Description copied from interface: LocalVariableMap
        Register a variable as a global variable. This is needed when an implementing class manages the global as well as the local variables.

        Interpreters may handle variables differently. When a variable is not defined using some keyword as 'LOCAL' or 'GLOBAL' then the interpreter may treat the variable default local, may treat default global or may raise error. This is configurable in ScriptBasic.

        This method can be used to declare that a variable is used in the local environment referring to the global variable.

        Specified by:
        registerGlobalVariable in interface LocalVariableMap
        Overrides:
        registerGlobalVariable in class BasicLocalVariableMap
        Parameters:
        variableName - parameter
        Throws:
        ScriptBasicException - in case of exception
      • setVariable

        public void setVariable​(java.lang.String variableName,
                                RightValue rightValue)
                         throws ScriptBasicException
        Description copied from interface: VariableMap
        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.

        Specified by:
        setVariable in interface VariableMap
        Overrides:
        setVariable in class BasicLocalVariableMap
        Parameters:
        variableName - parameter
        rightValue - the new value of the variable
        Throws:
        ScriptBasicException - in case there is an exception
      • setCaseSensitive

        public void setCaseSensitive()
        Tell the object that the variable names are handled in a case sensitive way. It means that the variables 'vaRIable' and 'variABLE' are two different variables and can live in the global or the actual local variable name space along with each other in peace.

        It is not recommended to use this mode, however most modern programming languages do this.

      • setCaseFreak

        public void setCaseFreak()
        Tell the object that the variable names has to be cased only one way. It means that there can not be a variable named "vaRIable' and 'variABLE' at the same time.

        It is the recommended behavior, however BASIC implementations rarely exhibit such variable name handling this is not the default.

      • setCaseIgnorant

        public void setCaseIgnorant()
        Tell the object that the variable handling is case insensitive. It means that the variables 'vaRIable' and 'variABLE' denote the same variable.

        It is not recommended to use this mode, however most BASIC implementation do this. This is the default behavior.

      • getVariableNameSet

        public java.util.Set<java.lang.String> getVariableNameSet()
        Description copied from interface: VariableMap
        Get the set of the variables stored in the variable map so that the caller can iterate through the variables.
        Specified by:
        getVariableNameSet in interface VariableMap
        Returns:
        return value
      • converted

        protected java.lang.String converted​(java.lang.String name)
        Converts the name of a variable in a way that if the name 'a' and name 'b' results the same string converted then 'a' and 'b' are treated from some aspects as the same variable name. The generic approach is simply upper casing.
        Parameters:
        name - parameter
        Returns:
        return value