Top Description Fields Constructors Methods
bsh

pack-priv Class BlockNameSpace

extends NameSpace
Class Inheritance

A specialized namespace for Blocks (e.g. the body of a "for" statement). The Block acts like a child namespace but only for typed variables declared within it (block local scope) or untyped variables explicitly set in it via setBlockVariable(). Otherwise variable assignment (including untyped variable usage) acts like it is part of the containing block.

Field Summary

Inherited from bsh.NameSpace:
callerInfoNodeclassInstanceclassStaticimportedClassesisClassisMethodJAVACODEnameSourceListeners

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private NameSpace
getNonBlockParent()

do we need this?

public This
getSuper(Interpreter declaringInterpreter)

Overrides bsh.NameSpace.getSuper.

super is our parent's super
public This
getThis(Interpreter declaringInterpreter)

Overrides bsh.NameSpace.getThis.

Get a 'this' reference is our parent's 'this' for the object closure.
public void
importClass(String name)

Overrides bsh.NameSpace.importClass.

delegate import to our parent
public void
importPackage(String name)

Overrides bsh.NameSpace.importPackage.

delegate import to our parent
public void
setBlockVariable(String name, Object value)

Set an untyped variable in the block namespace.

public void
setMethod(String name, BshMethod method)

Overrides bsh.NameSpace.setMethod.

Note

this is primarily for internal use.

public void
setVariable(String name, Object value, boolean
specifies whether strict java rules are applied.
strictJava
,
boolean
determines whether we will search for the variable in our parent's scope before assigning locally.
recurse
)

Overrides bsh.NameSpace.setVariable.

Override the standard namespace behavior to make assignments happen in our parent (enclosing) namespace, unless the variable has already been assigned here via a typed declaration or through the special setBlockVariable() (used for untyped args in try/catch).
private boolean
weHaveVar(String name)

We have the variable: either it was declared here with a type, giving it block local scope or an untyped var was explicitly set here via setBlockVariable().

Inherited from bsh.NameSpace:
addNameSourceListenercacheClassclassLoaderChangedclearcreateVariablecreateVariablecreateVariabledoSuperImportgetgetAllNamesgetAllNamesAuxgetClassgetClassInstancegetClassManagergetCommandgetDeclaredVariablesgetGlobalgetImportedMethodgetImportedVargetInvocationLinegetInvocationTextgetMethodgetMethodgetMethodNamesgetMethodsgetNamegetNameResolvergetNodegetPackagegetParentgetVariablegetVariablegetVariableImplgetVariableNamesidentifierToClassimportCommandsimportObjectimportStaticinvokeMethodinvokeMethodloadDefaultImportsnameSpaceChangedprunesetClassInstancesetClassManagersetClassStaticsetLocalVariablesetNamesetNodesetPackagesetParentsetTypedVariablesetTypedVariablesetVariabletoStringunsetVariableunwrapVariable

Constructor Detail

BlockNameSpaceback to summary
public BlockNameSpace(NameSpace parent) throws EvalError

Method Detail

getNonBlockParentback to summary
private NameSpace getNonBlockParent()

do we need this?

getSuperback to summary
public This getSuper(Interpreter declaringInterpreter)

Overrides bsh.NameSpace.getSuper.

super is our parent's super

getThisback to summary
public This getThis(Interpreter declaringInterpreter)

Overrides bsh.NameSpace.getThis.

Get a 'this' reference is our parent's 'this' for the object closure. e.g. Normally a 'this' reference to a BlockNameSpace (e.g. if () { } ) resolves to the parent namespace (e.g. the namespace containing the "if" statement).

See Also
getBlockThis(Interpreter)
importClassback to summary
public void importClass(String name)

Overrides bsh.NameSpace.importClass.

delegate import to our parent

importPackageback to summary
public void importPackage(String name)

Overrides bsh.NameSpace.importPackage.

delegate import to our parent

setBlockVariableback to summary
public void setBlockVariable(String name, Object value) throws UtilEvalError

Set an untyped variable in the block namespace. The BlockNameSpace would normally delegate this set to the parent. Typed variables are naturally set locally. This is used in try/catch block argument.

setMethodback to summary
public void setMethod(String name, BshMethod method) throws UtilEvalError

Overrides bsh.NameSpace.setMethod.

Doc from bsh.NameSpace.setMethod.

Note

this is primarily for internal use.

setVariableback to summary
public void setVariable(String name, Object value, boolean strictJava, boolean recurse) throws UtilEvalError

Overrides bsh.NameSpace.setVariable.

Override the standard namespace behavior to make assignments happen in our parent (enclosing) namespace, unless the variable has already been assigned here via a typed declaration or through the special setBlockVariable() (used for untyped args in try/catch).

i.e. only allow typed var declaration to happen in this namespace. Typed vars are handled in the ordinary way local scope. All untyped assignments are delegated to the enclosing context.

Parameters
strictJava:boolean

Doc from bsh.NameSpace.setVariable.

specifies whether strict java rules are applied.

recurse:boolean

Doc from bsh.NameSpace.setVariable.

determines whether we will search for the variable in our parent's scope before assigning locally.

weHaveVarback to summary
private boolean weHaveVar(String name)

We have the variable: either it was declared here with a type, giving it block local scope or an untyped var was explicitly set here via setBlockVariable().