Menu
pushmode.dom

Class DomContent

PushMode » API Reference » pushmode.dom

  • All Implemented Interfaces:
    Cloneable
    Direct Known Subclasses:
    DomContainer, DomText


    public abstract class DomContent
    extends Object
    implements Cloneable
    Base class for all PushMode DOM nodes that can be children of an element. This includes DomElement, DomFragment, and DomText.
    DOM nodes can be mutable (DomElement and DomFragment) or immutable (DomText). Mutable nodes can be frozen, which causes all mutating methods to throw. All in all, DOM nodes can be in three states: immutable, mutable, and frozen. Immutable state cannot be changed. Transition from mutable to frozen state is performed by freeze(). Transition from frozen to mutable state is performed by clone().
    All classes inheriting from DomContent support equals(Object) and hashCode(). HTML representation of the node can be obtained from toString().
    Thread-safety:
    Immutable and frozen nodes are thread-safe. Mutable nodes can be only used by single thread at a time.
    • Method Detail

      • clone

        public abstract DomContent clone()
        Creates mutable deep clone of this node. If this node is immutable, this method just returns this. For frozen and mutable nodes, this method returns mutable deep clone that is completely independent of this node.
        Overrides:
        clone in class Object
        Returns:
        Deep mutable clone. Returns this for immutable nodes.
        Thread-safety:
        This method can be executed concurrently with other read-only operations on the same node. If this node is modified while being cloned, some descendants in the clone might be missing or duplicated, but this method will never throw, this node is never damaged, and the cloned node will be always internally consistent.
      • freeze

        public abstract DomContent freeze()
        Creates frozen deep clone of this node. Mutating methods throw when executed on frozen node. Frozen nodes can be safely shared by all threads. Freezing is recursive. Frozen nodes therefore cannot contain mutable nodes. If this node is immutable (i.e. DomText) or already frozen, this method just returns this.
        Freezing applies several transformations to the node, so that these transformations don't have to be performed repeatedly during rendering. While DomFragment itself can be frozen, frozen DOM nodes cannot contain any DomFragment descendant. For this reason, the returned frozen node has all DomFragment descendants inlined into their respective parents. Freezing a node causes all consecutive text nodes to be concatenated into single node. Empty text nodes are removed. Listeners attached to descendants of type DomElement are discarded if the element has null DomElement.id(). All internal arrays are compacted, so that the frozen DOM tree takes up minimum amount of memory. None of these transformations modifies the original node in any way.
        Returns:
        Deep frozen clone. Returns this for frozen and immutable nodes.
        Thread-safety:
        This method can be executed concurrently with other read-only operations on the same node. If this node is modified while being cloned, some descendants in the clone might be missing or duplicated, but this method will never throw, this node is never damaged, and the cloned node will be always internally consistent.
      • equals

        public boolean equals(Object obj)
        Compares this node with another DOM node for equality.
        Overrides:
        equals in class Object
        Parameters:
        obj -
        Returns:
        True if the two nodes are equal.
      • hashCode

        public int hashCode()
        Computes deep hash code of the node.
        Overrides:
        hashCode in class Object
        Returns:
        Hash code of the node.
      • toString

        public String toString()
        Serialized HTML code for this node.
        Overrides:
        toString in class Object
        Returns:
        HTML representation of this node.