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