KickJava   Java API By Example, From Geeks To Geeks.

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


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.w3c.dom.DOMException JavaDoc;
21 import org.w3c.dom.Node JavaDoc;
22 import org.w3c.dom.ProcessingInstruction JavaDoc;
23
24 /**
25  * This class implements the {@link org.w3c.dom.ProcessingInstruction}
26  * interface.
27  *
28  * @author <a HREF="mailto:stephane@hillion.org">Stephane Hillion</a>
29  * @version $Id: AbstractProcessingInstruction.java,v 1.6 2005/03/27 08:58:32 cam Exp $
30  */

31 public abstract class AbstractProcessingInstruction
32     extends AbstractChildNode
33     implements ProcessingInstruction JavaDoc {
34     /**
35      * The data.
36      */

37     protected String JavaDoc data;
38
39     /**
40      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNodeName()}.
41      * @return {@link #getTarget()}.
42      */

43     public String JavaDoc getNodeName() {
44     return getTarget();
45     }
46
47     /**
48      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNodeType()}.
49      * @return {@link org.w3c.dom.Node#PROCESSING_INSTRUCTION_NODE}
50      */

51     public short getNodeType() {
52     return PROCESSING_INSTRUCTION_NODE;
53     }
54
55     /**
56      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#getNodeValue()}.
57      * @return {@link #getData()}.
58      */

59     public String JavaDoc getNodeValue() throws DOMException JavaDoc {
60     return getData();
61     }
62
63     /**
64      * <b>DOM</b>: Implements {@link org.w3c.dom.Node#setNodeValue(String)}.
65      */

66     public void setNodeValue(String JavaDoc nodeValue) throws DOMException JavaDoc {
67     setData(nodeValue);
68     }
69
70     /**
71      * <b>DOM</b>: Implements {@link
72      * org.w3c.dom.ProcessingInstruction#getData()}.
73      * @return {@link #data}.
74      */

75     public String JavaDoc getData() {
76     return data;
77     }
78
79     /**
80      * <b>DOM</b>: Implements {@link
81      * org.w3c.dom.ProcessingInstruction#setData(String)}.
82      */

83     public void setData(String JavaDoc data) throws DOMException JavaDoc {
84     if (isReadonly()) {
85             throw createDOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
86                                      "readonly.node",
87                                      new Object JavaDoc[] { new Integer JavaDoc(getNodeType()),
88                                                     getNodeName() });
89     }
90     String JavaDoc val = this.data;
91     this.data = data;
92
93     // Mutation event
94
fireDOMCharacterDataModifiedEvent(val, this.data);
95     if (getParentNode() != null) {
96         ((AbstractParentNode)getParentNode()).
97                 fireDOMSubtreeModifiedEvent();
98     }
99     }
100
101     /**
102      * Exports this node to the given document.
103      */

104     protected Node JavaDoc export(Node JavaDoc n, AbstractDocument d) {
105     AbstractProcessingInstruction p;
106     p = (AbstractProcessingInstruction)super.export(n, d);
107     p.data = data;
108     return p;
109     }
110
111     /**
112      * Deeply exports this node to the given document.
113      */

114     protected Node JavaDoc deepExport(Node JavaDoc n, AbstractDocument d) {
115     AbstractProcessingInstruction p;
116     p = (AbstractProcessingInstruction)super.deepExport(n, d);
117     p.data = data;
118     return p;
119     }
120
121     /**
122      * Copy the fields of the current node into the given node.
123      * @param n a node of the type of this.
124      */

125     protected Node JavaDoc copyInto(Node JavaDoc n) {
126     AbstractProcessingInstruction p;
127     p = (AbstractProcessingInstruction)super.copyInto(n);
128     p.data = data;
129     return p;
130     }
131
132     /**
133      * Deeply copy the fields of the current node into the given node.
134      * @param n a node of the type of this.
135      */

136     protected Node JavaDoc deepCopyInto(Node JavaDoc n) {
137     AbstractProcessingInstruction p;
138     p = (AbstractProcessingInstruction)super.deepCopyInto(n);
139     p.data = data;
140     return p;
141     }
142 }
143
Popular Tags