1 package org.jaxen; 2 3 48 49 import java.io.Serializable ; 50 51 68 public class ContextSupport 69 implements Serializable 70 { 71 72 73 private transient FunctionContext functionContext; 74 75 76 private NamespaceContext namespaceContext; 77 78 79 private VariableContext variableContext; 80 81 82 private Navigator navigator; 83 84 88 90 public ContextSupport() 91 { 92 } 94 95 102 public ContextSupport(NamespaceContext namespaceContext, 103 FunctionContext functionContext, 104 VariableContext variableContext, 105 Navigator navigator) 106 { 107 setNamespaceContext( namespaceContext ); 108 setFunctionContext( functionContext ); 109 setVariableContext( variableContext ); 110 111 this.navigator = navigator; 112 } 113 114 118 122 public void setNamespaceContext(NamespaceContext namespaceContext) 123 { 124 this.namespaceContext = namespaceContext; 125 } 126 127 131 public NamespaceContext getNamespaceContext() 132 { 133 return this.namespaceContext; 134 } 135 136 140 public void setFunctionContext(FunctionContext functionContext) 141 { 142 this.functionContext = functionContext; 143 } 144 145 149 public FunctionContext getFunctionContext() 150 { 151 return this.functionContext; 152 } 153 154 158 public void setVariableContext(VariableContext variableContext) 159 { 160 this.variableContext = variableContext; 161 } 162 163 167 public VariableContext getVariableContext() 168 { 169 return this.variableContext; 170 } 171 172 176 public Navigator getNavigator() 177 { 178 return this.navigator; 179 } 180 181 183 189 public String translateNamespacePrefixToUri(String prefix) 190 { 191 192 if ("xml".equals(prefix)) { 193 return "http://www.w3.org/XML/1998/namespace"; 194 } 195 NamespaceContext context = getNamespaceContext(); 196 197 if ( context != null ) 198 { 199 return context.translateNamespacePrefixToUri( prefix ); 200 } 201 202 return null; 203 } 204 205 215 public Object getVariableValue( String namespaceURI, 216 String prefix, 217 String localName ) 218 throws UnresolvableException 219 { 220 VariableContext context = getVariableContext(); 221 222 if ( context != null ) 223 { 224 return context.getVariableValue( namespaceURI, prefix, localName ); 225 } 226 else 227 { 228 throw new UnresolvableException( "No variable context installed" ); 229 } 230 } 231 232 242 public Function getFunction( String namespaceURI, 243 String prefix, 244 String localName ) 245 throws UnresolvableException 246 { 247 FunctionContext context = getFunctionContext(); 248 249 if ( context != null ) 250 { 251 return context.getFunction( namespaceURI, prefix, localName ); 252 } 253 else 254 { 255 throw new UnresolvableException( "No function context installed" ); 256 } 257 } 258 } 259 | Popular Tags |