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 | |
public final class MapNamespaceContext implements NamespaceContext |
20 | |
{ |
21 | 0 | private Map namespaces = new HashMap(); |
22 | |
|
23 | |
public MapNamespaceContext() |
24 | |
{ |
25 | 0 | super(); |
26 | 0 | } |
27 | |
|
28 | |
public MapNamespaceContext(final Map ns) |
29 | |
{ |
30 | 0 | this(); |
31 | 0 | this.namespaces = ns; |
32 | 0 | } |
33 | |
|
34 | |
public void addNamespace(final String prefix, final String namespaceURI) |
35 | |
{ |
36 | 0 | this.namespaces.put(prefix, namespaceURI); |
37 | 0 | } |
38 | |
|
39 | |
public void addNamespaces(final Map ns) |
40 | |
{ |
41 | 0 | this.namespaces.putAll(ns); |
42 | 0 | } |
43 | |
|
44 | |
public String getNamespaceURI(String prefix) |
45 | |
{ |
46 | 0 | return (String) namespaces.get(prefix); |
47 | |
} |
48 | |
|
49 | |
public String getPrefix(String namespaceURI) |
50 | |
{ |
51 | 0 | for (Iterator itr = namespaces.entrySet().iterator(); itr.hasNext();) |
52 | |
{ |
53 | 0 | Map.Entry e = (Map.Entry) itr.next(); |
54 | 0 | if (e.getValue().equals(namespaceURI)) |
55 | |
{ |
56 | 0 | return (String) e.getKey(); |
57 | |
} |
58 | 0 | } |
59 | 0 | return null; |
60 | |
} |
61 | |
|
62 | |
public Iterator getPrefixes(String namespaceURI) |
63 | |
{ |
64 | 0 | return null; |
65 | |
} |
66 | |
|
67 | |
public Map getUsedNamespaces() |
68 | |
{ |
69 | 0 | return namespaces; |
70 | |
} |
71 | |
} |