KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > commons > xml > namespace > NamespaceResolver


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.commons.xml.namespace;
20
21 import org.w3c.dom.Node JavaDoc;
22
23 /**
24  * Defines the interface for an XML namespace resolver for looking up namespace/prefix
25  * combinations.
26  *
27  * @author Matthew Large
28  * @version $Revision: 1.1 $
29  */

30 public interface NamespaceResolver {
31
32     /**
33      * Stores the specified namespace/prefix pair if the prefix is not already stored.
34      * If the prefix is already stored then a NamespaceClashException is thrown.
35      *
36      * @param sURI Namespace URI
37      * @param sPrefix Namespace prefix
38      * @throws NamespaceClashException If the prefix already exists
39      */

40     public void addNamespace(String JavaDoc sURI, String JavaDoc sPrefix) throws NamespaceClashException;
41     
42     /**
43      * Removes the specified namespace from the resolver if it exists.
44      *
45      * @param sURI Namespace URI
46      */

47     public void removeNamespace(String JavaDoc sURI);
48     
49     /**
50      * Returns the namespace URI that matches the supplied prefix.
51      *
52      * @param sPrefix Namespace prefix
53      * @return Namespace URI, null if none found
54      */

55     public String JavaDoc getNamespaceByPrefix(String JavaDoc sPrefix);
56     
57     /**
58      * Returns the namespace prefix that matches the supplied URI. If the namespace is associated
59      * to more than one prefix then the first found prefix is returned.
60      * If no namespace is found then a new prefix is generated, which does not clash
61      * with any stored prefix, stored and returned.
62      *
63      * @param sURI Namespace URI
64      * @return Namespace prefix
65      */

66     public String JavaDoc getPrefixByNamespace(String JavaDoc sURI);
67     
68     /**
69      * Returns the namespace prefix that matches the namespace URI of the supplied Node.
70      * If the Node does not have a namespace URI assigned to it null will be returned.
71      * If the namespace is associated
72      * with more than one prefix then the first found prefix is returned.
73      * If no namespace is found then a new prefix is generated, which does not clash
74      * with any stored prefix, stored and returned.
75      *
76      * @param node DOM Node to be checked
77      * @return Namespace prefix or null if the Node does not have a namespace URI assigned.
78      */

79     public String JavaDoc getPrefixByNode(Node JavaDoc node) throws NamespaceClashException;
80
81 }
82
Popular Tags