Interface HierarchicalAware
-
- All Known Implementing Classes:
BSHInterpreter
public interface HierarchicalAware
An extra interface implemented by an interpreter (Interpreter
) if it supports the hierarchical scopes.By supporting the hierarchical scopes we mean the interpreter associates one interpreter-dependent scope with each ZK's
IdSpace
. And, variables, classes and methods defined in zscript are then stored in an individual scope depending on the scope when callingInterpreter.interpret(java.lang.String, org.zkoss.zk.ui.ext.Scope)
.On the other hand, if the interpreter doesn't support the hierarchical scopes, it maintains only one global scope and all variables, classes and functions are defined in the global scope.
- Author:
- tomyeh
- See Also:
Interpreter
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description boolean
containsVariable(Scope scope, java.lang.String name)
Tests whether a variable defined in this interpreter.Function
getFunction(Scope scope, java.lang.String name, java.lang.Class[] argTypes)
Returns the method of the specified name defined in this interpreter's scope identified by the specified scope, or null if not defined.java.lang.Object
getVariable(Scope scope, java.lang.String name)
Returns the value of a variable defined in this interpreter's scope identified by the specified scope.void
setVariable(Scope scope, java.lang.String name, java.lang.Object value)
Sets the value of a variable to this interpreter's scope identified by the specified scope.void
unsetVariable(Scope scope, java.lang.String name)
Removes the value of a variable defined in the interpreter's scope identified by the specified scope.
-
-
-
Method Detail
-
containsVariable
boolean containsVariable(Scope scope, java.lang.String name)
Tests whether a variable defined in this interpreter. Note: it doesn't search the scope (Scope
).It is similar to
Interpreter.containsVariable(java.lang.String)
, except it uses the specified scope as a reference to identify the correct scope for searching the variable.- Parameters:
scope
- the scope used as a reference to identify the correct scope for searching the variable. Note: this method doesn't look for any variable stored in scope.- Since:
- 5.0.0
-
getVariable
java.lang.Object getVariable(Scope scope, java.lang.String name)
Returns the value of a variable defined in this interpreter's scope identified by the specified scope. Note: it doesn't search the specified scope (Scope
).It is similar to
Interpreter.getVariable(java.lang.String)
, except it uses the specified scope as a reference to identify the correct scope for searching the variable.- Parameters:
scope
- the scope used as a reference to identify the correct scope for searching the variable. Note: this method doesn't look for any variable stored in scope.- Since:
- 5.0.0
-
setVariable
void setVariable(Scope scope, java.lang.String name, java.lang.Object value)
Sets the value of a variable to this interpreter's scope identified by the specified scope.It is similar to
Interpreter.setVariable(java.lang.String, java.lang.Object)
, except it uses the specified scope as a reference to identify the correct scope for storing the variable.- Parameters:
scope
- the scope used as a reference to identify the correct scope for searching the variable. Note: this method doesn't look for any variable stored in scope.- Since:
- 5.0.0
-
unsetVariable
void unsetVariable(Scope scope, java.lang.String name)
Removes the value of a variable defined in the interpreter's scope identified by the specified scope.It is similar to
Interpreter.unsetVariable(java.lang.String)
, except it uses the specified scope as a reference to identify the correct scope for removing the variable.- Parameters:
scope
- the scope used as a reference to identify the correct scope for searching the variable. Note: this method doesn't look for any variable stored in scope.- Since:
- 5.0.0
-
getFunction
Function getFunction(Scope scope, java.lang.String name, java.lang.Class[] argTypes)
Returns the method of the specified name defined in this interpreter's scope identified by the specified scope, or null if not defined.It is similar to
Interpreter.getFunction(java.lang.String, java.lang.Class[])
, except it uses the specified scope as a reference to identify the correct scope for searching the variable.- Parameters:
scope
- the scope used as a reference to identify the correct scope for searching the method. Note: this method doesn't look for any variable stored in scope.argTypes
- the list of argument (a.k.a., parameter) types. If null, Class[0] is assumed.- Since:
- 5.0.0
-
-