KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > gumby > script > pnuts > PnutsScript


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

27 public class PnutsScript implements Script, ScriptConsts {
28
29   private Pnuts _pn;
30
31   PnutsScript(String JavaDoc script) throws ParseException {
32     Compiler JavaDoc comp = new Compiler JavaDoc();
33     _pn = comp.compile(script);
34   }
35
36   /**
37    * @see org.sapia.gumby.script.Script#execute(org.sapia.gumby.RenderContext,
38    * java.lang.Object[])
39    */

40   public Object JavaDoc execute(RenderContext renderContext, Object JavaDoc[] args)
41       throws Exception JavaDoc {
42     Context ctx = new Context();
43     ctx.set(KEY_CONTEXT, renderContext);
44     ctx.set(KEY_ARGS, args);
45     return _pn.run(ctx);
46   }
47
48 }
49
Popular Tags