koala.dynamicjava.interpreter.context
Interface SimpleContext

All Known Subinterfaces:
Context
All Known Implementing Classes:
VariableContext

public interface SimpleContext

The classes that implements this interface represent contexts of execution


Method Summary
 void define(java.lang.String name, java.lang.Object value)
          Defines a new variable in the current scope
 void defineConstant(java.lang.String name, java.lang.Object value)
          Defines a new constant variable in the current scope
 void defineVariables(java.util.Set vars)
          Defines the given variables
 void enterScope()
          Enters a scope
 void enterScope(java.util.Set entries)
          Enters a scope and defines the given entries to null.
 java.lang.Object get(java.lang.String name)
          Returns the value of a variable with the given name
 java.util.Map getConstants()
          Creates a map that contains the constants in this context
 java.util.Set getCurrentScopeVariableNames()
          Returns the current scope variables (strings) in a set
 java.util.Set getCurrentScopeVariables()
          Returns the current scope variables (strings) in a set
 boolean isDefinedVariable(java.lang.String name)
          Tests whether a variable is defined in this context
 boolean isFinal(java.lang.String name)
          Tests whether a variable is final in this context
 java.util.Set leaveScope()
          Leaves the current scope
 void set(java.lang.String name, java.lang.Object value)
          Sets the value of a defined variable
 void setConstant(java.lang.String name, java.lang.Object value)
          Defines a new constant variable in the current scope
 void setVariable(java.lang.String name, java.lang.Object value)
          Defines a new variable in the current scope
 

Method Detail

enterScope

public void enterScope()
Enters a scope

enterScope

public void enterScope(java.util.Set entries)
Enters a scope and defines the given entries to null.
Parameters:
entries - a set of string

defineVariables

public void defineVariables(java.util.Set vars)
Defines the given variables

getCurrentScopeVariables

public java.util.Set getCurrentScopeVariables()
Returns the current scope variables (strings) in a set

getCurrentScopeVariableNames

public java.util.Set getCurrentScopeVariableNames()
Returns the current scope variables (strings) in a set

leaveScope

public java.util.Set leaveScope()
Leaves the current scope
Returns:
the set of the variables (strings) defined in the current scope

isDefinedVariable

public boolean isDefinedVariable(java.lang.String name)
Tests whether a variable is defined in this context
Parameters:
name - the name of the entry
Returns:
false if the variable is undefined

isFinal

public boolean isFinal(java.lang.String name)
Tests whether a variable is final in this context
Parameters:
name - the name of the entry
Returns:
false if the variable is not final
Throws:
java.lang.IllegalStateException - if the variable is not defined

define

public void define(java.lang.String name,
                   java.lang.Object value)
Defines a new variable in the current scope
Parameters:
name - the name of the new entry
value - the value of the entry
Throws:
java.lang.IllegalStateException - if the variable is already defined

defineConstant

public void defineConstant(java.lang.String name,
                           java.lang.Object value)
Defines a new constant variable in the current scope
Parameters:
name - the name of the new entry
value - the value of the entry
Throws:
java.lang.IllegalStateException - if the variable is already defined

get

public java.lang.Object get(java.lang.String name)
Returns the value of a variable with the given name
Parameters:
name - the name of the value to get
Throws:
java.lang.IllegalStateException - if the variable is not defined

set

public void set(java.lang.String name,
                java.lang.Object value)
Sets the value of a defined variable
Parameters:
name - the name of the new entry
value - the value of the entry
Throws:
java.lang.IllegalStateException - if the variable is not defined

setConstant

public void setConstant(java.lang.String name,
                        java.lang.Object value)
Defines a new constant variable in the current scope
Parameters:
name - the name of the new entry
value - the value of the entry

setVariable

public void setVariable(java.lang.String name,
                        java.lang.Object value)
Defines a new variable in the current scope
Parameters:
name - the name of the new entry
value - the value of the entry

getConstants

public java.util.Map getConstants()
Creates a map that contains the constants in this context


Copyright ? 2001 Stephane Hillion. All Rights Reserved.