org.zkoss.zk.scripting
Interface HierachicalAware

All Known Implementing Classes:
BSHInterpreter

public interface HierachicalAware

An extra interface implemented by an interpreter (Interpreter) if it supports the hierachical scopes.

By supporting the hierachical scopes we mean the interpreter associates one interpreter-dependent scope with each ZK's Namespace. And, variables, classes and methods defined in zscript are then stored in an individual scope depending on the namespace when calling Interpreter.interpret(java.lang.String, org.zkoss.zk.scripting.Namespace).

On the other hand, if the interpreter doesn't support the hierachical 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
 boolean containsVariable(Namespace ns, java.lang.String name)
          Tests whether a variable defined in this interpreter.
 Function getFunction(Namespace ns, 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 namespace, or null if not defined.
 java.lang.Object getVariable(Namespace ns, java.lang.String name)
          Returns the value of a variable defined in this interpreter's scope identified by the specified namespace.
 void setVariable(Namespace ns, java.lang.String name, java.lang.Object value)
          Sets the value of a variable to this interpreter's scope identified by the specified namespace.
 void unsetVariable(Namespace ns, java.lang.String name)
          Removes the value of a variable defined in the interpreter's scope identified by the specified namespace.
 

Method Detail

containsVariable

boolean containsVariable(Namespace ns,
                         java.lang.String name)
Tests whether a variable defined in this interpreter. Note: it doesn't search the namespace (Namespace).

It is similar to Interpreter.containsVariable(java.lang.String), except it uses the specified namespace as a reference to identify the correct scope for searching the variable.

Parameters:
ns - the namespace used as a reference to identify the correct scope for searching the variable. Note: this method doesn't look for any variable stored in ns.
Since:
2.4.0

getVariable

java.lang.Object getVariable(Namespace ns,
                             java.lang.String name)
Returns the value of a variable defined in this interpreter's scope identified by the specified namespace. Note: it doesn't search the specified namespace (Namespace).

It is similar to Interpreter.getVariable(java.lang.String), except it uses the specified namespace as a reference to identify the correct scope for searching the variable.

Parameters:
ns - the namespace used as a reference to identify the correct scope for searching the variable. Note: this method doesn't look for any variable stored in ns.

setVariable

void setVariable(Namespace ns,
                 java.lang.String name,
                 java.lang.Object value)
Sets the value of a variable to this interpreter's scope identified by the specified namespace.

It is similar to Interpreter.setVariable(java.lang.String, java.lang.Object), except it uses the specified namespace as a reference to identify the correct scope for storing the variable.

Parameters:
ns - the namespace used as a reference to identify the correct scope for searching the variable. Note: this method doesn't look for any variable stored in ns.
Since:
2.4.0

unsetVariable

void unsetVariable(Namespace ns,
                   java.lang.String name)
Removes the value of a variable defined in the interpreter's scope identified by the specified namespace.

It is similar to Interpreter.unsetVariable(java.lang.String), except it uses the specified namespace as a reference to identify the correct scope for removing the variable.

Parameters:
ns - the namespace used as a reference to identify the correct scope for searching the variable. Note: this method doesn't look for any variable stored in ns.
Since:
2.4.0

getFunction

Function getFunction(Namespace ns,
                     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 namespace, or null if not defined.

It is similar to Interpreter.getFunction(java.lang.String, java.lang.Class[]), except it uses the specified namespace as a reference to identify the correct scope for searching the variable.

Parameters:
ns - the namespace used as a reference to identify the correct scope for searching the method. Note: this method doesn't look for any variable stored in ns.
argTypes - the list of argument (aka., parameter) types. If null, Class[0] is assumed.
Since:
3.0.0


Copyright © 2005-2009 Potix Corporation. All Rights Reserved.