|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.zkoss.zk.scripting.util.GenericInterpreter
org.zkoss.zk.scripting.bsh.BSHInterpreter
public class BSHInterpreter
The interpreter that uses BeanShell to interpret zscript codes.
Unlike many other implementations, it supports the hierachical
scopes (HierachicalAware).
That is, it uses an independent BeanShell NameSpace
(aka. interpreter's scope) to store the variables/classes/methods
defined in BeanShell script for each ZK namespace (Namespace).
Since one-to-one relationship between BeanShell's scope and ZK namespace,
the invocation of BeanShell methods can execute correctly without knowing
what namespace it is.
However, if you want your codes portable across different interpreters,
you had better to call
Namespaces.beforeInterpret(java.util.Map, org.zkoss.zk.ui.Component, boolean)
to prepare the proper namespace, before calling any method defined in
zscript.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.zkoss.zk.scripting.SerializableAware |
|---|
SerializableAware.Filter |
| Field Summary |
|---|
| Fields inherited from class org.zkoss.zk.scripting.util.GenericInterpreter |
|---|
UNDEFINED |
| Constructor Summary | |
|---|---|
BSHInterpreter()
|
|
| Method Summary | |
|---|---|
protected boolean |
contains(Namespace ns,
java.lang.String name)
Tests whether a variable is defined in the interpreter's scope associated with the specified namespace. |
protected boolean |
contains(java.lang.String name)
Tests whether a variable is defined in this interpreter. |
void |
destroy()
Reset the owner ( GenericInterpreter.getOwner()) to null. |
protected void |
exec(java.lang.String script)
Executes the specified script. |
protected java.lang.Object |
get(Namespace ns,
java.lang.String name)
Gets the variable from the interpreter's scope associated with the giving namespace. |
protected java.lang.Object |
get(java.lang.String name)
Gets the variable from the interpreter. |
java.lang.Class |
getClass(java.lang.String clsnm)
Returns null since retrieving class is not supported. |
Method |
getMethod(Namespace ns,
java.lang.String name,
java.lang.Class[] argTypes)
Returns null since retrieving methods is not supported. |
Method |
getMethod(java.lang.String name,
java.lang.Class[] argTypes)
Returns null since retrieving methods is not supported. |
void |
init(Page owner,
java.lang.String zslang)
Initializes the interpreter. |
void |
read(java.io.ObjectInputStream s)
Reads the name and value of the variable from the specified input stream. |
protected void |
set(Namespace ns,
java.lang.String name,
java.lang.Object val)
Sets the variable to the interpreter's scope associated with the giving namespace. |
protected void |
set(java.lang.String name,
java.lang.Object val)
Sets the variable to the interpreter. |
protected void |
unset(Namespace ns,
java.lang.String name)
Removes the variable from the interpreter. |
protected void |
unset(java.lang.String name)
Removes the variable from the interpreter. |
void |
write(java.io.ObjectOutputStream s,
SerializableAware.Filter filter)
Writes the name and value of the variables of this namespace to the specified stream. |
| Methods inherited from class org.zkoss.zk.scripting.util.GenericInterpreter |
|---|
afterExec, afterInterpret, beforeExec, beforeInterpret, containsVariable, containsVariable, getCurrent, getFromNamespace, getFromNamespace, getLanguage, getOwner, getVariable, getVariable, interpret, setVariable, setVariable, unsetVariable, unsetVariable |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.zkoss.zk.scripting.HierachicalAware |
|---|
containsVariable, getVariable, setVariable, unsetVariable |
| Constructor Detail |
|---|
public BSHInterpreter()
| Method Detail |
|---|
protected void exec(java.lang.String script)
GenericInterpreterGenericInterpreter.interpret(java.lang.String, org.zkoss.zk.scripting.Namespace).
exec in class GenericInterpreterprotected boolean contains(java.lang.String name)
GenericInterpreterBy default, it tests whether GenericInterpreter.get(String) returns non-null.
contains in class GenericInterpreterprotected java.lang.Object get(java.lang.String name)
GenericInterpreterGenericInterpreter.beforeExec() is called first, before this method is invoked.
An empty (and fake) namespace is pushed so GenericInterpreter.getFromNamespace(java.lang.String)
always returns null.
get in class GenericInterpreter
protected void set(java.lang.String name,
java.lang.Object val)
GenericInterpreterGenericInterpreter.beforeExec() is called first, before this method is invoked.
set in class GenericInterpreterprotected void unset(java.lang.String name)
GenericInterpreterGenericInterpreter.beforeExec() is called first, before this method is invoked.
unset in class GenericInterpreter
protected boolean contains(Namespace ns,
java.lang.String name)
GenericInterpreterBy default, it tests whether GenericInterpreter.get(Namespace, String)
returns non-null.
contains in class GenericInterpreter
protected java.lang.Object get(Namespace ns,
java.lang.String name)
GenericInterpreterThis method is implemented only if the interpreter that supports
hierachical scopes (HierachicalAware).
Default: the same as GenericInterpreter.get(String).
GenericInterpreter.beforeExec() is called first, before this method is invoked.
An empty (and fake) namespace is pushed so GenericInterpreter.getFromNamespace(java.lang.String)
always returns null.
get in class GenericInterpreter
protected void set(Namespace ns,
java.lang.String name,
java.lang.Object val)
GenericInterpreterThis method is implemented only if the interpreter that supports
hierachical scopes (HierachicalAware).
Default: the same as GenericInterpreter.set(String, Object).
GenericInterpreter.beforeExec() is called first, before this method is invoked.
set in class GenericInterpreter
protected void unset(Namespace ns,
java.lang.String name)
GenericInterpreterThis method is implemented only if the interpreter that supports
hierachical scopes (HierachicalAware).
Default: the same as GenericInterpreter.unset(String).
GenericInterpreter.beforeExec() is called first, before this method is invoked.
unset in class GenericInterpreter
public void init(Page owner,
java.lang.String zslang)
Interpreter
init in interface Interpreterinit in class GenericInterpreterzslang - the language this interpreter is associated withpublic void destroy()
GenericInterpreterGenericInterpreter.getOwner()) to null.
destroy in interface Interpreterdestroy in class GenericInterpreterpublic java.lang.Class getClass(java.lang.String clsnm)
GenericInterpreter
getClass in interface InterpretergetClass in class GenericInterpreter
public Method getMethod(java.lang.String name,
java.lang.Class[] argTypes)
GenericInterpreter
getMethod in interface InterpretergetMethod in class GenericInterpreterargTypes - the list of argument (aka., parameter) types.
If null, Class[0] is assumed.
public Method getMethod(Namespace ns,
java.lang.String name,
java.lang.Class[] argTypes)
GenericInterpreter
getMethod in interface HierachicalAwaregetMethod in class GenericInterpreterns - 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.
public void write(java.io.ObjectOutputStream s,
SerializableAware.Filter filter)
throws java.io.IOException
SerializableAwareIf the variable's value is not serializable, it won't be written.
To read back, use SerializableAware.read(java.io.ObjectInputStream).
write in interface SerializableAwarejava.io.IOException
public void read(java.io.ObjectInputStream s)
throws java.io.IOException,
java.lang.ClassNotFoundException
SerializableAware
read in interface SerializableAwarejava.io.IOException
java.lang.ClassNotFoundExceptionSerializableAware.write(java.io.ObjectOutputStream, org.zkoss.zk.scripting.SerializableAware.Filter)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||