Package org.htmlunit.html

# Class DomCharacterData

java.lang.Object
org.htmlunit.html.DomNode
org.htmlunit.html.DomCharacterData

All Implemented Interfaces:
  `Serializable`, `Cloneable`, `CharacterData`, `Node`

Direct Known Subclasses:
  `DomComment`, `DomText`

public abstract class DomCharacterData extends DomNode implements CharacterData
Wrapper for the DOM node CharacterData.

See Also:
  - Serialized Form

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class org.htmlunit.html.DomNode

  `DomNode.ChildIterator, DomNode.DescendantDomElementsIterator, DomNode.DescendantDomNodesIterator, DomNode.DescendantElementsIterator<T extends DomNode>, DomNode.DescendantHtmlElementsIterator`

- ## Field Summary

  ### Fields inherited from class org.htmlunit.html.DomNode

  `PROPERTY_ELEMENT, READY_STATE_COMPLETE, READY_STATE_INTERACTIVE, READY_STATE_LOADED, READY_STATE_LOADING, READY_STATE_UNINITIALIZED`

  ### Fields inherited from interface org.w3c.dom.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

  Constructors
  Constructor
  Description
  `DomCharacterData(SgmlPage page, String data)`
  Creates an instance of DomCharacterData.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `appendData(String newData)`
  Appends a string to character data.
  `void`
  `deleteData(int offset, int count)`
  Deletes characters from character data.
  `String`
  `getCanonicalXPath()`
  Returns the canonical XPath expression which identifies this node, for instance `"/html/body/table[3]/tbody/tr[5]/td[2]/span/a[3]"`.
  `String`
  `getData()`
  Gets the data character string for this character data node.
  `int`
  `getLength()`
  Returns the number of characters in the character data.
  `String`
  `getNodeValue()`
  `void`
  `insertData(int offset, String arg)`
  Inserts a string into character data.
  `void`
  `replaceData(int offset, int count, String arg)`
  Replaces characters of character data with a string.
  `void`
  `setData(String data)`
  Sets the data character string for this character data node.
  `void`
  `setNodeValue(String newValue)`
  Sets the data character string to the new string.
  `void`
  `setTextContent(String textContent)`
  `String`
  `substringData(int offset, int count)`
  Extracts a substring from character data.

  ### Methods inherited from class org.htmlunit.html.DomNode

  `addCharacterDataChangeListener, addDomChangeListener, appendChild, asNormalizedText, asXml, basicRemove, checkChildHierarchy, cloneNode, closest, compareDocumentPosition, detach, fireCharacterDataChanged, fireNodeAdded, fireNodeDeleted, getAncestors, getAttributes, getBaseURI, getByXPath, getByXPath, getChildNodes, getChildren, getDescendants, getDomElementDescendants, getEndColumnNumber, getEndLineNumber, getFeature, getFirstByXPath, getFirstByXPath, getFirstChild, getHtmlElementDescendants, getHtmlPageOrNull, getIndex, getLastChild, getLocalName, getNamespaceURI, getNextElementSibling, getNextSibling, getOwnerDocument, getPage, getParentNode, getPrefix, getPreviousElementSibling, getPreviousSibling, getReadyState, getScriptableObject, getSelectorList, getStartColumnNumber, getStartLineNumber, getTextContent, getUserData, getVisibleText, handles, hasAttributes, hasChildNodes, hasFeature, insertBefore, insertBefore, isAncestorOf, isAncestorOfAny, isAttachedToPage, isDefaultNamespace, isDisplayed, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, mayBeDisplayed, normalize, notifyIncorrectness, onAddedToDocumentFragment, onAddedToPage, onAllChildrenAddedToPage, parseHtmlSnippet, printChildrenAsXml, printXml, processImportNode, querySelector, querySelectorAll, quietlyRemoveAndMoveChildrenTo, remove, removeAllChildren, removeCharacterDataChangeListener, removeChild, removeDomChangeListener, replace, replaceChild, setEndLocation, setParentNode, setReadyState, setScriptableObject, setStartLocation, setUserData`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface org.w3c.dom.Node

  `appendChild, cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getChildNodes, getFeature, getFirstChild, getLastChild, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, hasChildNodes, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeChild, replaceChild, setPrefix, setUserData`

- ## Constructor Details

  - ### DomCharacterData

    public DomCharacterData(SgmlPage page, String data)
    Creates an instance of DomCharacterData.
    Parameters:
      `page` - the Page that contains this element
      `data` - the data string wrapped by this node

- ## Method Details

  - ### getData

    public String getData()
    Gets the data character string for this character data node.
    Specified by:
      `getData` in interface `CharacterData`
    Returns:
      the data character string

  - ### setData

    public void setData(String data)
    Sets the data character string for this character data node.
    Specified by:
      `setData` in interface `CharacterData`
    Parameters:
      `data` - the new data character string

  - ### setNodeValue

    public void setNodeValue(String newValue)
    Sets the data character string to the new string.
    Specified by:
      `setNodeValue` in interface `Node`
    Parameters:
      `newValue` - the new string of data

  - ### setTextContent

    public void setTextContent(String textContent)
    Specified by:
      `setTextContent` in interface `Node`
    Overrides:
      `setTextContent` in class `DomNode`

  - ### getLength

    public int getLength()
    Returns the number of characters in the character data.
    Specified by:
      `getLength` in interface `CharacterData`
    Returns:
      the number of characters

  - ### appendData

    public void appendData(String newData)
    Appends a string to character data.
    Specified by:
      `appendData` in interface `CharacterData`
    Parameters:
      `newData` - the string to be appended to the character data

  - ### deleteData

    public void deleteData(int offset, int count)
    Deletes characters from character data.
    Specified by:
      `deleteData` in interface `CharacterData`
    Parameters:
      `offset` - the position of the first character to be deleted (can't be less than zero)
      `count` - the number of characters to be deleted, if less than zero leaves the first offset chars

  - ### insertData

    public void insertData(int offset, String arg)
    Inserts a string into character data.
    Specified by:
      `insertData` in interface `CharacterData`
    Parameters:
      `offset` - the position within the first character at which the string is to be inserted
      `arg` - the string to insert

  - ### replaceData

    public void replaceData(int offset, int count, String arg)
    Replaces characters of character data with a string.
    Specified by:
      `replaceData` in interface `CharacterData`
    Parameters:
      `offset` - the position within the first character at which the string is to be replaced
      `count` - the number of characters to be replaced
      `arg` - the string that replaces the count characters beginning at the character at offset

  - ### substringData

    public String substringData(int offset, int count)
    Extracts a substring from character data.
    Specified by:
      `substringData` in interface `CharacterData`
    Parameters:
      `offset` - the position of the first character to be extracted
      `count` - the number of characters to be extracted
    Returns:
      a string that consists of the count characters of the character data starting from the character at position offset

  - ### getNodeValue

    public String getNodeValue()
    Specified by:
      `getNodeValue` in interface `Node`
    Overrides:
      `getNodeValue` in class `DomNode`
    Returns:
      the string data held by this node

  - ### getCanonicalXPath

    public String getCanonicalXPath()

    Returns the canonical XPath expression which identifies this node, for instance `"/html/body/table[3]/tbody/tr[5]/td[2]/span/a[3]"`.

    WARNING: This sort of automated XPath expression is often quite bad at identifying a node, as it is highly sensitive to changes in the DOM tree.

    Overrides:
      `getCanonicalXPath` in class `DomNode`
    Returns:
      the canonical XPath expression which identifies this node
    See Also:
      - `DomNode.getByXPath(String)`