|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbsh.NameSpace
bsh.ExternalNameSpace
public class ExternalNameSpace
A namespace which maintains an external map of values held in variables in its scope. This mechanism provides a standard collections based interface to the namespace as well as a convenient way to export and view values of the namespace without the ordinary BeanShell wrappers.
Variables are maintained internally in the normal fashion to support meta-information (such as variable type and visibility modifiers), but exported and imported in a synchronized way. Variables are exported each time they are written by BeanShell. Imported variables from the map appear in the BeanShell namespace as untyped variables with no modifiers and shadow any previously defined variables in the scope. Note: this class is inherentely dependent on Java 1.2 (for Map), however it is not used directly by the core as other than type NameSpace, so no dependency is introduced.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface bsh.NameSource |
---|
NameSource.Listener |
Field Summary |
---|
Fields inherited from class bsh.NameSpace |
---|
importedClasses, JAVACODE |
Constructor Summary | |
---|---|
ExternalNameSpace()
|
|
ExternalNameSpace(NameSpace parent,
java.lang.String name,
java.util.Map externalMap)
|
Method Summary | |
---|---|
void |
clear()
Clear all variables, methods, and imports from this namespace and clear all values from the external map (via Map clear()). |
Variable |
createVariable(java.lang.String name,
java.lang.Class type,
java.lang.Object value,
Modifiers mods)
|
java.util.Map |
getMap()
Get the map view of this namespace. |
protected Variable |
getVariableImpl(java.lang.String name,
boolean recurse)
Locate a variable and return the Variable object with optional recursion through parent name spaces. |
java.lang.String[] |
getVariableNames()
Get the names of variables defined in this namespace. |
void |
setMap(java.util.Map map)
Set the external Map which to which this namespace synchronizes. |
void |
unsetVariable(java.lang.String name)
Remove the variable from the namespace. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ExternalNameSpace()
public ExternalNameSpace(NameSpace parent, java.lang.String name, java.util.Map externalMap)
Method Detail |
---|
public java.util.Map getMap()
public void setMap(java.util.Map map)
public void unsetVariable(java.lang.String name)
NameSpace
unsetVariable
in class NameSpace
public java.lang.String[] getVariableNames()
NameSpace
getVariableNames
in class NameSpace
protected Variable getVariableImpl(java.lang.String name, boolean recurse) throws UtilEvalError
NameSpace
getVariableImpl
in class NameSpace
UtilEvalError
public Variable createVariable(java.lang.String name, java.lang.Class type, java.lang.Object value, Modifiers mods)
createVariable
in class NameSpace
public void clear()
clear
in class NameSpace
NameSpace.loadDefaultImports()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |