|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkoala.dynamicjava.interpreter.context.VariableContext
This class encapsulates the behaviour of Java scopes.
Nested Class Summary | |
protected static class |
VariableContext.AbstractVariable
To store the variables |
protected class |
VariableContext.Constant
To store the constants |
protected static class |
VariableContext.Link
To store one scope |
protected static class |
VariableContext.LinkFactory
To manage the creation of scopes and links |
protected static class |
VariableContext.Scope
A table which maps a string with an object |
protected static class |
VariableContext.Variable
To store the variables |
Field Summary | |
protected VariableContext.Scope |
cscope
The current scope for variables |
protected VariableContext.Scope |
scope
The current scope |
protected VariableContext.Link |
scopes
The scopes |
Constructor Summary | |
VariableContext()
Creates a new context initialized with an empty initial scope |
|
VariableContext(java.util.Set entries)
Creates a new context initialized with the given entries defined in the initial scope. |
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 in a set |
boolean |
isDefinedVariable(java.lang.String name)
Tests whether an entry 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)
Sets the value of a constant variable in the current scope |
void |
setVariable(java.lang.String name,
java.lang.Object value)
Sets the value of a variable in the current scope |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected VariableContext.Link scopes
protected VariableContext.Scope scope
protected VariableContext.Scope cscope
Constructor Detail |
public VariableContext()
public VariableContext(java.util.Set entries)
entries
- a set of stringMethod Detail |
public void enterScope()
enterScope
in interface SimpleContext
public void enterScope(java.util.Set entries)
enterScope
in interface SimpleContext
entries
- a set of stringpublic void defineVariables(java.util.Set vars)
defineVariables
in interface SimpleContext
public java.util.Set leaveScope()
leaveScope
in interface SimpleContext
public java.util.Set getCurrentScopeVariables()
getCurrentScopeVariables
in interface SimpleContext
public java.util.Set getCurrentScopeVariableNames()
getCurrentScopeVariableNames
in interface SimpleContext
public boolean isDefinedVariable(java.lang.String name)
isDefinedVariable
in interface SimpleContext
name
- the name of the entry
public boolean isFinal(java.lang.String name)
isFinal
in interface SimpleContext
name
- the name of the entry
java.lang.IllegalStateException
- if the variable is not definedpublic void define(java.lang.String name, java.lang.Object value)
define
in interface SimpleContext
name
- the name of the new entryvalue
- the value of the entry
java.lang.IllegalStateException
- if the variable is already definedpublic void defineConstant(java.lang.String name, java.lang.Object value)
defineConstant
in interface SimpleContext
name
- the name of the new entryvalue
- the value of the entry
java.lang.IllegalStateException
- if the variable is already definedpublic java.lang.Object get(java.lang.String name)
get
in interface SimpleContext
name
- the name of the value to get
java.lang.IllegalStateException
- if the variable is not definedpublic void set(java.lang.String name, java.lang.Object value)
set
in interface SimpleContext
name
- the name of the entryvalue
- the value of the entry
java.lang.IllegalStateException
- if the variable is not defined or is finalpublic void setConstant(java.lang.String name, java.lang.Object value)
setConstant
in interface SimpleContext
name
- the name of the entryvalue
- the value of the entrypublic void setVariable(java.lang.String name, java.lang.Object value)
setVariable
in interface SimpleContext
name
- the name of the entryvalue
- the value of the entrypublic java.util.Map getConstants()
getConstants
in interface SimpleContext
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |