001: /*
002: * @(#)DOMCharacterDataImpl.java 1.11 2000/08/16
003: *
004: */
005:
006: package org.w3c.tidy;
007:
008: import org.w3c.dom.DOMException;
009:
010: /**
011: *
012: * DOMCharacterDataImpl
013: *
014: * (c) 1998-2000 (W3C) MIT, INRIA, Keio University
015: * See Tidy.java for the copyright notice.
016: * Derived from <a href="http://www.w3.org/People/Raggett/tidy">
017: * HTML Tidy Release 4 Aug 2000</a>
018: *
019: * @author Dave Raggett <dsr@w3.org>
020: * @author Andy Quick <ac.quick@sympatico.ca> (translation to Java)
021: * @version 1.7, 1999/12/06 Tidy Release 30 Nov 1999
022: * @version 1.8, 2000/01/22 Tidy Release 13 Jan 2000
023: * @version 1.9, 2000/06/03 Tidy Release 30 Apr 2000
024: * @version 1.10, 2000/07/22 Tidy Release 8 Jul 2000
025: * @version 1.11, 2000/08/16 Tidy Release 4 Aug 2000
026: */
027:
028: public class DOMCharacterDataImpl extends DOMNodeImpl implements
029: org.w3c.dom.CharacterData {
030:
031: protected DOMCharacterDataImpl(Node adaptee) {
032: super (adaptee);
033: }
034:
035: /* --------------------- DOM ---------------------------- */
036:
037: /**
038: * @see org.w3c.dom.CharacterData#getData
039: */
040: public String getData() throws DOMException {
041: return getNodeValue();
042: }
043:
044: /**
045: * @see org.w3c.dom.CharacterData#setData
046: */
047: public void setData(String data) throws DOMException {
048: // NOT SUPPORTED
049: throw new DOMExceptionImpl(
050: DOMException.NO_MODIFICATION_ALLOWED_ERR,
051: "Not supported");
052: }
053:
054: /**
055: * @see org.w3c.dom.CharacterData#getLength
056: */
057: public int getLength() {
058: int len = 0;
059: if (adaptee.textarray != null && adaptee.start < adaptee.end)
060: len = adaptee.end - adaptee.start;
061: return len;
062: }
063:
064: /**
065: * @see org.w3c.dom.CharacterData#substringData
066: */
067: public String substringData(int offset, int count)
068: throws DOMException {
069: int len;
070: String value = null;
071: if (count < 0) {
072: throw new DOMExceptionImpl(DOMException.INDEX_SIZE_ERR,
073: "Invalid length");
074: }
075: if (adaptee.textarray != null && adaptee.start < adaptee.end) {
076: if (adaptee.start + offset >= adaptee.end) {
077: throw new DOMExceptionImpl(DOMException.INDEX_SIZE_ERR,
078: "Invalid offset");
079: }
080: len = count;
081: if (adaptee.start + offset + len - 1 >= adaptee.end)
082: len = adaptee.end - adaptee.start - offset;
083:
084: value = Lexer.getString(adaptee.textarray, adaptee.start
085: + offset, len);
086: }
087: return value;
088: }
089:
090: /**
091: * @see org.w3c.dom.CharacterData#appendData
092: */
093: public void appendData(String arg) throws DOMException {
094: // NOT SUPPORTED
095: throw new DOMExceptionImpl(
096: DOMException.NO_MODIFICATION_ALLOWED_ERR,
097: "Not supported");
098: }
099:
100: /**
101: * @see org.w3c.dom.CharacterData#insertData
102: */
103: public void insertData(int offset, String arg) throws DOMException {
104: // NOT SUPPORTED
105: throw new DOMExceptionImpl(
106: DOMException.NO_MODIFICATION_ALLOWED_ERR,
107: "Not supported");
108: }
109:
110: /**
111: * @see org.w3c.dom.CharacterData#deleteData
112: */
113: public void deleteData(int offset, int count) throws DOMException {
114: // NOT SUPPORTED
115: throw new DOMExceptionImpl(
116: DOMException.NO_MODIFICATION_ALLOWED_ERR,
117: "Not supported");
118: }
119:
120: /**
121: * @see org.w3c.dom.CharacterData#replaceData
122: */
123: public void replaceData(int offset, int count, String arg)
124: throws DOMException {
125: // NOT SUPPORTED
126: throw new DOMExceptionImpl(
127: DOMException.NO_MODIFICATION_ALLOWED_ERR,
128: "Not supported");
129: }
130:
131: }
|