1 37 package org.webharvest.runtime.scripting; 38 39 import bsh.CallStack; 40 import bsh.Interpreter; 41 import bsh.EvalError; 42 43 import java.util.Map ; 44 45 import org.webharvest.exception.ScriptException; 46 import org.webharvest.runtime.variables.EmptyVariable; 47 import org.webharvest.runtime.variables.IVariable; 48 import org.webharvest.runtime.variables.NodeVariable; 49 import org.webharvest.runtime.ScraperContext; 50 51 55 public class SetContextVar { 56 57 public static void invoke(Interpreter interpreter, CallStack callstack, String name, Object value) { 58 try { 59 ScraperContext context = (ScraperContext) interpreter.get(ScriptEngine.CONTEXT_VARIABLE_NAME); 60 if (context != null) { 61 context.setVar(name, value); 62 } 63 } catch (EvalError e) { 64 throw new ScriptException("Cannot get web-Harvest context from interpreter: " + e.getMessage(), e); 65 } 66 } 67 68 } | Popular Tags |