1
2
3
4
5
6
7
8
9
10 package org.dom4j.tree;
11
12 import java.util.Map;
13
14 import org.dom4j.Element;
15
16 /*** <p><code>DefaultProcessingInstruction</code> is the default
17 * Processing Instruction implementation.
18 * It is a doubly linked node which supports the parent relationship
19 * and can be modified in place.</p>
20 *
21 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
22 * @version $Revision: 1.11 $
23 */
24 public class DefaultProcessingInstruction extends FlyweightProcessingInstruction {
25
26 /*** The parent of this node */
27 private Element parent;
28
29 /*** <p>This will create a new PI with the given target and values</p>
30 *
31 * @param target is the name of the PI
32 * @param values is the <code>Map</code> values for the PI
33 */
34 public DefaultProcessingInstruction(String target,Map values) {
35 super(target, values);
36 }
37
38 /*** <p>This will create a new PI with the given target and values</p>
39 *
40 * @param target is the name of the PI
41 * @param values is the values for the PI
42 */
43 public DefaultProcessingInstruction(String target,String values) {
44 super(target, values);
45 }
46
47 /*** <p>This will create a new PI with the given target and values</p>
48 *
49 * @param parent is the parent element
50 * @param target is the name of the PI
51 * @param values is the values for the PI
52 */
53 public DefaultProcessingInstruction(Element parent,String target,String values) {
54 super(target, values);
55 this.parent = parent;
56 }
57
58 public void setTarget(String target) {
59 this.target = target;
60 }
61
62 public void setText(String text) {
63 this.text = text;
64 this.values = parseValues(text);
65 }
66
67 public void setValues(Map values) {
68 this.values = values;
69 this.text = toString(values);
70 }
71
72 public void setValue(String name, String value) {
73 values.put(name, value);
74 }
75
76
77 public Element getParent() {
78 return parent;
79 }
80
81 public void setParent(Element parent) {
82 this.parent = parent;
83 }
84
85 public boolean supportsParent() {
86 return true;
87 }
88
89 public boolean isReadOnly() {
90 return false;
91 }
92 }
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140