public class ExternalNameSpace extends NameSpace
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.
NameSource.ListenerimportedClasses, JAVACODE| Constructor and Description |
|---|
ExternalNameSpace() |
ExternalNameSpace(NameSpace parent,
java.lang.String name,
java.util.Map externalMap) |
| Modifier and Type | Method and 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(java.util.Vector vec)
Helper for implementing NameSource
|
Variable[] |
getDeclaredVariables() |
java.util.Map |
getMap()
Get the map view of this namespace.
|
BshMethod |
getMethod(java.lang.String name,
java.lang.Class[] sig,
boolean declaredOnly)
Get the bsh method matching the specified signature declared in
this name space or a parent.
|
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.
|
protected void |
putExternalMap(java.lang.String name,
java.lang.Object value)
Place an unwrapped value in the external map.
|
void |
setMap(java.util.Map map)
Set the external Map which to which this namespace synchronizes.
|
void |
setMethod(java.lang.String name,
BshMethod method)
Note: this is primarily for internal use.
|
void |
setTypedVariable(java.lang.String name,
java.lang.Class type,
java.lang.Object value,
Modifiers modifiers)
Declare a variable in the local scope and set its initial value.
|
void |
unsetVariable(java.lang.String name)
Remove the variable from the namespace.
|
addCommandPath, addNameSourceListener, classLoaderChanged, doSuperImport, get, getAllNames, getClass, getClassManager, getCommand, 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, removeCommandPath, setName, setParent, setTypedVariable, setVariable, setVariable, toString, unwrapVariablepublic ExternalNameSpace()
public ExternalNameSpace(NameSpace parent, java.lang.String name, java.util.Map externalMap)
public java.util.Map getMap()
public void setMap(java.util.Map map)
public void unsetVariable(java.lang.String name)
NameSpaceunsetVariable in class NameSpacepublic java.lang.String[] getVariableNames()
NameSpacegetVariableNames in class NameSpaceprotected Variable getVariableImpl(java.lang.String name, boolean recurse) throws UtilEvalError
NameSpaceIf this namespace is static, return only static variables.
getVariableImpl in class NameSpaceUtilEvalErrorpublic Variable[] getDeclaredVariables()
getDeclaredVariables in class NameSpacepublic void setTypedVariable(java.lang.String name,
java.lang.Class type,
java.lang.Object value,
Modifiers modifiers)
throws UtilEvalError
NameSpaceNote: 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.
setTypedVariable in class NameSpacevalue - If value is null, you'll get the default value for the typemodifiers - may be nullUtilEvalErrorPrimitivepublic void setMethod(java.lang.String name,
BshMethod method)
throws UtilEvalError
NameSpacesetMethod in class NameSpaceUtilEvalErrorInterpreter.source( String ),
Interpreter.eval( String )public BshMethod getMethod(java.lang.String name, java.lang.Class[] sig, boolean declaredOnly) throws UtilEvalError
NameSpaceNote: this method is primarily intended for use internally. If you use this method outside of the bsh package you will have to be familiar with BeanShell's use of the Primitive wrapper class.
getMethod in class NameSpacedeclaredOnly - if true then only methods declared directly in this
namespace will be found and no inherited or imported methods will
be visible.UtilEvalErrorPrimitiveprotected void getAllNamesAux(java.util.Vector vec)
NameSpacegetAllNamesAux in class NameSpacepublic void clear()
clear in class NameSpaceNameSpace.loadDefaultImports()protected void putExternalMap(java.lang.String name,
java.lang.Object value)