Methods Summary |
---|
private boolean | canModify(org.w3c.dom.Node node)If any EntityReference to be removed has descendants
that are not EntityReference, Text, or CDATASection
nodes, the replaceWholeText method must fail before
performing any modification of the document, raising a
DOMException with the code NO_MODIFICATION_ALLOWED_ERR.
while (node != null) {
short type = node.getNodeType();
if (type == Node.ENTITY_REFERENCE_NODE) {
if (!canModify(node.getFirstChild())){
return false;
}
}
else if (type != Node.TEXT_NODE &&
type != Node.CDATA_SECTION_NODE) {
return false;
}
node = node.getNextSibling();
}
return true;
|
public java.lang.String | getNodeName()Returns the node name.
return "#text";
|
public short | getNodeType()A short integer indicating what type of node this is. The named
constants for this value are defined in the org.w3c.dom.Node interface.
return Node.TEXT_NODE;
|
public java.lang.String | getWholeText()DOM Level 3 WD - Experimental.
Returns all text of Text nodes logically-adjacent text
nodes to this node, concatenated in document order.
if (needsSyncData()) {
synchronizeData();
}
if (nextSibling == null) {
return data;
}
if (fBufferStr == null){
fBufferStr = new StringBuffer();
}
else {
fBufferStr.setLength(0);
}
if (data != null && data.length() != 0) {
fBufferStr.append(data);
}
getWholeText(nextSibling, fBufferStr);
return fBufferStr.toString();
|
private boolean | getWholeText(org.w3c.dom.Node node, java.lang.StringBuffer buffer)Concatenates the text of all logically-adjacent text nodes
String text;
while (node != null) {
short type = node.getNodeType();
if (type == Node.ENTITY_REFERENCE_NODE) {
if (getWholeText(node.getFirstChild(), buffer)){
return true;
}
}
else if (type == Node.TEXT_NODE ||
type == Node.CDATA_SECTION_NODE) {
((NodeImpl)node).getTextContent(buffer);
}
else {
return true;
}
node = node.getNextSibling();
}
return false;
|
public boolean | isElementContentWhitespace()DOM L3 Core CR - Experimental
Returns whether this text node contains
element content whitespace, often abusively called "ignorable whitespace".
The text node is determined to contain whitespace in element content
during the load of the document or if validation occurs while using
Document.normalizeDocument() .
// REVISIT: is this implemenation correct?
if (needsSyncData()) {
synchronizeData();
}
return internalIsIgnorableWhitespace();
|
public boolean | isIgnorableWhitespace()NON-DOM: Returns whether this Text is ignorable whitespace.
if (needsSyncData()) {
synchronizeData();
}
return internalIsIgnorableWhitespace();
|
public java.lang.String | removeData()NON-DOM (used by DOMParser: Sets data to empty string.
Returns the value the data was set to.
String olddata=data;
data = "";
return olddata;
|
public void | replaceData(java.lang.String value)NON-DOM (used by DOMParser): Reset data for the node.
data = value;
|
public org.w3c.dom.Text | replaceWholeText(java.lang.String content)DOM Level 3 WD - Experimental.
if (needsSyncData()) {
synchronizeData();
}
// make sure we can make the replacement
if (!canModify(nextSibling)) {
throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null));
}
Node parent = this.getParentNode();
if (content == null || content.length() == 0) {
// remove current node
if (parent !=null) { // check if node in the tree
parent.removeChild(this);
return null;
}
}
Text currentNode = null;
if (isReadOnly()){
Text newNode = this.ownerDocument().createTextNode(content);
if (parent !=null) { // check if node in the tree
parent.insertBefore(newNode, this);
parent.removeChild(this);
currentNode = newNode;
} else {
return newNode;
}
} else {
this.setData(content);
currentNode = this;
}
Node sibling = currentNode.getNextSibling();
while ( sibling !=null) {
parent.removeChild(sibling);
sibling = currentNode.getNextSibling();
}
return currentNode;
|
public void | setIgnorableWhitespace(boolean ignore)NON-DOM: Set whether this Text is ignorable whitespace.
if (needsSyncData()) {
synchronizeData();
}
isIgnorableWhitespace(ignore);
|
public void | setValues(com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl ownerDoc, java.lang.String data)NON-DOM: resets node and sets specified values for the current node
flags=0;
nextSibling = null;
previousSibling=null;
setOwnerDocument(ownerDoc);
super.data = data;
|
public org.w3c.dom.Text | splitText(int offset)Break a text node into two sibling nodes. (Note that if the
current node has no parent, they won't wind up as "siblings" --
they'll both be orphans.)
if (isReadOnly()) {
throw new DOMException(
DOMException.NO_MODIFICATION_ALLOWED_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null));
}
if (needsSyncData()) {
synchronizeData();
}
if (offset < 0 || offset > data.length() ) {
throw new DOMException(DOMException.INDEX_SIZE_ERR,
DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INDEX_SIZE_ERR", null));
}
// split text into two separate nodes
Text newText =
getOwnerDocument().createTextNode(data.substring(offset));
setNodeValue(data.substring(0, offset));
// insert new text node
Node parentNode = getParentNode();
if (parentNode != null) {
parentNode.insertBefore(newText, nextSibling);
}
return newText;
|