1 16 package org.apache.commons.jxpath; 17 18 import java.util.HashMap ; 19 20 26 public class BasicVariables implements Variables { 27 28 31 private HashMap vars = new HashMap (); 32 33 41 public boolean isDeclaredVariable(String varName) { 42 return vars.containsKey(varName); 43 } 44 45 53 public Object getVariable(String varName) { 54 56 if (vars.containsKey(varName)) { 57 return vars.get(varName); 58 } 59 60 throw new IllegalArgumentException ( 61 "No such variable: '" + varName + "'"); 62 } 63 64 71 public void declareVariable(String varName, Object value) { 72 vars.put(varName, value); 73 } 74 75 80 public void undeclareVariable(String varName) { 81 vars.remove(varName); 82 } 83 84 public String toString() { 85 return vars.toString(); 86 } 87 } | Popular Tags |