Menu
pushmode.dom

Class DomContainer

PushMode » API Reference » pushmode.dom

    • Method Detail

      • clone

        public abstract DomContainer clone()
        Creates mutable deep clone of this node. All child nodes are cloned recursively. The clone is completely independent of this node.
        Specified by:
        clone in class DomContent
        Returns:
        Deep mutable clone.
        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.
      • children

        public List<DomContent> children()
        Lists all children in this node. The list is a view of the internal representation of the child list. It will reflect changes made through other methods of this class. Conversely, changes made through the returned list will be visible through other methods of this class.
        The returned List has a few peculiar behaviors. When items are added through any of the List methods, null values are ignored. When items are replaced, null replacement will trigger NullPointerException. List's Iterator will also exhibit these peculiarities when used to modify the list. If this node is frozen, all write methods on the List will throw IllegalStateException. Method List.subList(int, int) will return unmodifiable list and its complexity is O(n). Otherwise the returned List behaves normally.
        Returns:
        List of all children.
      • freeze

        public DomContainer freeze()
        Creates frozen deep clone of this node. Mutating methods throw IllegalStateException when executed on frozen node. Frozen nodes can be safely shared by all threads. Freezing is recursive. Frozen nodes therefore cannot contain mutable nodes.
        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. If the resulting text node is empty, it is 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.
        Specified by:
        freeze in class DomContent
        Returns:
        Deep frozen clone. Returns this if this node is already frozen.
        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 object)
        Compares content of two DomContainer nodes. If the two nodes are of different type (i.e. one is DomElement and the other one DomFragment), this method returns false. If one of the nodes is frozen and the other is not, this method returns false. Children of both containers are compared recursively by calling their DomContent.equals(Object) methods.
        Overrides:
        equals in class DomContent
        Parameters:
        object - Object to compare this node with.
        Returns:
        True if the two nodes are equal.
      • hashCode

        public int hashCode()
        Computes hash code of the node. It is computed by combining hash codes of all children.
        Overrides:
        hashCode in class DomContent
        Returns:
        Node's hash code.
      • add

        public <C extends DomContentDomContainer add(C... children)
        Adds all nodes in an array to the list of children.
        Parameters:
        children - Array of child nodes to add. This method has no effect if the parameter is null. Array items that are null are skipped.
        Returns:
        this
        Throws:
        IllegalStateException - This node is frozen.
        See Also:
        add(DomContent)
      • text

        public DomContainer text(String text)
        Adds literal text to the list of children. The text is first wrapped in DomText.
        Parameters:
        text - Text to add. This method has no effect if the text is null or empty.
        Returns:
        this
        Throws:
        IllegalStateException - This node is frozen.
        See Also:
        add(DomContent)