Top Description Fields Constructors Methods
bsh

public Class ExternalNameSpace

extends NameSpace
Class Inheritance
Imports
java.util.*

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.

Field Summary

Modifier and TypeField and Description
private Map<K, V>
Inherited from bsh.NameSpace:
callerInfoNodeclassInstanceclassStaticimportedClassesisClassisMethodJAVACODEnameSourceListeners

Constructor Summary

AccessConstructor and Description
public
public
ExternalNameSpace(NameSpace parent, String name, Map<K, V> externalMap)

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Overrides bsh.NameSpace.clear.

Clear all variables, methods, and imports from this namespace and clear all values from the external map (via Map clear()).
public Variable
public Map<K, V>
getMap()

Get the map view of this namespace.

protected Variable
getVariableImpl(String name, boolean recurse)

Overrides bsh.NameSpace.getVariableImpl.

Locate a variable and return the Variable object with optional recursion through parent name spaces.
public String[]
getVariableNames()

Overrides bsh.NameSpace.getVariableNames.

Get the names of variables defined in this namespace.
public void
setMap(Map<K, V> map)

Set the external Map which to which this namespace synchronizes.

public void
unsetVariable(String name)

Overrides bsh.NameSpace.unsetVariable.

Remove the variable from the namespace.
Inherited from bsh.NameSpace:
addNameSourceListenercacheClassclassLoaderChangedcreateVariablecreateVariabledoSuperImportgetgetAllNamesgetAllNamesAuxgetClassgetClassInstancegetClassManagergetCommandgetDeclaredVariablesgetGlobalgetImportedMethodgetImportedVargetInvocationLinegetInvocationTextgetMethodgetMethodgetMethodNamesgetMethodsgetNamegetNameResolvergetNodegetPackagegetParentgetSupergetThisgetVariablegetVariableidentifierToClassimportClassimportCommandsimportObjectimportPackageimportStaticinvokeMethodinvokeMethodloadDefaultImportsnameSpaceChangedprunesetClassInstancesetClassManagersetClassStaticsetLocalVariablesetMethodsetNamesetNodesetPackagesetParentsetTypedVariablesetTypedVariablesetVariablesetVariabletoStringunwrapVariable

Field Detail

externalMapback to summary
private Map<K, V> externalMap

Constructor Detail

ExternalNameSpaceback to summary
public ExternalNameSpace()
ExternalNameSpaceback to summary
public ExternalNameSpace(NameSpace parent, String name, Map<K, V> externalMap)

Method Detail

clearback to summary
public void clear()

Overrides bsh.NameSpace.clear.

Clear all variables, methods, and imports from this namespace and clear all values from the external map (via Map clear()).

createVariableback to summary
public Variable createVariable(String name, Class<T> type, Object value, Modifiers mods)

Overrides bsh.NameSpace.createVariable.

getMapback to summary
public Map<K, V> getMap()

Get the map view of this namespace.

getVariableImplback to summary
protected Variable getVariableImpl(String name, boolean recurse) throws UtilEvalError

Overrides bsh.NameSpace.getVariableImpl.

Doc from bsh.NameSpace.getVariableImpl.

Locate a variable and return the Variable object with optional recursion through parent name spaces.

If this namespace is static, return only static variables.

Returns:Variable

the Variable value or null if it is not defined

getVariableNamesback to summary
public String[] getVariableNames()

Overrides bsh.NameSpace.getVariableNames.

Doc from bsh.NameSpace.getVariableNames.

Get the names of variables defined in this namespace. (This does not show variables in parent namespaces).

setMapback to summary
public void setMap(Map<K, V> map)

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.

unsetVariableback to summary
public void unsetVariable(String name)

Overrides bsh.NameSpace.unsetVariable.

Doc from bsh.NameSpace.unsetVariable.

Remove the variable from the namespace.