Package bsh
Class ExternalNameSpace3
- java.lang.Object
-
- bsh.NameSpace
-
- bsh.ExternalNameSpace3
-
- All Implemented Interfaces:
bsh.BshClassManager.Listener
,bsh.NameSource
,Serializable
- Direct Known Subclasses:
ExtensibleObjectNamespace
public class ExternalNameSpace3 extends bsh.NameSpace
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.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ExternalNameSpace3()
ExternalNameSpace3(bsh.NameSpace parent, String name, Map externalMap)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clear all variables, methods, and imports from this namespace and clear all values from the external map (via Map clear()).protected void
getAllNamesAux(Vector vec)
bsh.Variable[]
getDeclaredVariables()
Map
getMap()
Get the map view of this namespace.bsh.BshMethod
getMethod(String name, Class[] sig, boolean declaredOnly)
protected bsh.Variable
getVariableImpl(String name, boolean recurse)
String[]
getVariableNames()
protected void
putExternalMap(String name, Object value)
Place an unwrapped value in the external map.void
setMap(Map map)
Set the external Map which to which this namespace synchronizes.void
setMethod(String name, bsh.BshMethod method)
void
setTypedVariable(String name, Class type, Object value, bsh.Modifiers modifiers)
void
unsetVariable(String name)
-
Methods inherited from class bsh.NameSpace
addNameSourceListener, classLoaderChanged, doSuperImport, get, getAllNames, getClass, getClassManager, getCommand, getGlobal, getImportedMethod, getImportedVar, getInvocationLine, getInvocationText, getMethod, getMethodNames, getMethods, getName, getParent, getSuper, getVariable, getVariable, identifierToClass, importClass, importCommands, importObject, importPackage, importStatic, invokeMethod, invokeMethod, loadDefaultImports, nameSpaceChanged, prune, setName, setParent, setTypedVariable, setVariable, toString, unwrapVariable
-
-
-
-
Method Detail
-
getMap
public Map getMap()
Get the map view of this namespace.
-
setMap
public void setMap(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.
-
unsetVariable
public void unsetVariable(String name)
- Overrides:
unsetVariable
in classbsh.NameSpace
-
getVariableNames
public String[] getVariableNames()
- Overrides:
getVariableNames
in classbsh.NameSpace
-
getVariableImpl
protected bsh.Variable getVariableImpl(String name, boolean recurse) throws bsh.UtilEvalError
- Overrides:
getVariableImpl
in classbsh.NameSpace
- Throws:
bsh.UtilEvalError
-
getDeclaredVariables
public bsh.Variable[] getDeclaredVariables()
- Overrides:
getDeclaredVariables
in classbsh.NameSpace
-
setTypedVariable
public void setTypedVariable(String name, Class type, Object value, bsh.Modifiers modifiers) throws bsh.UtilEvalError
- Overrides:
setTypedVariable
in classbsh.NameSpace
- Throws:
bsh.UtilEvalError
-
setMethod
public void setMethod(String name, bsh.BshMethod method) throws bsh.UtilEvalError
- Overrides:
setMethod
in classbsh.NameSpace
- Throws:
bsh.UtilEvalError
-
getMethod
public bsh.BshMethod getMethod(String name, Class[] sig, boolean declaredOnly) throws bsh.UtilEvalError
- Overrides:
getMethod
in classbsh.NameSpace
- Throws:
bsh.UtilEvalError
-
getAllNamesAux
protected void getAllNamesAux(Vector vec)
- Overrides:
getAllNamesAux
in classbsh.NameSpace
-
clear
public void clear()
Clear all variables, methods, and imports from this namespace and clear all values from the external map (via Map clear()).- Overrides:
clear
in classbsh.NameSpace
-
-