01: /*
02: * Copyright 2004,2005 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.axis2.databinding.utils.writer;
17:
18: import javax.xml.namespace.NamespaceContext;
19: import java.util.Iterator;
20: import java.util.Map;
21: import java.util.HashMap;
22:
23: public class OMStreamNamespaceContext implements NamespaceContext {
24:
25: private Map namespaceToPrefixMap;
26: private Map prefixToNamespaceMap;
27:
28: public OMStreamNamespaceContext() {
29: this .namespaceToPrefixMap = new HashMap();
30: this .prefixToNamespaceMap = new HashMap();
31: }
32:
33: public void registerNamespace(String namespace, String prefix) {
34: this .namespaceToPrefixMap.put(namespace, prefix);
35: this .prefixToNamespaceMap.put(prefix, namespace);
36: }
37:
38: public String getNamespaceURI(String prefix) {
39: return (String) prefixToNamespaceMap.get(prefix);
40: }
41:
42: public String getPrefix(String namespaceURI) {
43: return (String) namespaceToPrefixMap.get(namespaceURI);
44: }
45:
46: public Iterator getPrefixes(String namespaceURI) {
47: return prefixToNamespaceMap.keySet().iterator();
48: }
49:
50: }
|