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.Signatures; |
26 |
| import org.apache.xindice.xml.SymbolTable; |
27 |
| import org.apache.xindice.xml.XMLCompressedInput; |
28 |
| |
29 |
| import org.w3c.dom.EntityReference; |
30 |
| import org.w3c.dom.Node; |
31 |
| |
32 |
| import java.io.IOException; |
33 |
| |
34 |
| |
35 |
| |
36 |
| |
37 |
| |
38 |
| |
39 |
| public final class EntityReferenceImpl extends NodeImpl |
40 |
| implements EntityReference { |
41 |
| |
42 |
| private static final Log log = LogFactory.getLog(EntityReferenceImpl.class); |
43 |
| |
44 |
| |
45 |
0
| public EntityReferenceImpl() {
|
46 |
| } |
47 |
| |
48 |
0
| public EntityReferenceImpl(NodeImpl parent, byte[] data, int pos, int len) {
|
49 |
0
| super(parent, data, pos, len);
|
50 |
| } |
51 |
| |
52 |
0
| public EntityReferenceImpl(NodeImpl parent, boolean dirty) {
|
53 |
0
| super(parent, dirty);
|
54 |
| } |
55 |
| |
56 |
0
| public EntityReferenceImpl(NodeImpl parent, String nodeName) {
|
57 |
0
| super(parent, true);
|
58 |
0
| this.nodeName = nodeName;
|
59 |
| } |
60 |
| |
61 |
0
| protected void checkLoaded() {
|
62 |
0
| if (loaded) {
|
63 |
0
| return;
|
64 |
| } |
65 |
| |
66 |
0
| loaded = true;
|
67 |
0
| try {
|
68 |
0
| if (data != null) {
|
69 |
0
| DocumentImpl doc = (DocumentImpl) getOwnerDocument();
|
70 |
0
| SymbolTable st = doc.getSymbols();
|
71 |
| |
72 |
0
| ByteArrayInput bis = new ByteArrayInput(data, pos, len);
|
73 |
0
| XMLCompressedInput xci = new XMLCompressedInput(bis, st);
|
74 |
| |
75 |
0
| byte signature = xci.readByte();
|
76 |
0
| byte entityType = (byte) (signature & 0x1F);
|
77 |
0
| switch (entityType) {
|
78 |
| |
79 |
0
| case Signatures.ENT_DEFINED:
|
80 |
0
| nodeName = st.getName(xci.readShort());
|
81 |
0
| break;
|
82 |
| |
83 |
0
| case Signatures.ENT_AMP:
|
84 |
0
| nodeName = "&";
|
85 |
0
| break;
|
86 |
| |
87 |
0
| case Signatures.ENT_LT:
|
88 |
0
| nodeName = "<";
|
89 |
0
| break;
|
90 |
| |
91 |
0
| case Signatures.ENT_GT:
|
92 |
0
| nodeName = ">";
|
93 |
0
| break;
|
94 |
| |
95 |
0
| case Signatures.ENT_QUOT:
|
96 |
0
| nodeName = """;
|
97 |
0
| break;
|
98 |
| |
99 |
0
| case Signatures.ENT_APOS:
|
100 |
0
| nodeName = "'";
|
101 |
0
| break;
|
102 |
| |
103 |
0
| case Signatures.ENT_UNICODE:
|
104 |
| |
105 |
0
| nodeName = "";
|
106 |
0
| break;
|
107 |
| |
108 |
0
| default:
|
109 |
0
| if (log.isWarnEnabled()) {
|
110 |
0
| log.warn("invalid entity type : " + entityType);
|
111 |
| } |
112 |
| } |
113 |
| } |
114 |
| } catch (IOException e) { |
115 |
0
| if (log.isWarnEnabled()) {
|
116 |
0
| log.warn("ignored exception", e);
|
117 |
| } |
118 |
| } |
119 |
| } |
120 |
| |
121 |
0
| public short getNodeType() {
|
122 |
0
| return Node.ENTITY_REFERENCE_NODE;
|
123 |
| } |
124 |
| } |