1 61 62 63 package org.jaxen; 64 65 import java.io.Serializable ; 66 import java.util.HashMap ; 67 import java.util.Map ; 68 69 79 public class SimpleVariableContext implements VariableContext, Serializable 80 { 81 82 private Map variables; 83 84 90 public SimpleVariableContext() 91 { 92 variables = new HashMap (); 93 } 94 95 112 public void setVariableValue( String namespaceURI, 113 String localName, 114 Object value ) 115 { 116 this.variables.put( new QualifiedName(namespaceURI, localName), 117 value ); 118 } 119 120 132 public void setVariableValue( String localName, 133 Object value ) 134 { 135 this.variables.put( new QualifiedName(null, localName), value ); 136 } 137 138 public Object getVariableValue( String namespaceURI, 139 String prefix, 140 String localName ) 141 throws UnresolvableException 142 { 143 Object key = new QualifiedName( namespaceURI, localName ); 144 145 if ( this.variables.containsKey(key) ) 146 { 147 return this.variables.get( key ); 148 } 149 else 150 { 151 throw new UnresolvableException( "Variable {" + namespaceURI + 152 "}" + prefix + ":" + localName ); 153 } 154 } 155 } 156 | Popular Tags |