1 37 package org.webharvest.runtime.processors; 38 39 import org.webharvest.definition.VarDef; 40 import org.webharvest.exception.VariableException; 41 import org.webharvest.runtime.Scraper; 42 import org.webharvest.runtime.ScraperContext; 43 import org.webharvest.runtime.templaters.BaseTemplater; 44 import org.webharvest.runtime.variables.IVariable; 45 46 49 public class VarProcessor extends BaseProcessor { 50 51 private VarDef varDef; 52 53 public VarProcessor(VarDef varDef) { 54 super(varDef); 55 this.varDef = varDef; 56 } 57 58 public IVariable execute(Scraper scraper, ScraperContext context) { 59 String name = BaseTemplater.execute( varDef.getName(), scraper.getScriptEngine() ); 60 61 IVariable var = context.getVar(name); 62 63 if (var == null) { 64 throw new VariableException("Variable '" + name + "' is not defined!"); 65 } 66 67 return var; 68 } 69 70 } | Popular Tags |