01: // Copyright (c) 2004 Per M.A. Bothner.
02: // This is free software; for terms and warranty disclaimer see ./COPYING.
03:
04: package gnu.kawa.xml;
05:
06: import gnu.xml.*;
07:
08: /* #ifdef use:org.w3c.dom.Node */
09: // import org.w3c.dom.*;
10: /* #endif */
11:
12: public abstract class KCharacterData extends KNode
13: /* #ifdef use:org.w3c.dom.Node */
14: // implements org.w3c.dom.CharacterData
15: /* #endif */
16: {
17: public KCharacterData(NodeTree seq, int ipos) {
18: super (seq, ipos);
19: }
20:
21: /** Non-optimized. */
22: public int getLength() {
23: StringBuffer sbuf = new StringBuffer();
24: NodeTree tlist = (NodeTree) sequence;
25: tlist.stringValue(tlist.posToDataIndex(ipos), sbuf);
26: return sbuf.length();
27: }
28:
29: public String getData() {
30: return getNodeValue();
31: }
32:
33: /* #ifdef use:org.w3c.dom.Node */
34: // public void setData(String data) throws DOMException
35: // {
36: // throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
37: // "setData not supported");
38: // }
39: // public String substringData(int offset, int count)
40: // throws DOMException
41: // {
42: // String data = getData();
43: // if (offset < 0 || count < 0 || offset + count >= data.length())
44: // throw new DOMException(DOMException.INDEX_SIZE_ERR,
45: // "invalid index to substringData");
46: // return data.substring(offset, count);
47: // }
48: // public void appendData (String data) throws DOMException
49: // {
50: // throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
51: // "appendData not supported");
52: // }
53: // public void insertData (int offset, String data) throws DOMException
54: // {
55: // replaceData(offset, 0, data);
56: // }
57: // public void deleteData (int offset, int count) throws DOMException
58: // {
59: // replaceData(offset, count, "");
60: // }
61: // public void replaceData (int offset, int count, String arg) throws DOMException
62: // {
63: // throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
64: // "replaceData not supported");
65: // }
66: /* #endif */
67: }
|