KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > dom > AbstractElementNS


1 /*
2
3    Copyright 2000 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.dom;
19
20 import org.apache.batik.dom.util.DOMUtilities;
21 import org.apache.batik.dom.util.XMLSupport;
22 import org.w3c.dom.DOMException JavaDoc;
23 import org.w3c.dom.Node JavaDoc;
24
25 /**
26  * This class implements the {@link org.w3c.dom.Element} interface.
27  *
28  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
29  * @version $Id: AbstractElementNS.java,v 1.3 2004/08/18 07:13:07 vhardy Exp $
30  */

31
32 public abstract class AbstractElementNS extends AbstractElement {
33     /**
34      * The namespace URI
35      */

36     protected String JavaDoc namespaceURI;
37
38     /**
39      * Creates a new AbstractElementNS object.
40      */

41     protected AbstractElementNS() {
42     }
43
44     /**
45      * Creates a new AbstractElementNS object.
46      * @param nsURI The element namespace URI.
47      * @param qname The element qualified name for validation purposes.
48      * @param owner The owner document.
49      * @exception DOMException
50      * INVALID_CHARACTER_ERR: Raised if the specified qualified name
51      * contains an illegal character.
52      * <br> NAMESPACE_ERR: Raised if the <code>qualifiedName</code> is
53      * malformed, if the <code>qualifiedName</code> has a prefix and the
54      * <code>namespaceURI</code> is <code>null</code> or an empty string,
55      * or if the <code>qualifiedName</code> has a prefix that is "xml" and
56      * the <code>namespaceURI</code> is different from
57      * "http://www.w3.org/XML/1998/namespace" .
58      */

59     protected AbstractElementNS(String JavaDoc nsURI, String JavaDoc qname,
60                                 AbstractDocument owner)
61     throws DOMException JavaDoc {
62     super(qname, owner);
63     namespaceURI = nsURI;
64     String JavaDoc prefix = DOMUtilities.getPrefix(qname);
65     if (prefix != null) {
66         if (nsURI == null || nsURI.equals("") ||
67         ("xml".equals(prefix) &&
68          !XMLSupport.XML_NAMESPACE_URI.equals(nsURI))) {
69         throw createDOMException
70                     (DOMException.NAMESPACE_ERR,
71                      "namespace.uri",
72                      new Object JavaDoc[] { new Integer JavaDoc(getNodeType()),
73                                     getNodeName(),
74                                     nsURI });
75         }
76     }
77     }
78
79     /**
80      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNamespaceURI()}.
81      * @return {@link #namespaceURI}.
82      */

83     public String JavaDoc getNamespaceURI() {
84     return namespaceURI;
85     }
86
87     /**
88      * Exports this node to the given document.
89      */

90     protected Node JavaDoc export(Node JavaDoc n, AbstractDocument d) {
91     super.export(n, d);
92     AbstractElementNS ae = (AbstractElementNS)n;
93     ae.namespaceURI = namespaceURI;
94     return n;
95     }
96
97     /**
98      * Deeply exports this node to the given document.
99      */

100     protected Node JavaDoc deepExport(Node JavaDoc n, AbstractDocument d) {
101     super.deepExport(n, d);
102     AbstractElementNS ae = (AbstractElementNS)n;
103     ae.namespaceURI = namespaceURI;
104     return n;
105     }
106
107     /**
108      * Copy the fields of the current node into the given node.
109      * @param n a node of the type of this.
110      */

111     protected Node JavaDoc copyInto(Node JavaDoc n) {
112     super.copyInto(n);
113     AbstractElementNS ae = (AbstractElementNS)n;
114     ae.namespaceURI = namespaceURI;
115     return n;
116     }
117
118     /**
119      * Deeply copy the fields of the current node into the given node.
120      * @param n a node of the type of this.
121      */

122     protected Node JavaDoc deepCopyInto(Node JavaDoc n) {
123     super.deepCopyInto(n);
124     AbstractElementNS ae = (AbstractElementNS)n;
125     ae.namespaceURI = namespaceURI;
126     return n;
127     }
128 }
129
Popular Tags