Class PMRTextImpl
java.lang.Object
org.episteme.natural.chemistry.loaders.cml.dom.pmr.PMRNodeImpl
org.episteme.natural.chemistry.loaders.cml.dom.pmr.PMRCharacterDataImpl
org.episteme.natural.chemistry.loaders.cml.dom.pmr.PMRTextImpl
- All Implemented Interfaces:
CharacterData, Node, Text
- Direct Known Subclasses:
PMRCDATASectionImpl
Implementation of the
Text interface for the CML DOM.- Since:
- 1.0
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Field Summary
Fields inherited from class PMRNodeImpl
childNodes, delegateNode, parentNode, pmrDocument, siblingNodesFields inherited from interface Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for the PMRTextImpl object.PMRTextImpl(Text text, PMRDocument doc) Creates a new PMRTextImpl object. -
Method Summary
Modifier and TypeMethodDescriptionReturns all text ofTextnodes logically-adjacent text nodes to this node, concatenated in document order.booleanReturns whether this text node contains element content whitespace, often called "ignorable whitespace".replaceWholeText(String content) Replaces the text of the current node and all logically-adjacent text nodes with the specified text.splitText(int i) Breaks this node into two nodes at the specifiedoffset, keeping both in the tree as siblings.Methods inherited from class PMRCharacterDataImpl
appendData, deleteData, getData, getLength, insertData, replaceData, setData, substringDataMethods inherited from class PMRNodeImpl
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getDelegateNode, getDelegateParentNode, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setDelegateNode, setNodeValue, setOwnerDocument, setOwnerDocumentRecursively, setPrefix, setTextContent, setUserData, toString, wrapRecursivelyMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface CharacterData
appendData, deleteData, getData, getLength, insertData, replaceData, setData, substringDataMethods inherited from interface Node
appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setNodeValue, setPrefix, setTextContent, setUserData
-
Constructor Details
-
PMRTextImpl
public PMRTextImpl()Constructor for the PMRTextImpl object. -
PMRTextImpl
Creates a new PMRTextImpl object.- Parameters:
text- the generic W3C text node to delegate todoc- the owner CML document
-
-
Method Details
-
splitText
Breaks this node into two nodes at the specifiedoffset, keeping both in the tree as siblings. After being split, this node will contain all the content up to theoffsetpoint. A new node of the same type, which contains all the content at and after theoffsetpoint, is returned. If the original node had a parent node, the new node is inserted as the next sibling of the original node. When theoffsetis equal to the length of this node, the new node has no data. -
getWholeText
Returns all text ofTextnodes logically-adjacent text nodes to this node, concatenated in document order.- Specified by:
getWholeTextin interfaceText- Returns:
- the concatenated text
- Since:
- DOM Level 3
-
isElementContentWhitespace
public boolean isElementContentWhitespace()Returns whether this text node contains element content whitespace, often called "ignorable whitespace".- Specified by:
isElementContentWhitespacein interfaceText- Returns:
- true if whitespace in element content, false otherwise
- Since:
- DOM Level 3
-
replaceWholeText
Replaces the text of the current node and all logically-adjacent text nodes with the specified text. All logically-adjacent text nodes are removed including the current node unless it was the recipient of the replacement text.
This method returns the node which received the replacement text. The returned node is:-
null, when the replacement text is the empty string; - the current node, except when the current node is read-only;
-
a new
Textnode of the same type (TextorCDATASection) as the current node inserted at the location of the replacement.
For instance, in the above example callingreplaceWholeTexton theTextnode that contains "bar" with "yo" in argument results in the following:
Where the nodes to be removed are read-only descendants of anEntityReference, theEntityReferencemust be removed instead of the read-only nodes. If anyEntityReferenceto be removed has descendants that are notEntityReference,Text, orCDATASectionnodes, thereplaceWholeTextmethod must fail before performing any modification of the document, raising aDOMExceptionwith the codeNO_MODIFICATION_ALLOWED_ERR.
For instance, in the example below callingreplaceWholeTexton theTextnode that contains "bar" fails, because theEntityReferencenode "ent" contains anElementnode which cannot be removed.- Specified by:
replaceWholeTextin interfaceText- Parameters:
content- The content of the replacingTextnode.- Returns:
- The
Textnode created with the specified content. - Throws:
DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if one of theTextnodes being replaced is readonly.- Since:
- DOM Level 3
-
-