java.lang.Objectorg.zkoss.zk.scripting.util.GenericInterpreter
All Implemented Interfaces:
Interpreter
Direct Known Subclasses:
JythonInterpreter, RhinoInterpreter, JRubyInterpreter, GroovyInterpreter, BSHInterpreter
Derive classes usually override #exec instead of #interpret ; In addition, don't override #getVariable , #setVariable and #unsetVariable . Instead, override #get(String) , #contains(String) , #set(String,Object) and #unset(String) instead.
If an interpreter doesn't support hierachical scopes, it can simply implement a global scope, and then use #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 . Thus, it can retrieve the correct scope by giving ZK's Namespace , and vice versa. It also has to implement #get(Namespace,String) , #contains(Namespace,String) #set(Namespace,String,Object) and #unset(Namespace,String) .
Whether to support hierachical namespaces is optional.
tomyeh - | Field Summary | ||
|---|---|---|
| public static final Object | UNDEFINED | Used by #getFromNamespace to denote a variable is not defined.
|
| Constructor: |
|---|
|
| Method from org.zkoss.zk.scripting.util.GenericInterpreter Summary: |
|---|
| afterExec, afterInterpret, beforeExec, beforeInterpret, contains, contains, containsVariable, containsVariable, destroy, exec, get, get, getClass, getCurrent, getFromNamespace, getFromNamespace, getFunction, getFunction, getLanguage, getOwner, getVariable, getVariable, init, interpret, set, set, setVariable, setVariable, unset, unset, unsetVariable, unsetVariable |
| Methods from java.lang.Object: |
|---|
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method from org.zkoss.zk.scripting.util.GenericInterpreter Detail: |
|---|
|
Default: call #afterExec . |
|
Default: call #beforeExec and push the namespace as the active one. |
By default, it tests whether #get(String) returns non-null. |
By default, it tests whether #get(Namespace, String) returns non-null. |
Deriving class shall override #contains(String) , instead of this method. |
Deriving class shall override #contains(Namespace,String) , instead of this method. |
|
|
#beforeExec is called first, before this method is invoked. An empty (and fake) namespace is pushed so #getFromNamespace always returns null. |
This method is implemented only if the interpreter that supports hierachical scopes (org.zkoss.zk.scripting.HierachicalAware ). Default: the same as #get(String) . #beforeExec is called first, before this method is invoked. An empty (and fake) namespace is pushed so #getFromNamespace always returns null. |
|
This method will handle Namespaces#getCurrent automatically. |
It is usually called to search namespaces and variable resolvers, when the real interpreter failed to find a variable in its own scope. Note: We use #UNDEFINED to denote undefined since 2.4.0, while null is a valid value. |
It is usually called to search namespaces and variable resolvers, when the real interpreter failed to find a variable in its own scope. This method is used with the interpreter that supports hierachical scopes (org.zkoss.zk.scripting.HierachicalAware ). |
|
|
|
|
Deriving class shall override #get(String) , instead of this method. |
Deriving class shall override #get(Namespace,String) , instead of this method. This method is part of org.zkoss.zk.scripting.HierachicalAware . It is defined here to simplify the implementation of the deriving classes, if they support the hierachical scopes. |
|
|
#beforeExec is called first, before this method is invoked. |
This method is implemented only if the interpreter that supports hierachical scopes (org.zkoss.zk.scripting.HierachicalAware ). Default: the same as #set(String, Object) . #beforeExec is called first, before this method is invoked. |
Deriving class shall override #set(String,Object) , instead of this method. |
Deriving class shall override #set(Namespace,String,Object) , instead of this method. |
#beforeExec is called first, before this method is invoked. |
This method is implemented only if the interpreter that supports hierachical scopes (org.zkoss.zk.scripting.HierachicalAware ). Default: the same as #unset(String) . #beforeExec is called first, before this method is invoked. |
Deriving class shall override #unset(String) , instead of this method. |
Deriving class shall override #unset(Namespace,String) , instead of this method. |