use of com.gargoylesoftware.htmlunit.html.DomCharacterData in project htmlunit by HtmlUnit.
the class XMLDOMCharacterData method setData.
/**
* Sets the node data depending on the node type.
* @param newData the node data depending on the node type
*/
@JsxSetter
public void setData(final String newData) {
if (newData == null || "null".equals(newData)) {
throw Context.reportRuntimeError("Type mismatch.");
}
final DomCharacterData domCharacterData = getDomNodeOrDie();
domCharacterData.setData(newData);
}
use of com.gargoylesoftware.htmlunit.html.DomCharacterData in project htmlunit by HtmlUnit.
the class XMLDOMCharacterData method replaceData.
/**
* Replaces the specified number of characters with the supplied string.
* @param offset the offset, in characters, at which to start replacing string data
* @param count the number of characters to replace
* @param data the new data that replaces the old string data
*/
@JsxFunction
public void replaceData(final int offset, final int count, final String data) {
if (offset < 0) {
throw Context.reportRuntimeError("The offset must be 0 or a positive number that is not greater than the " + "number of characters in the data.");
}
if (count < 0) {
throw Context.reportRuntimeError("The offset must be 0 or a positive number that is not greater than the " + "number of characters in the data.");
}
if (data == null || "null".equals(data)) {
throw Context.reportRuntimeError("Type mismatch.");
}
final DomCharacterData domCharacterData = getDomNodeOrDie();
if (offset > domCharacterData.getLength()) {
throw Context.reportRuntimeError("The offset must be 0 or a positive number that is not greater than the " + "number of characters in the data.");
}
domCharacterData.replaceData(offset, count, data);
}
Aggregations