1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 package org.w3c.tidy;
55
56 import org.w3c.dom.DOMException;
57
58
59 /**
60 * Tidy implementation of org.w3c.dom.CharacterData.
61 * @author Dave Raggett <a href="mailto:dsr@w3.org">dsr@w3.org </a>
62 * @author Andy Quick <a href="mailto:ac.quick@sympatico.ca">ac.quick@sympatico.ca </a> (translation to Java)
63 * @author Fabrizio Giustina
64 * @version $Revision: 779 $ ($Author: fgiust $)
65 */
66 public class DOMCharacterDataImpl extends DOMNodeImpl implements org.w3c.dom.CharacterData
67 {
68
69 /**
70 * Instantiates a new DOMCharacterDataImpl which wraps the given Node.
71 * @param adaptee wrapped node.
72 */
73 protected DOMCharacterDataImpl(Node adaptee)
74 {
75 super(adaptee);
76 }
77
78 /**
79 * @see org.w3c.dom.CharacterData#getData
80 */
81 public String getData() throws DOMException
82 {
83 return getNodeValue();
84 }
85
86 /**
87 * @see org.w3c.dom.CharacterData#getLength
88 */
89 public int getLength()
90 {
91 int len = 0;
92 if (adaptee.textarray != null && adaptee.start < adaptee.end)
93 {
94 len = adaptee.end - adaptee.start;
95 }
96 return len;
97 }
98
99 /**
100 * @see org.w3c.dom.CharacterData#substringData
101 */
102 public String substringData(int offset, int count) throws DOMException
103 {
104 int len;
105 String value = null;
106 if (count < 0)
107 {
108 throw new DOMException(DOMException.INDEX_SIZE_ERR, "Invalid length");
109 }
110 if (adaptee.textarray != null && adaptee.start < adaptee.end)
111 {
112 if (adaptee.start + offset >= adaptee.end)
113 {
114 throw new DOMException(DOMException.INDEX_SIZE_ERR, "Invalid offset");
115 }
116 len = count;
117 if (adaptee.start + offset + len - 1 >= adaptee.end)
118 {
119 len = adaptee.end - adaptee.start - offset;
120 }
121
122 value = TidyUtils.getString(adaptee.textarray, adaptee.start + offset, len);
123 }
124 return value;
125 }
126
127 /**
128 * Not supported.
129 * @see org.w3c.dom.CharacterData#setData
130 */
131 public void setData(String data) throws DOMException
132 {
133
134 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Not supported");
135 }
136
137 /**
138 * Not supported.
139 * @see org.w3c.dom.CharacterData#appendData
140 */
141 public void appendData(String arg) throws DOMException
142 {
143
144 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Not supported");
145 }
146
147 /**
148 * Not supported.
149 * @see org.w3c.dom.CharacterData#insertData
150 */
151 public void insertData(int offset, String arg) throws DOMException
152 {
153
154 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Not supported");
155 }
156
157 /**
158 * Not supported.
159 * @see org.w3c.dom.CharacterData#deleteData
160 */
161 public void deleteData(int offset, int count) throws DOMException
162 {
163
164 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Not supported");
165 }
166
167 /**
168 * Not supported.
169 * @see org.w3c.dom.CharacterData#replaceData
170 */
171 public void replaceData(int offset, int count, String arg) throws DOMException
172 {
173
174 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Not supported");
175 }
176
177 }