home *** CD-ROM | disk | FTP | other *** search
- package com.ibm.bsf.engines.jacl;
-
- import com.ibm.bsf.BSFDeclaredBean;
- import com.ibm.bsf.BSFException;
- import com.ibm.bsf.BSFManager;
- import com.ibm.bsf.util.BSFEngineImpl;
- import java.util.Vector;
- import tcl.lang.Interp;
- import tcl.lang.TclException;
-
- public class JaclEngine extends BSFEngineImpl {
- private Interp interp;
-
- public void initialize(BSFManager var1, String var2, Vector var3) throws BSFException {
- super.initialize(var1, var2, var3);
- this.interp = new Interp();
- this.interp.createCommand("bsf", new BSFCommand(var1, this));
- int var4 = var3.size();
-
- for(int var5 = 0; var5 < var4; ++var5) {
- this.declareBean((BSFDeclaredBean)var3.elementAt(var5));
- }
-
- }
-
- public Object eval(String var1, int var2, int var3, Object var4) throws BSFException {
- String var5 = var4.toString();
-
- try {
- this.interp.eval(var5);
- return this.interp.getResult();
- } catch (TclException var7) {
- throw new BSFException(BSFException.REASON_EXECUTION_ERROR, "error while eval'ing Jacl expression: " + this.interp.getResult(), var7);
- }
- }
-
- public Object call(Object var1, String var2, Object[] var3) throws BSFException {
- StringBuffer var4 = new StringBuffer(var2);
- if (var3 != null) {
- for(int var5 = 0; var5 < var3.length; ++var5) {
- var4.append(" ");
- var4.append(var3[var5].toString());
- }
- }
-
- return this.eval("<function call>", 0, 0, var4.toString());
- }
-
- public void declareBean(BSFDeclaredBean var1) throws BSFException {
- String var2 = "set " + var1.name + " [bsf lookupBean \"" + var1.name + "\"]";
- this.eval("<declare bean>", 0, 0, var2);
- }
-
- public void undeclareBean(BSFDeclaredBean var1) throws BSFException {
- this.eval("<undeclare bean>", 0, 0, "set " + var1.name + " \"\"");
- }
- }
-