1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| |
16 |
| |
17 |
| |
18 |
| |
19 |
| |
20 |
| package org.apache.xindice.xml.dom; |
21 |
| |
22 |
| import org.apache.commons.logging.Log; |
23 |
| import org.apache.commons.logging.LogFactory; |
24 |
| import org.apache.xindice.util.ByteArrayInput; |
25 |
| import org.apache.xindice.xml.SymbolTable; |
26 |
| import org.apache.xindice.xml.XMLCompressedInput; |
27 |
| |
28 |
| import org.w3c.dom.DOMException; |
29 |
| import org.w3c.dom.Node; |
30 |
| import org.w3c.dom.ProcessingInstruction; |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| public final class ProcessingInstructionImpl extends NodeImpl implements ProcessingInstruction { |
38 |
| |
39 |
| private static final Log log = LogFactory.getLog(ProcessingInstructionImpl.class); |
40 |
| |
41 |
| |
42 |
0
| public ProcessingInstructionImpl() {
|
43 |
| } |
44 |
| |
45 |
2658
| public ProcessingInstructionImpl(NodeImpl parent, byte[] data, int pos, int len) {
|
46 |
2658
| super(parent, data, pos, len);
|
47 |
| } |
48 |
| |
49 |
0
| public ProcessingInstructionImpl(NodeImpl parent, boolean dirty) {
|
50 |
0
| super(parent, dirty);
|
51 |
| } |
52 |
| |
53 |
5869
| public ProcessingInstructionImpl(NodeImpl parent, String nodeName, String nodeValue) {
|
54 |
5869
| super(parent, true);
|
55 |
5869
| this.nodeName = nodeName;
|
56 |
5869
| this.nodeValue = nodeValue;
|
57 |
| } |
58 |
| |
59 |
17054
| protected void checkLoaded() {
|
60 |
17054
| if (loaded) {
|
61 |
8527
| return;
|
62 |
| } else { |
63 |
8527
| loaded = true;
|
64 |
| } |
65 |
| |
66 |
8527
| try {
|
67 |
8527
| if (data != null) {
|
68 |
2658
| DocumentImpl doc = (DocumentImpl) getOwnerDocument();
|
69 |
2658
| SymbolTable st = doc.getSymbols();
|
70 |
| |
71 |
2658
| ByteArrayInput bis = new ByteArrayInput(data, pos, len);
|
72 |
2658
| XMLCompressedInput xci = new XMLCompressedInput(bis, st);
|
73 |
| |
74 |
2658
| xci.readSignature();
|
75 |
2658
| xci.readInt();
|
76 |
| |
77 |
2658
| byte[] buf = new byte[bis.available()];
|
78 |
2658
| xci.read(buf);
|
79 |
| |
80 |
2658
| String value = new String(buf, "UTF-8");
|
81 |
2658
| int i = value.indexOf(' ');
|
82 |
2658
| nodeName = value.substring(0, i);
|
83 |
2658
| nodeValue = value.substring(i + 1);
|
84 |
| } |
85 |
| } catch (Exception e) { |
86 |
0
| if (log.isWarnEnabled()) {
|
87 |
0
| log.warn("ignored exception", e);
|
88 |
| } |
89 |
| } |
90 |
| } |
91 |
| |
92 |
37319
| public short getNodeType() {
|
93 |
37319
| return Node.PROCESSING_INSTRUCTION_NODE;
|
94 |
| } |
95 |
| |
96 |
0
| public void setNodeValue(String nodeValue) throws DOMException {
|
97 |
0
| checkLoaded();
|
98 |
0
| checkReadOnly();
|
99 |
0
| this.nodeValue = nodeValue;
|
100 |
0
| setDirty();
|
101 |
| } |
102 |
| |
103 |
| |
104 |
| |
105 |
| |
106 |
| |
107 |
0
| public String getTarget() {
|
108 |
0
| return getNodeName();
|
109 |
| } |
110 |
| |
111 |
| |
112 |
| |
113 |
| |
114 |
| |
115 |
| |
116 |
| |
117 |
| |
118 |
0
| public String getData() {
|
119 |
0
| return getNodeValue();
|
120 |
| } |
121 |
| |
122 |
0
| public void setData(String data) throws DOMException {
|
123 |
0
| setNodeValue(data);
|
124 |
| } |
125 |
| } |