Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

bsh
Class ForBodyNameSpace  view ForBodyNameSpace download ForBodyNameSpace.java

java.lang.Object
  extended bybsh.NameSpace
      extended bybsh.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.


Nested Class Summary
 
Nested classes inherited from class bsh.NameSpace
NameSpace.CommandPathEntry, NameSpace.Variable
 
Nested classes inherited from class bsh.NameSource
NameSource.Listener
 
Field Summary
(package private)  NameSpace forInitNameSpace
           
 
Fields inherited from class bsh.NameSpace
callerInfoNode, isMethod, JAVACODE, nameSourceListeners, nsName
 
Constructor Summary
ForBodyNameSpace(NameSpace parent, NameSpace forInitNameSpace)
           
 
Method Summary
(package private)  boolean forInitSpaceHasVariable(java.lang.String name)
           
 java.lang.Object getVariable(java.lang.String name)
          get()s first check the forInit space.
 void setTypedVariable(java.lang.String name, java.lang.Class type, java.lang.Object value, boolean isFinal)
          If the variables exists in the forInit space assign it there, otherwise in the parent space.
 void setVariable(java.lang.String name, java.lang.Object o)
          If the variables exists in the forInit space assign it there, otherwise in the parent space.
 
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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

forInitNameSpace

NameSpace forInitNameSpace
Constructor Detail

ForBodyNameSpace

public ForBodyNameSpace(NameSpace parent,
                        NameSpace forInitNameSpace)
Method Detail

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