Class AbstractTextual

java.lang.Object
org.zkoss.idom.impl.AbstractItem
org.zkoss.idom.impl.AbstractTextual
All Implemented Interfaces:
Serializable, Cloneable, CharacterData, Node, Item, Textual
Direct Known Subclasses:
Binary, CData, Comment, Text

public abstract class AbstractTextual extends AbstractItem implements Textual, 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:
  • Field Details

    • _text

      protected String _text
      The text.
  • Constructor Details

    • AbstractTextual

      protected AbstractTextual(String text)
      Constructor.
    • AbstractTextual

      protected AbstractTextual()
      Constructor.
  • Method Details

    • 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(String text)
      Checks whether the text is valid. It is usually overridden by the deriving classes to check more specifically.
    • getText

      public 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(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 CharacterData
    • getData

      public final String getData()
      Specified by:
      getData in interface CharacterData
    • setData

      public final void setData(String data)
      Specified by:
      setData in interface CharacterData
    • substringData

      public final String substringData(int offset, int count)
      Specified by:
      substringData in interface CharacterData
    • appendData

      public final void appendData(String newData)
      Specified by:
      appendData in interface CharacterData
    • insertData

      public final void insertData(int offset, String arg)
      Specified by:
      insertData in interface CharacterData
    • deleteData

      public final void deleteData(int offset, int count)
      Specified by:
      deleteData in interface CharacterData
    • replaceData

      public final void replaceData(int offset, int count, String arg)
      Specified by:
      replaceData in interface CharacterData
    • splitText

      public final Text splitText(int offset)
    • isElementContentWhitespace

      public boolean isElementContentWhitespace()
    • getWholeText

      public String getWholeText()
    • replaceWholeText

      public Text replaceWholeText(String content) throws DOMException
      Throws:
      DOMException
    • getTextContent

      public String getTextContent()
      Specified by:
      getTextContent in interface Node
      Overrides:
      getTextContent in class AbstractItem
    • toString

      public String toString()
      Gets the textual representation for debug.
      Overrides:
      toString in class Object