Package org.zkoss.idom.impl

## Class AbstractTextual

- java.lang.Object
- - org.zkoss.idom.impl.AbstractItem
  - - org.zkoss.idom.impl.AbstractTextual

- All Implemented Interfaces:
    `java.io.Serializable`, `java.lang.Cloneable`, `org.w3c.dom.CharacterData`, `org.w3c.dom.Node`, `Item`, `Textual`
  Direct Known Subclasses:
    `Binary`, `CData`, `Comment`, `Text`

      public abstract class AbstractTextual
      extends AbstractItem
      implements Textual, org.w3c.dom.CharacterData

  Represents a textual item.

  Note: any deriving class's getText shall not return null.

  Element.getText uses this class's isPartOfParentText to know whether a child's text shall be concatenated.

  Author:
    tomyeh
  See Also:
    `Element`, Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected java.lang.String` | `_text` | The text.

    - ### Fields inherited from interface org.zkoss.idom.Item

      `FIND_BY_PREFIX, FIND_BY_REGEX, FIND_BY_TAGNAME, FIND_IGNORE_CASE, FIND_RECURSIVE`

    - ### 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
    Modifier | Constructor | Description
    --- | --- | ---
    `protected` | `AbstractTextual()` | Constructor.
    `protected` | `AbstractTextual​(java.lang.String text)` | Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `appendData​(java.lang.String newData)` |
    `protected void` | `checkText​(java.lang.String text)` | Checks whether the text is valid.
    `void` | `deleteData​(int offset, int count)` |
    `java.lang.String` | `getData()` |
    `int` | `getLength()` |
    `java.lang.String` | `getText()` | Gets the text of this item, or null if it is neither `Textual` nor `Element`.
    `java.lang.String` | `getTextContent()` |
    `java.lang.String` | `getWholeText()` |
    `void` | `insertData​(int offset, java.lang.String arg)` |
    `boolean` | `isCoalesceable()` | Returns true if this textual object is allowed to be coalesced with its siblings with the same type (class).
    `boolean` | `isElementContentWhitespace()` |
    `boolean` | `isPartOfParentText()` | Returns true if this text object is part of the parent's text.
    `void` | `replaceData​(int offset, int count, java.lang.String arg)` |
    `org.w3c.dom.Text` | `replaceWholeText​(java.lang.String content)` |
    `void` | `setData​(java.lang.String data)` |
    `void` | `setText​(java.lang.String text)` | Sets the text of this item.
    `Textual` | `split​(int offset)` | Splits at the specified offset into two Textual objects.
    `org.w3c.dom.Text` | `splitText​(int offset)` |
    `java.lang.String` | `substringData​(int offset, int count)` |
    `java.lang.String` | `toString()` | Gets the textual representation for debug.

    - ### Methods inherited from class org.zkoss.idom.impl.AbstractItem

      `appendChild, clone, cloneNode, compareDocumentPosition, detach, equals, getAttributes, getBaseURI, getChildNodes, getDocument, getFeature, getFirstChild, getLastChild, getLocalName, getLocator, getNamespaceURI, getNextSibling, getNodeName, getNodeValue, getOwnerDocument, getParent, getParentNode, getPrefix, getPreviousSibling, getUserData, hasAttributes, hasChildNodes, hashCode, insertBefore, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, match, normalize, removeChild, replaceChild, setLocator, setName, setNodeValue, setParent, setPrefix, setTextContent, setUserData`

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

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.zkoss.idom.Item

      `getName`

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

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

- - ### Field Detail

    - #### _text

          protected java.lang.String _text

      The text.

  - ### Constructor Detail

    - #### AbstractTextual

          protected AbstractTextual​(java.lang.String text)

      Constructor.

    - #### AbstractTextual

          protected AbstractTextual()

      Constructor.

  - ### Method Detail

    - #### isPartOfParentText

          public boolean isPartOfParentText()

      Returns true if this text object is part of the parent's text. Default: true.
      Specified by:
        `isPartOfParentText` in interface `Textual`

    - #### isCoalesceable

          public boolean isCoalesceable()

      Returns true if this textual object is allowed to be coalesced with its siblings with the same type (class). It is used by Group.coalesce.

      Default: false. Right now only Text override it to true.

      Specified by:
        `isCoalesceable` in interface `Textual`

    - #### split

          public Textual split​(int offset)

      Description copied from interface: `Textual`
      Splits at the specified offset into two Textual objects. The new textual object is inserted right after this one.
      Specified by:
        `split` in interface `Textual`
      Returns:
        the new textual object; null if offset is no less than length

    - #### checkText

          protected void checkText​(java.lang.String text)

      Checks whether the text is valid. It is usually overridden by the deriving classes to check more specifically.

    - #### getText

          public java.lang.String getText()

      Description copied from interface: `Item`
      Gets the text of this item, or null if it is neither `Textual` nor `Element`. For Element, the text is the concatenation of all its textual children, including Text, CDATA, and Binary.

      Besides String-type value, some item, e.g., Binary, allows any type of objects. Caller could test whether a item implements the Binable interface, and use Binable.getValue instead. For binable vertices, getText is actually getValue().toString().

      The returned value is neither trimmed nor normalized.

      Specified by:
        `getText` in interface `Item`
      Overrides:
        `getText` in class `AbstractItem`

    - #### setText

          public void setText​(java.lang.String text)

      Description copied from interface: `Item`
      Sets the text of this item.
      Specified by:
        `setText` in interface `Item`
      Overrides:
        `setText` in class `AbstractItem`

    - #### getLength

          public final int getLength()

      Specified by:
        `getLength` in interface `org.w3c.dom.CharacterData`

    - #### getData

          public final java.lang.String getData()

      Specified by:
        `getData` in interface `org.w3c.dom.CharacterData`

    - #### setData

          public final void setData​(java.lang.String data)

      Specified by:
        `setData` in interface `org.w3c.dom.CharacterData`

    - #### substringData

          public final java.lang.String substringData​(int offset,
                                                      int count)

      Specified by:
        `substringData` in interface `org.w3c.dom.CharacterData`

    - #### appendData

          public final void appendData​(java.lang.String newData)

      Specified by:
        `appendData` in interface `org.w3c.dom.CharacterData`

    - #### insertData

          public final void insertData​(int offset,
                                       java.lang.String arg)

      Specified by:
        `insertData` in interface `org.w3c.dom.CharacterData`

    - #### deleteData

          public final void deleteData​(int offset,
                                       int count)

      Specified by:
        `deleteData` in interface `org.w3c.dom.CharacterData`

    - #### replaceData

          public final void replaceData​(int offset,
                                        int count,
                                        java.lang.String arg)

      Specified by:
        `replaceData` in interface `org.w3c.dom.CharacterData`

    - #### splitText

          public final org.w3c.dom.Text splitText​(int offset)

    - #### isElementContentWhitespace

          public boolean isElementContentWhitespace()

    - #### getWholeText

          public java.lang.String getWholeText()

    - #### replaceWholeText

          public org.w3c.dom.Text replaceWholeText​(java.lang.String content)
                                            throws DOMException

      Throws:
        `DOMException`

    - #### getTextContent

          public java.lang.String getTextContent()

      Specified by:
        `getTextContent` in interface `org.w3c.dom.Node`
      Overrides:
        `getTextContent` in class `AbstractItem`

    - #### toString

          public java.lang.String toString()

      Gets the textual representation for debug.
      Overrides:
        `toString` in class `java.lang.Object`