Class 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.

    • Constructor Detail

      • 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 Detail

      • 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