Package bsh
Class ExternalNameSpace
java.lang.Object
bsh.NameSpace
bsh.ExternalNameSpace
- All Implemented Interfaces:
BshClassManager.Listener,NameSource,Serializable
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.
- See Also:
-
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clear all variables, methods, and imports from this namespace and clear all values from the external map (via Map clear()).createVariable(String name, Class type, Object value, Modifiers mods) getMap()Get the map view of this namespace.protected VariablegetVariableImpl(String name, boolean recurse) Locate a variable and return the Variable object with optional recursion through parent name spaces.String[]Get the names of variables defined in this namespace.voidSet the external Map which to which this namespace synchronizes.voidunsetVariable(String name) Remove the variable from the namespace.Methods inherited from class bsh.NameSpace
addNameSourceListener, classLoaderChanged, createVariable, createVariable, doSuperImport, get, getAllNames, getAllNamesAux, getClass, getClassManager, getCommand, getDeclaredVariables, getGlobal, getImportedMethod, getImportedVar, getInvocationLine, getInvocationText, getMethod, getMethod, getMethodNames, getMethods, getName, getParent, getSuper, getThis, getVariable, getVariable, getVariableOrProperty, identifierToClass, importClass, importCommands, importObject, importPackage, importStatic, invokeMethod, invokeMethod, loadDefaultImports, nameSpaceChanged, prune, setMethod, setName, setParent, setTypedVariable, setTypedVariable, setVariable, setVariableOrProperty, toString, unwrapVariable
-
Constructor Details
-
ExternalNameSpace
public ExternalNameSpace() -
ExternalNameSpace
-
-
Method Details
-
getMap
Get the map view of this namespace. -
setMap
Set the external Map which to which this namespace synchronizes. The previous external map is detached from this namespace. Previous map values are retained in the external map, but are removed from the BeanShell namespace. -
unsetVariable
Description copied from class:NameSpaceRemove the variable from the namespace.- Overrides:
unsetVariablein classNameSpace
-
getVariableNames
Description copied from class:NameSpaceGet the names of variables defined in this namespace. (This does not show variables in parent namespaces).- Overrides:
getVariableNamesin classNameSpace
-
getVariableImpl
Description copied from class:NameSpaceLocate a variable and return the Variable object with optional recursion through parent name spaces. If this namespace is static, return only static variables.- Overrides:
getVariableImplin classNameSpace- Returns:
- the Variable value or null if it is not defined
- Throws:
UtilEvalError
-
createVariable
- Overrides:
createVariablein classNameSpace
-
clear
public void clear()Clear all variables, methods, and imports from this namespace and clear all values from the external map (via Map clear()).
-