/** Sets the text value of data. */ public void setData(String data) throws DOMException { if (!this.isReadonly()) { this.textValue.replace(0, this.getLength(), data); } else { throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null)); } }
/** * */ public void deleteData(int offset, int count) throws DOMException { this.replaceData(offset, count, null); }
public void appendData(String value) throws DOMException { if (this.isReadonly()) { throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null)); } this.textValue.append(value); }
/** * Extracts a range of data from the node. * * @return Returns the specified substring. If the sum of offset and count exceeds the length, then * all 16-bit units to the end of the data are returned. */ public String substringData(int offset, int count) throws DOMException { if (offset < 0 || offset > this.getLength() || count < 0) { throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR", null)); } int end = Math.min(count + offset, textValue.length()); return this.textValue.substring(offset, end); }
/** If the given data is null the content will be deleted. */ public void replaceData(int offset, int count, String data) throws DOMException { if (this.isReadonly()) { throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null)); } int length = this.textValue.length(); if (offset < 0 || offset > length - 1 || count < 0) { throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR", null)); } else { int end = Math.min(count + offset, length); if (data == null) { this.textValue.delete(offset, end); } else { this.textValue.replace(offset, end, data); } } }
/** Inserts a string at the specified offset. */ public void insertData(int offset, String data) throws DOMException { int length = this.getLength(); if (this.isReadonly()) { throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null)); } if (offset < 0 || offset > length - 1) { throw new DOMException(DOMException.INDEX_SIZE_ERR, DOMMessageFormatter.formatMessage( DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR", null)); } this.textValue.insert(offset, data); }