Class DomText

java.lang.Object
com.machinezoo.pushmode.dom.DomContent
com.machinezoo.pushmode.dom.DomText
All Implemented Interfaces:
Cloneable

@DraftTests public class DomText extends DomContent
Text node in PushMode DOM tree. Text nodes are immutable. In order to change the text, new DomText node must be created.

DomText, being immutable, is always safe to access by multiple threads.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    amp
    Unicode expansion of &.
    static final String
    Unicode expansion of '.
    static final String
    Unicode expansion of  .
    static final String
    Unicode expansion of  .
    static final String
    gt
    Unicode expansion of >.
    static final String
    lrm
    Unicode expansion of ‎.
    static final String
    lt
    Unicode expansion of <.
    static final String
    Unicode expansion of  .
    static final String
    Unicode expansion of ".
    static final String
    rlm
    Unicode expansion of ‏.
    static final String
    shy
    Unicode expansion of ­.
    static final String
    Unicode expansion of  .
    static final String
    zwj
    Unicode expansion of ‍.
    static final String
    Unicode expansion of ‌.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DomText(String text)
    Creates DOM text node.
  • Method Summary

    Modifier and Type
    Method
    Description
    clone()
    Clones the text node (no-op).
    boolean
    equals(Object object)
    Compares texts of two DomText nodes.
    freeze()
    Freezes this DOM tree node (no-op).
    int
    Computes hash code of the text node.
    text()
    Gets content of this text node.

    Methods inherited from class com.machinezoo.pushmode.dom.DomContent

    toString

    Methods inherited from class java.lang.Object

    finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • DomText

      public DomText(String text)
      Creates DOM text node. If the parameter is null, the created text node will contain an empty string.
      Parameters:
      text - content of the newly created text node
  • Method Details

    • text

      public String text()
      Gets content of this text node. Text is always non-null even if the constructor was called with null argument. If this is a descendant of DomElement or DomFragment, the text is guaranteed to be non-empty.
      Specified by:
      text in class DomContent
      Returns:
      content of this text node
    • clone

      public DomText clone()
      Clones the text node (no-op). Implementation of this method is required by parent DomContent. Since DomText is immutable, this method just returns this.
      Specified by:
      clone in class DomContent
      Returns:
      this
    • equals

      public boolean equals(Object object)
      Compares texts of two DomText nodes. If the other object is not a DomText node, this method returns false.
      Overrides:
      equals in class DomContent
      Parameters:
      object - object to compare this text node with
      Returns:
      true if the two text nodes are equal, false otherwise
    • hashCode

      public int hashCode()
      Computes hash code of the text node. The returned hash code is equal to the hash code of text().
      Overrides:
      hashCode in class DomContent
      Returns:
      hash code of the text node
    • freeze

      public DomText freeze()
      Freezes this DOM tree node (no-op). Since DomText is immutable by nature, this method has no effect. It is implemented, because it is required by parent DomContent.
      Specified by:
      freeze in class DomContent
      Returns:
      this