A skeletal class for implementing a interpreter (
Interpreter ) that
support
Namespace .
Derive classes usually override
GenericInterpreter.exec instead of
GenericInterpreter.interpret ;
In addition, don't override
GenericInterpreter.getVariable ,
GenericInterpreter.setVariable and
GenericInterpreter.unsetVariable .
Instead, override
GenericInterpreter.get(String) ,
GenericInterpreter.contains(String) ,
GenericInterpreter.set(String,Object) and
GenericInterpreter.unset(String) instead.
If an interpreter doesn't support hierachical scopes,
it can simply implement a global scope, and then use
GenericInterpreter.getFromNamespace to
retrieve variables from ZK's hierachical namespaces.
If it supports hierachical scopes
(example:
org.zkoss.zk.scripting.bsh.BSHInterpreter ), it
can maintain a one-to-one relationship among interpreter's scopes
and ZK's
Namespace . |