Save This Page
Home » zk-src-3.0.6 » org.zkoss.zk.scripting.bsh » [javadoc | source]
org.zkoss.zk.scripting.bsh
public class: BSHInterpreter [javadoc | source]
java.lang.Object
   org.zkoss.zk.scripting.util.GenericInterpreter
      org.zkoss.zk.scripting.bsh.BSHInterpreter

All Implemented Interfaces:
    SerializableAware, HierachicalAware, Interpreter

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 org.zkoss.zk.scripting.Namespaces#beforeInterpret to prepare the proper namespace, before calling any method defined in zscript.

Fields inherited from org.zkoss.zk.scripting.util.GenericInterpreter:
UNDEFINED
Constructor:
 public BSHInterpreter() 
Method from org.zkoss.zk.scripting.bsh.BSHInterpreter Summary:
contains,   contains,   destroy,   exec,   get,   get,   getClass,   getFunction,   getFunction,   getNativeInterpreter,   init,   loadDefaultImports,   read,   set,   set,   unset,   unset,   write
Methods from org.zkoss.zk.scripting.util.GenericInterpreter:
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.bsh.BSHInterpreter Detail:
 protected boolean contains(String name) 
 protected boolean contains(Namespace ns,
    String name) 
 public  void destroy() 
 protected  void exec(String script) 
 protected Object get(String name) 
 protected Object get(Namespace ns,
    String name) 
 public Class getClass(String clsnm) 
 public Function getFunction(String name,
    Class[] argTypes) 
 public Function getFunction(Namespace ns,
    String name,
    Class[] argTypes) 
 public Object getNativeInterpreter() 
    Returns the native interpreter, or null if it is not initialized or destroyed. From application's standpoint, it never returns null, and the returned object must be an instance of bsh.Interpreter
 public  void init(Page owner,
    String zslang) 
 protected  void loadDefaultImports(NameSpace bshns) 
    Called when the top-level BeanShell namespace is created. By default, it does nothing.

    Note: to speed up the performance, this implementation disabled bsh.NameSpace#loadDefaultImports . It only imports the java.lang and java.util packages. If you want the built command and import packages, you can override this method. For example,

    
    protected void loadDefaultImports(NameSpace bshns) {
    bshns.importCommands("/bsh/commands");
    }
 public  void read(ObjectInputStream s) throws ClassNotFoundException, IOException 
 protected  void set(String name,
    Object val) 
 protected  void set(Namespace ns,
    String name,
    Object val) 
 protected  void unset(String name) 
 protected  void unset(Namespace ns,
    String name) 
 public  void write(ObjectOutputStream s,
    Filter filter) throws IOException