1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.html;
16
17 import java.io.PrintWriter;
18
19 import org.htmlunit.SgmlPage;
20 import org.w3c.dom.DOMException;
21 import org.w3c.dom.ProcessingInstruction;
22
23
24
25
26
27
28
29 public class DomProcessingInstruction extends DomNode implements ProcessingInstruction {
30
31 private final String target_;
32 private String data_;
33
34
35
36
37
38
39
40
41 public DomProcessingInstruction(final SgmlPage page, final String target, final String data) {
42 super(page);
43 target_ = target;
44 setData(data);
45 }
46
47
48
49
50
51 @Override
52 public short getNodeType() {
53 return org.w3c.dom.Node.PROCESSING_INSTRUCTION_NODE;
54 }
55
56
57
58
59 @Override
60 public String getNodeName() {
61 return target_;
62 }
63
64
65
66
67 @Override
68 public String getTarget() {
69 return getNodeName();
70 }
71
72
73
74
75 @Override
76 public String getData() {
77 return getNodeValue();
78 }
79
80
81
82
83 @Override
84 public void setData(final String data) throws DOMException {
85 setNodeValue(data);
86 }
87
88
89
90
91 @Override
92 public void setNodeValue(final String value) {
93 data_ = value;
94 }
95
96
97
98
99 @Override
100 public String getNodeValue() {
101 return data_;
102 }
103
104
105
106
107 @Override
108 public void setTextContent(final String textContent) {
109 setNodeValue(textContent);
110 }
111
112
113
114
115 @Override
116 protected boolean printXml(final String indent, final boolean tagBefore, final PrintWriter printWriter) {
117 printWriter.print("<?");
118 printWriter.print(getTarget());
119 printWriter.print(" ");
120 printWriter.print(getData());
121 printWriter.print("?>");
122 return true;
123 }
124
125
126
127
128 @Override
129 public void setPrefix(final String prefix) {
130
131 }
132 }