Mercurial > dive4elements > framework
comparison artifacts-common/src/main/java/org/dive4elements/artifacts/common/utils/MapXPathVariableResolver.java @ 472:783cc1b6b615
Moved directories to org.dive4elements
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 10:53:15 +0200 |
parents | artifacts-common/src/main/java/de/intevation/artifacts/common/utils/MapXPathVariableResolver.java@1d3607ceb9fa |
children | 415df0fc4fa1 |
comparison
equal
deleted
inserted
replaced
471:1a87cb24a446 | 472:783cc1b6b615 |
---|---|
1 /* | |
2 * Copyright (c) 2011 by Intevation GmbH | |
3 * | |
4 * This program is free software under the LGPL (>=v2.1) | |
5 * Read the file LGPL.txt coming with the software for details | |
6 * or visit http://www.gnu.org/licenses/ if it does not exist. | |
7 */ | |
8 package de.intevation.artifacts.common.utils; | |
9 | |
10 import java.util.HashMap; | |
11 import java.util.Map; | |
12 | |
13 import javax.xml.namespace.QName; | |
14 import javax.xml.xpath.XPathVariableResolver; | |
15 | |
16 | |
17 /** | |
18 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | |
19 */ | |
20 public class MapXPathVariableResolver implements XPathVariableResolver { | |
21 | |
22 protected Map<String, String> variables; | |
23 | |
24 | |
25 public MapXPathVariableResolver() { | |
26 this.variables = new HashMap<String, String>(); | |
27 } | |
28 | |
29 | |
30 public MapXPathVariableResolver(Map<String, String> variables) { | |
31 this.variables = variables; | |
32 } | |
33 | |
34 | |
35 public void addVariable(String name, String value) { | |
36 if (name != null && value != null) { | |
37 variables.put(name, value); | |
38 } | |
39 } | |
40 | |
41 | |
42 @Override | |
43 public Object resolveVariable(QName variableName) { | |
44 String key = variableName.getLocalPart(); | |
45 return variables.get(key); | |
46 } | |
47 } | |
48 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |