bsh
Class ForBodyNameSpace

java.lang.Object
bsh.NameSpace
bsh.ForBodyNameSpace
- All Implemented Interfaces:
- BshClassManager.Listener, NameSource, java.io.Serializable
- class ForBodyNameSpace
- extends NameSpace
A specialized namespace for the body of a "for" statement.
The for statement body acts like a child namespace but only for
variables declared or initialized in the forInit() section. Elsewhere
variable assignment acts like it is part of the containing block.
This namespace takes as an argument a namespace comprising the forInit()
variables and allows variables within it to shadow those in the parent
namespace. Otherwise all assignments are delegated to the parent
namespace.
There may be more methods from NameSpace that should be overidden here.
| Methods inherited from class bsh.NameSpace |
addCommandPath, addNameSourceListener, checkMethodModifiers, checkVariableModifiers, classLoaderChanged, clear, doSuperImport, get, getAllNames, getAllNamesAux, getAssignableForm, getClass, getClassManager, getCommand, getCommand, getGlobal, getInvocationLine, getInvocationText, getMethod, getMethodNames, getMethods, getName, getNameResolver, getNode, getParent, getSuper, getThis, getVariable, getVariableImpl, getVariableNames, identifierToClass, importClass, importPackage, invokeMethod, invokeMethod, isVisible, isVisible, loadDefaultImports, nameSpaceChanged, prune, removeCommandPath, setClassManager, setLocalVariable, setMethod, setName, setNode, setParent, setTypedVariable, setVariable, setVariable, toString, unsetVariable, unwrapVariable |
forInitNameSpace
NameSpace forInitNameSpace
ForBodyNameSpace
public ForBodyNameSpace(NameSpace parent,
NameSpace forInitNameSpace)
setVariable
public void setVariable(java.lang.String name,
java.lang.Object o)
throws EvalError
- If the variables exists in the forInit space assign it there,
otherwise in the parent space.
- Overrides:
setVariable in class NameSpace
setTypedVariable
public void setTypedVariable(java.lang.String name,
java.lang.Class type,
java.lang.Object value,
boolean isFinal)
throws EvalError
- If the variables exists in the forInit space assign it there,
otherwise in the parent space.
Note: this may not make sense... if it exists we'll throw an
error, right? this can only happen in the forInit eval, right?
- Overrides:
setTypedVariable in class NameSpace
forInitSpaceHasVariable
boolean forInitSpaceHasVariable(java.lang.String name)
getVariable
public java.lang.Object getVariable(java.lang.String name)
- get()s first check the forInit space. If not defined there then
they are delegated to the parent space.
- Overrides:
getVariable in class NameSpace