Source code: org/apache/batik/dom/GenericProcessingInstruction.java
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.Node;
21
22 /**
23 * This class implements the {@link
24 * org.w3c.dom.ProcessingInstruction} interface.
25 *
26 * @author <a href="mailto:stephane@hillion.org">Stephane Hillion</a>
27 * @version $Id: GenericProcessingInstruction.java,v 1.4 2004/08/18 07:13:08 vhardy Exp $
28 */
29
30 public class GenericProcessingInstruction
31 extends AbstractProcessingInstruction {
32 /**
33 * The target.
34 */
35 protected String target;
36
37 /**
38 * Is this node immutable?
39 */
40 protected boolean readonly;
41
42 /**
43 * Creates a new ProcessingInstruction object.
44 */
45 protected GenericProcessingInstruction() {
46 }
47
48 /**
49 * Creates a new ProcessingInstruction object.
50 */
51 public GenericProcessingInstruction(String target,
52 String data,
53 AbstractDocument owner) {
54 ownerDocument = owner;
55 setTarget(target);
56 setData(data);
57 }
58
59 /**
60 * Sets the node name.
61 */
62 public void setNodeName(String v) {
63 setTarget(v);
64 }
65
66 /**
67 * Tests whether this node is readonly.
68 */
69 public boolean isReadonly() {
70 return readonly;
71 }
72
73 /**
74 * Sets this node readonly attribute.
75 */
76 public void setReadonly(boolean v) {
77 readonly = v;
78 }
79
80 /**
81 * <b>DOM</b>: Implements {@link
82 * org.w3c.dom.ProcessingInstruction#getTarget()}.
83 * @return {@link #target}.
84 */
85 public String getTarget() {
86 return target;
87 }
88
89 /**
90 * Sets the target value.
91 */
92 public void setTarget(String v) {
93 target = v;
94 }
95
96 /**
97 * Exports this node to the given document.
98 */
99 protected Node export(Node n, AbstractDocument d) {
100 GenericProcessingInstruction p;
101 p = (GenericProcessingInstruction)super.export(n, d);
102 p.setTarget(getTarget());
103 return p;
104 }
105
106 /**
107 * Deeply exports this node to the given document.
108 */
109 protected Node deepExport(Node n, AbstractDocument d) {
110 GenericProcessingInstruction p;
111 p = (GenericProcessingInstruction)super.deepExport(n, d);
112 p.setTarget(getTarget());
113 return p;
114 }
115
116 /**
117 * Copy the fields of the current node into the given node.
118 * @param n a node of the type of this.
119 */
120 protected Node copyInto(Node n) {
121 GenericProcessingInstruction p;
122 p = (GenericProcessingInstruction)super.copyInto(n);
123 p.setTarget(getTarget());
124 return p;
125 }
126
127 /**
128 * Deeply copy the fields of the current node into the given node.
129 * @param n a node of the type of this.
130 */
131 protected Node deepCopyInto(Node n) {
132 GenericProcessingInstruction p;
133 p = (GenericProcessingInstruction)super.deepCopyInto(n);
134 p.setTarget(getTarget());
135 return p;
136 }
137
138 /**
139 * Returns a new uninitialized instance of this object's class.
140 */
141 protected Node newNode() {
142 return new GenericProcessingInstruction();
143 }
144 }