1
2
3
4
5
6
7 package org.mule.module.xml.stax;
8
9 import java.util.HashMap;
10 import java.util.Iterator;
11 import java.util.Map;
12
13 import javax.xml.namespace.NamespaceContext;
14
15 public final class MapNamespaceContext implements NamespaceContext
16 {
17 private Map namespaces = new HashMap();
18
19 public MapNamespaceContext()
20 {
21 super();
22 }
23
24 public MapNamespaceContext(final Map ns)
25 {
26 this();
27 this.namespaces = ns;
28 }
29
30 public void addNamespace(final String prefix, final String namespaceURI)
31 {
32 this.namespaces.put(prefix, namespaceURI);
33 }
34
35 public void addNamespaces(final Map ns)
36 {
37 this.namespaces.putAll(ns);
38 }
39
40 public String getNamespaceURI(String prefix)
41 {
42 return (String) namespaces.get(prefix);
43 }
44
45 public String getPrefix(String namespaceURI)
46 {
47 for (Iterator itr = namespaces.entrySet().iterator(); itr.hasNext();)
48 {
49 Map.Entry e = (Map.Entry) itr.next();
50 if (e.getValue().equals(namespaceURI))
51 {
52 return (String) e.getKey();
53 }
54 }
55 return null;
56 }
57
58 public Iterator getPrefixes(String namespaceURI)
59 {
60 return null;
61 }
62
63 public Map getUsedNamespaces()
64 {
65 return namespaces;
66 }
67 }