KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2
3    Copyright 2000,2002 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.w3c.dom.DOMException JavaDoc;
21 import org.w3c.dom.Entity JavaDoc;
22 import org.w3c.dom.Node JavaDoc;
23
24 /**
25  * This class implements the {@link org.w3c.dom.Entity} interface.
26  *
27  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
28  * @version $Id: AbstractEntity.java,v 1.6 2005/02/22 09:12:58 cam Exp $
29  */

30 public abstract class AbstractEntity
31     extends AbstractParentNode
32     implements Entity JavaDoc {
33     /**
34      * The node name.
35      */

36     protected String JavaDoc nodeName;
37
38     /**
39      * The public id.
40      */

41     protected String JavaDoc publicId;
42
43     /**
44      * The system id.
45      */

46     protected String JavaDoc systemId;
47
48     /**
49      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNodeType()}.
50      * @return {@link org.w3c.dom.Node#ENTITY_NODE}
51      */

52     public short getNodeType() {
53     return ENTITY_NODE;
54     }
55
56     /**
57      * Sets the name of this node.
58      */

59     public void setNodeName(String JavaDoc v) {
60     nodeName = v;
61     }
62
63     /**
64      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNodeName()}.
65      * @return {@link #nodeName}.
66      */

67     public String JavaDoc getNodeName() {
68     return nodeName;
69     }
70
71     /**
72      * <b>DOM</b>: Implements {@link org.w3c.dom.Entity#getPublicId()}.
73      * @return {@link #publicId}.
74      */

75     public String JavaDoc getPublicId() {
76     return publicId;
77     }
78
79     /**
80      * Sets the public id.
81      */

82     public void setPublicId(String JavaDoc id) {
83     publicId = id;
84     }
85
86     /**
87      * <b>DOM</b>: Implements {@link org.w3c.dom.Entity#getSystemId()}.
88      * @return {@link #systemId}.
89      */

90     public String JavaDoc getSystemId() {
91     return systemId;
92     }
93
94     /**
95      * Sets the system id.
96      */

97     public void setSystemId(String JavaDoc id) {
98     systemId = id;
99     }
100
101     /**
102      * <b>DOM</b>: Implements {@link org.w3c.dom.Entity#getNotationName()}.
103      * @return {@link #getNodeName()}.
104      */

105     public String JavaDoc getNotationName() {
106     return getNodeName();
107     }
108
109     /**
110      * Sets the notation name.
111      */

112     public void setNotationName(String JavaDoc name) {
113     setNodeName(name);
114     }
115
116     /**
117      * Exports this node to the given document.
118      */

119     protected Node JavaDoc export(Node JavaDoc n, AbstractDocument d) {
120     super.export(n, d);
121     AbstractEntity ae = (AbstractEntity)n;
122     ae.nodeName = nodeName;
123     ae.publicId = publicId;
124     ae.systemId = systemId;
125     return n;
126     }
127
128     /**
129      * Deeply exports this node to the given document.
130      */

131     protected Node JavaDoc deepExport(Node JavaDoc n, AbstractDocument d) {
132     super.deepExport(n, d);
133     AbstractEntity ae = (AbstractEntity)n;
134     ae.nodeName = nodeName;
135     ae.publicId = publicId;
136     ae.systemId = systemId;
137     return n;
138     }
139
140     /**
141      * Copy the fields of the current node into the given node.
142      * @param n a node of the type of this.
143      */

144     protected Node JavaDoc copyInto(Node JavaDoc n) {
145     super.copyInto(n);
146     AbstractEntity ae = (AbstractEntity)n;
147     ae.nodeName = nodeName;
148     ae.publicId = publicId;
149     ae.systemId = systemId;
150     return n;
151     }
152
153     /**
154      * Deeply copy the fields of the current node into the given node.
155      * @param n a node of the type of this.
156      */

157     protected Node JavaDoc deepCopyInto(Node JavaDoc n) {
158     super.deepCopyInto(n);
159     AbstractEntity ae = (AbstractEntity)n;
160     ae.nodeName = nodeName;
161     ae.publicId = publicId;
162     ae.systemId = systemId;
163     return n;
164     }
165
166     /**
167      * Checks the validity of a node to be inserted.
168      */

169     protected void checkChildType(Node JavaDoc n, boolean replace) {
170     switch (n.getNodeType()) {
171     case ELEMENT_NODE:
172     case PROCESSING_INSTRUCTION_NODE:
173     case COMMENT_NODE:
174     case TEXT_NODE:
175     case CDATA_SECTION_NODE:
176     case ENTITY_REFERENCE_NODE:
177     case DOCUMENT_FRAGMENT_NODE:
178         break;
179     default:
180         throw createDOMException
181                 (DOMException.HIERARCHY_REQUEST_ERR,
182                  "child.type",
183                  new Object JavaDoc[] { new Integer JavaDoc(getNodeType()),
184                                 getNodeName(),
185                                 new Integer JavaDoc(n.getNodeType()),
186                                 n.getNodeName() });
187     }
188     }
189 }
190
Popular Tags