KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > gumby > script > bsh > BeanshellScript


1 package org.sapia.gumby.script.bsh;
2
3 import org.sapia.gumby.RenderContext;
4 import org.sapia.gumby.script.Script;
5 import org.sapia.gumby.script.ScriptConsts;
6
7 import bsh.Interpreter;
8
9 /**
10  * @author Yanick Duchesne
11  *
12  * <dl>
13  * <dt><b>Copyright: </b>
14  * <dd>Copyright &#169; 2002-2005 <a HREF="http://www.sapia-oss.org">Sapia Open
15  * Source Software </a>. All Rights Reserved.</dd>
16  * </dt>
17  * <dt><b>License: </b>
18  * <dd>Read the license.txt file of the jar or visit the <a
19  * HREF="http://www.sapia-oss.org/license.html">license page </a> at the Sapia
20  * OSS web site</dd>
21  * </dt>
22  * </dl>
23  */

24 public class BeanshellScript implements Script, ScriptConsts {
25
26   private String JavaDoc _script;
27
28   BeanshellScript(String JavaDoc script) {
29     _script = script;
30   }
31
32   /**
33    * @see org.sapia.gumby.script.Script#execute(org.sapia.gumby.RenderContext,
34    * java.lang.Object[])
35    */

36   public Object JavaDoc execute(RenderContext context, Object JavaDoc[] args) throws Exception JavaDoc {
37     Interpreter bsh = new Interpreter();
38     bsh.set(KEY_CONTEXT, context);
39     bsh.set(KEY_ARGS, args);
40     return bsh.eval(_script);
41   }
42
43 }
44
Popular Tags