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, however it is not
used directly by the core as other than type NameSpace, so no dependency is
introduced.

Constructor Detail

ExternalNameSpace

ExternalNameSpace

Method Detail

getMap

public java.util.Map getMap()

Get the map view of this namespace.

setMap

public void setMap(java.util.Map 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.

setTypedVariable

Declare a variable in the local scope and set its initial value.
Value may be null to indicate that we would like the default value
for the variable type. (e.g. 0 for integer types, null for object
types). An existing typed variable may only be set to the same type.
If an untyped variable of the same name exists it will be overridden
with the new typed var.
The set will perform a Types.getAssignableForm() on the value if
necessary.

Note: this method is primarily intended for use internally. If you use
this method outside of the bsh package and wish to set variables with
primitive values you will have to wrap them using bsh.Primitive.

putExternalMap

Place an unwrapped value in the external map.
BeanShell primitive types are represented by their object wrappers, so
it is not possible to differentiate between wrapper types and primitive
types via the external Map.