Coverage Report - org.webslinger.bsf.LanguageEngineConvertor
 
Classes in this File Line Coverage Branch Coverage Complexity
LanguageEngineConvertor
0%
0/72
N/A
0
 
 1  
 package org.webslinger.bsf;
 2  
 
 3  
 import java.io.IOException;
 4  
 import java.beans.PropertyChangeEvent;
 5  
 import java.util.Map;
 6  
 import java.util.Vector;
 7  
 
 8  
 import org.apache.bsf.BSFDeclaredBean;
 9  
 import org.apache.bsf.BSFEngine;
 10  
 import org.apache.bsf.BSFException;
 11  
 import org.apache.bsf.BSFManager;
 12  
 import org.apache.bsf.util.BSFFunctions;
 13  
 import org.apache.bsf.util.CodeBuffer;
 14  
 import org.apache.commons.collections.CollectionUtils;
 15  
 
 16  
 import org.webslinger.util.TTLObject;
 17  
 import org.webslinger.vfs.VFSDelegate;
 18  
 
 19  
 public class LanguageEngineConvertor implements LanguageEngine {
 20  
     static {
 21  0
         TTLObject.setDefaultTTLForClass(LanguageEngineConvertor.class, 1000);
 22  0
     }
 23  
 
 24  
     protected final String language;
 25  
     protected final LanguageManager manager;
 26  
     protected final BSFEngine engine;
 27  
     protected boolean debug;
 28  
 
 29  0
     public LanguageEngineConvertor(String language, LanguageManager manager, BSFEngine engine) {
 30  0
         this.language = language;
 31  0
         this.manager = manager;
 32  0
         this.engine = engine;
 33  0
     }
 34  
 
 35  
     public static Vector makeVector(Object[] array) {
 36  0
         Vector vector = new Vector(array.length);
 37  0
         CollectionUtils.addAll(vector, array);
 38  0
         return vector;
 39  
     }
 40  
 
 41  
     public long getTTL() {
 42  0
         return TTLObject.getTTLForClass(getClass());
 43  
     }
 44  
 
 45  
     public LanguageEngineInfo getLanguageEngineInfo() {
 46  0
         return null;
 47  
     }
 48  
 
 49  
     public Map getBeans() {
 50  0
         return null;
 51  
     }
 52  
 
 53  
     public boolean getDebug() {
 54  0
         return debug;
 55  
     }
 56  
 
 57  
     public void setDebug(boolean debug) {
 58  0
         this.debug = debug;
 59  0
     }
 60  
 
 61  
     public boolean isDebugOn() {
 62  0
         return debug;
 63  
     }
 64  
 
 65  
     public String getLanguage() {
 66  0
         return language;
 67  
     }
 68  
 
 69  
     public BSFManager getManager() {
 70  0
         return manager;
 71  
     }
 72  
 
 73  
     public AbstractManager getAbstractManager() {
 74  0
         return manager;
 75  
     }
 76  
 
 77  
     public BSFFunctions getBSFFunctions() {
 78  0
         return null;
 79  
     }
 80  
 
 81  
     public BSFEngine getEngine() {
 82  0
         return engine;
 83  
     }
 84  
 
 85  
     public VFSDelegate<?, Object, ?> getVFSDelegate() {
 86  0
         return getAbstractManager().getVFSDelegate();
 87  
     }
 88  
 
 89  
     public Object call(Object object, String name, Object[] args) throws BSFException {
 90  
         try {
 91  0
             return getEngine().call(getVFSDelegate().getString(object), name, args);
 92  0
         } catch (IOException e) {
 93  0
             throw (BSFException) new BSFException(BSFException.REASON_IO_ERROR, e.getMessage()).initCause(e);
 94  
         }
 95  
     }
 96  
 
 97  
     public Object apply(String source, int lineNo, int columnNo, Object body, Vector paramNames, Vector args) throws BSFException {
 98  
         try {
 99  0
             return getEngine().apply(source, lineNo, columnNo, getVFSDelegate().getString(body), paramNames, args);
 100  0
         } catch (IOException e) {
 101  0
             throw (BSFException) new BSFException(BSFException.REASON_IO_ERROR, e.getMessage()).initCause(e);
 102  
         }
 103  
     }
 104  
 
 105  
     public Object apply(String source, int lineNo, int columnNo, Object body, Vector paramNames, Vector args, Vector types) throws BSFException {
 106  
         try {
 107  0
             return getEngine().apply(source, lineNo, columnNo, getVFSDelegate().getString(body), paramNames, args, types);
 108  0
         } catch (IOException e) {
 109  0
             throw (BSFException) new BSFException(BSFException.REASON_IO_ERROR, e.getMessage()).initCause(e);
 110  
         }
 111  
     }
 112  
 
 113  
     public Object apply(String source, int lineNo, int columnNo, Object funcBody, String[] paramNames, Object[] arguments) throws BSFException {
 114  0
         return apply(source, lineNo, columnNo, funcBody, makeVector(paramNames), makeVector(arguments));
 115  
     }
 116  
 
 117  
     public Object apply(String source, int lineNo, int columnNo, Object funcBody, String[] paramNames, Object[] arguments, Class[] types) throws BSFException {
 118  0
         return apply(source, lineNo, columnNo, funcBody, makeVector(paramNames), makeVector(arguments), makeVector(types));
 119  
     }
 120  
 
 121  
     public void compileApply(String source, int lineNo, int columnNo, Object body, Vector paramNames, Vector args, CodeBuffer cb) throws BSFException {
 122  
         try {
 123  0
             getEngine().compileApply(source, lineNo, columnNo, getVFSDelegate().getString(body), paramNames, args, cb);
 124  0
         } catch (IOException e) {
 125  0
             throw (BSFException) new BSFException(BSFException.REASON_IO_ERROR, e.getMessage()).initCause(e);
 126  0
         }
 127  0
     }
 128  
 
 129  
     public void compileExpr(String source, int lineNo, int columnNo, Object expr, CodeBuffer cb) throws BSFException {
 130  
         try {
 131  0
             getEngine().compileExpr(source, lineNo, columnNo, getVFSDelegate().getString(expr), cb);
 132  0
         } catch (IOException e) {
 133  0
             throw (BSFException) new BSFException(BSFException.REASON_IO_ERROR, e.getMessage()).initCause(e);
 134  0
         }
 135  0
     }
 136  
 
 137  
     public void compileScript(String source, int lineNo, int columnNo, Object script, CodeBuffer cb) throws BSFException {
 138  
         try {
 139  0
             getEngine().compileScript(source, lineNo, columnNo, getVFSDelegate().getString(script), cb);
 140  0
         } catch (IOException e) {
 141  0
             throw (BSFException) new BSFException(BSFException.REASON_IO_ERROR, e.getMessage()).initCause(e);
 142  0
         }
 143  0
     }
 144  
 
 145  
     public Object eval(String source, int lineNo, int columnNo, Object expr) throws BSFException {
 146  
         try {
 147  0
             return getEngine().eval(source, lineNo, columnNo, getVFSDelegate().getString(expr));
 148  0
         } catch (IOException e) {
 149  0
             throw (BSFException) new BSFException(BSFException.REASON_IO_ERROR, e.getMessage()).initCause(e);
 150  
         }
 151  
     }
 152  
 
 153  
     public void exec(String source, int lineNo, int columnNo, Object script) throws BSFException {
 154  
         try {
 155  0
             getEngine().exec(source, lineNo, columnNo, getVFSDelegate().getString(script));
 156  0
         } catch (IOException e) {
 157  0
             throw (BSFException) new BSFException(BSFException.REASON_IO_ERROR, e.getMessage()).initCause(e);
 158  0
         }
 159  0
     }
 160  
 
 161  
     public void iexec(String source, int lineNo, int columnNo, Object script) throws BSFException {
 162  
         try {
 163  0
             getEngine().iexec(source, lineNo, columnNo, getVFSDelegate().getString(script));
 164  0
         } catch (IOException e) {
 165  0
             throw (BSFException) new BSFException(BSFException.REASON_IO_ERROR, e.getMessage()).initCause(e);
 166  0
         }
 167  0
     }
 168  
 
 169  
     public void terminate() {
 170  0
         getEngine().terminate();
 171  0
     }
 172  
 
 173  
     public void initialize(BSFManager manager, String lang, Vector declaredBeans) throws BSFException {
 174  
         // do nothing, the real engine was already initialized
 175  0
     }
 176  
 
 177  
     public void undeclareBean(BSFDeclaredBean bean) throws BSFException {
 178  0
         getEngine().undeclareBean(bean);
 179  0
     }
 180  
 
 181  
     public void declareBean(BSFDeclaredBean bean) throws BSFException {
 182  0
         getEngine().declareBean(bean);
 183  0
     }
 184  
 
 185  
     public void propertyChange(PropertyChangeEvent event) {
 186  0
         System.err.println("event=" + event);
 187  0
         getEngine().propertyChange(event);
 188  0
     }
 189  
 }