Source code: com/port80/html/tidy/DOMCharacterDataImpl.java
1 /*
2 * @(#)DOMCharacterDataImpl.java 1.11 2000/08/16
3 *
4 */
5
6 package com.port80.html.tidy;
7
8 import org.w3c.dom.DOMException;
9
10
11 /**
12 *
13 * DOMCharacterDataImpl
14 *
15 * (c) 1998-2000 (W3C) MIT, INRIA, Keio University
16 * See Tidy.java for the copyright notice.
17 * Derived from <a href="http://www.w3.org/People/Raggett/tidy">
18 * HTML Tidy Release 4 Aug 2000</a>
19 *
20 * @author Dave Raggett <dsr@w3.org>
21 * @author Andy Quick <ac.quick@sympatico.ca> (translation to Java)
22 * @version 1.7, 1999/12/06 Tidy Release 30 Nov 1999
23 * @version 1.8, 2000/01/22 Tidy Release 13 Jan 2000
24 * @version 1.9, 2000/06/03 Tidy Release 30 Apr 2000
25 * @version 1.10, 2000/07/22 Tidy Release 8 Jul 2000
26 * @version 1.11, 2000/08/16 Tidy Release 4 Aug 2000
27 */
28
29 public class DOMCharacterDataImpl extends DOMNodeImpl
30 implements org.w3c.dom.CharacterData {
31
32 protected DOMCharacterDataImpl(Node adaptee)
33 {
34 super(adaptee);
35 }
36
37
38 /* --------------------- DOM ---------------------------- */
39
40 /**
41 * @see org.w3c.dom.CharacterData#getData
42 */
43 public String getData() throws DOMException
44 {
45 return getNodeValue();
46 }
47
48 /**
49 * @see org.w3c.dom.CharacterData#setData
50 */
51 public void setData(String data) throws DOMException
52 {
53 // NOT SUPPORTED
54 throw new DOMExceptionImpl(DOMException.NO_MODIFICATION_ALLOWED_ERR,
55 "Not supported");
56 }
57
58 /**
59 * @see org.w3c.dom.CharacterData#getLength
60 */
61 public int getLength()
62 {
63 int len = 0;
64 if (adaptee.textarray != null && adaptee.start < adaptee.end)
65 len = adaptee.end - adaptee.start;
66 return len;
67 }
68
69 /**
70 * @see org.w3c.dom.CharacterData#substringData
71 */
72 public String substringData(int offset,
73 int count) throws DOMException
74 {
75 int len;
76 String value = null;
77 if (count < 0)
78 {
79 throw new DOMExceptionImpl(DOMException.INDEX_SIZE_ERR,
80 "Invalid length");
81 }
82 if (adaptee.textarray != null && adaptee.start < adaptee.end)
83 {
84 if (adaptee.start + offset >= adaptee.end)
85 {
86 throw new DOMExceptionImpl(DOMException.INDEX_SIZE_ERR,
87 "Invalid offset");
88 }
89 len = count;
90 if (adaptee.start + offset + len - 1 >= adaptee.end)
91 len = adaptee.end - adaptee.start - offset;
92
93 value = Lexer.getString(adaptee.textarray,
94 adaptee.start + offset,
95 len);
96 }
97 return value;
98 }
99
100 /**
101 * @see org.w3c.dom.CharacterData#appendData
102 */
103 public void appendData(String arg) throws DOMException
104 {
105 // NOT SUPPORTED
106 throw new DOMExceptionImpl(DOMException.NO_MODIFICATION_ALLOWED_ERR,
107 "Not supported");
108 }
109
110 /**
111 * @see org.w3c.dom.CharacterData#insertData
112 */
113 public void insertData(int offset,
114 String arg) throws DOMException
115 {
116 // NOT SUPPORTED
117 throw new DOMExceptionImpl(DOMException.NO_MODIFICATION_ALLOWED_ERR,
118 "Not supported");
119 }
120
121 /**
122 * @see org.w3c.dom.CharacterData#deleteData
123 */
124 public void deleteData(int offset,
125 int count) throws DOMException
126 {
127 // NOT SUPPORTED
128 throw new DOMExceptionImpl(DOMException.NO_MODIFICATION_ALLOWED_ERR,
129 "Not supported");
130 }
131
132 /**
133 * @see org.w3c.dom.CharacterData#replaceData
134 */
135 public void replaceData(int offset,
136 int count,
137 String arg) throws DOMException
138 {
139 // NOT SUPPORTED
140 throw new DOMExceptionImpl(DOMException.NO_MODIFICATION_ALLOWED_ERR,
141 "Not supported");
142 }
143
144 }