Class AbstractMicroNode

    • Constructor Detail

      • AbstractMicroNode

        public AbstractMicroNode()
    • Method Detail

      • onAppendChild

        @OverrideOnDemand
        protected void onAppendChild​(@Nonnull
                                     AbstractMicroNode aChildNode)
        Callback that is invoked once a child is to be appended.
        Parameters:
        aChildNode - The appended child node.
      • onInsertBefore

        @OverrideOnDemand
        protected void onInsertBefore​(@Nonnull
                                      AbstractMicroNode aChildNode,
                                      @Nonnull
                                      IMicroNode aSuccessor)
        Callback that is invoked once a child is to be inserted before another child.
        Parameters:
        aChildNode - The new child node to be inserted.
        aSuccessor - The node before which the new node will be inserted.
      • onInsertAfter

        @OverrideOnDemand
        protected void onInsertAfter​(@Nonnull
                                     AbstractMicroNode aChildNode,
                                     @Nonnull
                                     IMicroNode aPredecessor)
        Callback that is invoked once a child is to be inserted after another child.
        Parameters:
        aChildNode - The new child node to be inserted.
        aPredecessor - The node after which the new node will be inserted.
      • onInsertAtIndex

        @OverrideOnDemand
        protected void onInsertAtIndex​(@Nonnegative
                                       int nIndex,
                                       @Nonnull
                                       AbstractMicroNode aChildNode)
        Callback that is invoked once a child is to be inserted at the specified index.
        Parameters:
        nIndex - The index where the node should be inserted.
        aChildNode - The new child node to be inserted.
      • appendChild

        @Nullable
        public final <NODETYPE extends IMicroNode> NODETYPE appendChild​(@Nullable
                                                                        NODETYPE aChildNode)
        Description copied from interface: IMicroNode
        Append any child to the node.
        Specified by:
        appendChild in interface IMicroNode
        Type Parameters:
        NODETYPE - Parameter type == return type
        Parameters:
        aChildNode - The child node to append. May be null.
        Returns:
        The appended node, or null if the parameter was null.
      • insertBefore

        @Nullable
        public final <NODETYPE extends IMicroNode> NODETYPE insertBefore​(@Nullable
                                                                         NODETYPE aChildNode,
                                                                         @Nonnull
                                                                         IMicroNode aSuccessor)
        Description copied from interface: IMicroNode
        Insert an existing node before a certain child node of this.
        Specified by:
        insertBefore in interface IMicroNode
        Type Parameters:
        NODETYPE - Parameter type == return type
        Parameters:
        aChildNode - The new child node to be inserted.
        aSuccessor - The node before which the new node will be inserted.
        Returns:
        The newly inserted node
      • insertAfter

        @Nullable
        public final <NODETYPE extends IMicroNode> NODETYPE insertAfter​(@Nullable
                                                                        NODETYPE aChildNode,
                                                                        @Nonnull
                                                                        IMicroNode aPredecessor)
        Description copied from interface: IMicroNode
        Insert an existing node after a certain child node of this.
        Specified by:
        insertAfter in interface IMicroNode
        Type Parameters:
        NODETYPE - Parameter type == return type
        Parameters:
        aChildNode - The new child node to be inserted.
        aPredecessor - The node after which the new node will be inserted.
        Returns:
        The newly inserted node
      • insertAtIndex

        @Nullable
        public final <NODETYPE extends IMicroNode> NODETYPE insertAtIndex​(@Nonnegative
                                                                          int nIndex,
                                                                          @Nullable
                                                                          NODETYPE aChildNode)
        Description copied from interface: IMicroNode
        Insert an existing node as a child at the specified index.
        Specified by:
        insertAtIndex in interface IMicroNode
        Type Parameters:
        NODETYPE - Parameter type == return type
        Parameters:
        nIndex - The index to insert. Must be ≥ 0.
        aChildNode - The new child node to be inserted.
        Returns:
        The newly inserted node
      • onRemoveChild

        @OverrideOnDemand
        @Nonnull
        protected com.helger.commons.state.EChange onRemoveChild​(IMicroNode aChild)
        Callback when a child is removed.
        Parameters:
        aChild - The child that is removed.
        Returns:
        EChange.CHANGED if something changed
      • removeChild

        @Nonnull
        public final com.helger.commons.state.EChange removeChild​(@Nonnull
                                                                  IMicroNode aChild)
        Description copied from interface: IMicroNode
        Remove the passed child.
        Specified by:
        removeChild in interface IMicroNode
        Parameters:
        aChild - The child to be removed. May not be null.
        Returns:
        EChange.CHANGED if the child was successfully removed, EChange.UNCHANGED otherwise.
      • onRemoveChildAtIndex

        @OverrideOnDemand
        @Nonnull
        protected com.helger.commons.state.EChange onRemoveChildAtIndex​(int nIndex)
        Remove the child not at the specified index.
        Parameters:
        nIndex - The 0-based index of the item to be removed.
        Returns:
        EChange.CHANGED if the node was successfully removed, EChange.UNCHANGED otherwise.
      • removeChildAtIndex

        @Nonnull
        public final com.helger.commons.state.EChange removeChildAtIndex​(@Nonnegative
                                                                         int nIndex)
        Description copied from interface: IMicroNode
        Remove the child not at the specified index.
        Specified by:
        removeChildAtIndex in interface IMicroNode
        Parameters:
        nIndex - The 0-based index of the item to be removed.
        Returns:
        EChange.CHANGED if the node was successfully removed, EChange.UNCHANGED otherwise.
      • onRemoveAllChildren

        @OverrideOnDemand
        @Nonnull
        protected com.helger.commons.state.EChange onRemoveAllChildren()
        Remove all children from this node.
        Returns:
        EChange.CHANGED if at least one child was present, and was successfully removed, EChange.UNCHANGED otherwise.
      • removeAllChildren

        @Nonnull
        public final com.helger.commons.state.EChange removeAllChildren()
        Description copied from interface: IMicroNode
        Remove all children from this node.
        Specified by:
        removeAllChildren in interface IMicroNode
        Returns:
        EChange.CHANGED if at least one child was present, and was successfully removed, EChange.UNCHANGED otherwise.
      • hasChildren

        @OverrideOnDemand
        public boolean hasChildren()
        Specified by:
        hasChildren in interface com.helger.commons.hierarchy.IHasChildren<IMicroNode>
      • getAllChildren

        @OverrideOnDemand
        @Nullable
        public com.helger.commons.collection.impl.ICommonsList<IMicroNode> getAllChildren()
        Description copied from interface: IMicroNode
        Get a list of all direct child nodes.
        Specified by:
        getAllChildren in interface com.helger.commons.hierarchy.IHasChildren<IMicroNode>
        Specified by:
        getAllChildren in interface com.helger.commons.hierarchy.IHasChildrenSorted<IMicroNode>
        Specified by:
        getAllChildren in interface IMicroNode
        Returns:
        May be null if the node has no children.
      • getChildren

        @OverrideOnDemand
        @Nullable
        public com.helger.commons.collection.impl.ICommonsIterable<IMicroNode> getChildren()
        Specified by:
        getChildren in interface com.helger.commons.hierarchy.IHasChildren<IMicroNode>
      • forAllChildren

        public void forAllChildren​(@Nonnull
                                   Consumer<? super IMicroNode> aConsumer)
        Specified by:
        forAllChildren in interface com.helger.commons.hierarchy.IHasChildren<IMicroNode>
      • forAllChildrenBreakable

        @Nonnull
        public com.helger.commons.state.EContinue forAllChildrenBreakable​(@Nonnull
                                                                          Function<? super IMicroNode,​com.helger.commons.state.EContinue> aConsumer)
        Specified by:
        forAllChildrenBreakable in interface com.helger.commons.hierarchy.IHasChildren<IMicroNode>
      • getChildAtIndex

        @OverrideOnDemand
        @Nullable
        public IMicroNode getChildAtIndex​(@Nonnegative
                                          int nIndex)
        Specified by:
        getChildAtIndex in interface com.helger.commons.hierarchy.IHasChildrenSorted<IMicroNode>
      • getChildCount

        @OverrideOnDemand
        @Nonnegative
        public int getChildCount()
        Specified by:
        getChildCount in interface com.helger.commons.hierarchy.IHasChildren<IMicroNode>
      • getFirstChild

        @OverrideOnDemand
        @Nullable
        public IMicroNode getFirstChild()
        Specified by:
        getFirstChild in interface com.helger.commons.hierarchy.IHasChildrenSorted<IMicroNode>
        Specified by:
        getFirstChild in interface IMicroNode
        Returns:
        The first child node of this node, or null if this node has no children.
      • getLastChild

        @OverrideOnDemand
        @Nullable
        public IMicroNode getLastChild()
        Specified by:
        getLastChild in interface com.helger.commons.hierarchy.IHasChildrenSorted<IMicroNode>
        Specified by:
        getLastChild in interface IMicroNode
        Returns:
        The last child node of this node, or null if this node has no children.
      • getPreviousSibling

        @Nullable
        public final IMicroNode getPreviousSibling()
        Specified by:
        getPreviousSibling in interface IMicroNode
        Returns:
        The previous node on the same level as this node, or null if this node has no preceding siblings.
      • getNextSibling

        @Nullable
        public final IMicroNode getNextSibling()
        Specified by:
        getNextSibling in interface IMicroNode
        Returns:
        The next node on the same level as this node, or null if this node has no succeeding siblings.
      • hasParent

        public final boolean hasParent()
        Specified by:
        hasParent in interface com.helger.commons.hierarchy.IHasParent<IMicroNode>
        Specified by:
        hasParent in interface IMicroNode
        Returns:
        true if this node has a parent node assigned, false otherwise.
      • internalResetParentNode

        protected final void internalResetParentNode()
      • detachFromParent

        @Nonnull
        public final IMicroNode detachFromParent()
        Description copied from interface: IMicroNode
        Detach this node from the parent node so it can be inserted into another node without problems. Otherwise you would get an IllegalStateException if adding this node again to another parent since each node can only have one parent.
        Specified by:
        detachFromParent in interface IMicroNode
        Returns:
        this
      • isText

        public final boolean isText()
        Specified by:
        isText in interface IMicroNode
        Returns:
        true if this node can safely be casted to IMicroText.
      • isCDATA

        public final boolean isCDATA()
        Specified by:
        isCDATA in interface IMicroNode
        Returns:
        true if this node can safely be casted to IMicroCDATA.
      • isComment

        public final boolean isComment()
        Specified by:
        isComment in interface IMicroNode
        Returns:
        true if this node can safely be casted to IMicroComment.
      • isElement

        public final boolean isElement()
        Specified by:
        isElement in interface IMicroNode
        Returns:
        true if this node can safely be casted to IMicroElement.
      • registerEventTarget

        @Nonnull
        public com.helger.commons.state.EChange registerEventTarget​(@Nonnull
                                                                    EMicroEvent eEventType,
                                                                    @Nonnull
                                                                    IMicroEventTarget aTarget)
        Description copied from interface: IMicroNode
        Register a specific MicroDOM event listener. One event listener can only be attached once to an event!
        Specified by:
        registerEventTarget in interface IMicroNode
        Parameters:
        eEventType - The event type. May not be null.
        aTarget - The event target to be added. May not be null.
        Returns:
        EChange.CHANGED if the event listener was registered, EChange.UNCHANGED otherwise.
      • unregisterEventTarget

        @Nonnull
        public com.helger.commons.state.EChange unregisterEventTarget​(@Nonnull
                                                                      EMicroEvent eEventType,
                                                                      @Nonnull
                                                                      IMicroEventTarget aTarget)
        Description copied from interface: IMicroNode
        Unregister a specific MicroDOM event listener.
        Specified by:
        unregisterEventTarget in interface IMicroNode
        Parameters:
        eEventType - The event type. May not be null.
        aTarget - The event target to be added. May not be null.
        Returns:
        EChange.CHANGED if the event listener was unregistered, EChange.UNCHANGED otherwise.
      • getAllEventTargets

        @Nonnull
        @ReturnsMutableCopy
        public com.helger.commons.collection.impl.ICommonsMap<EMicroEvent,​com.helger.commons.callback.CallbackList<IMicroEventTarget>> getAllEventTargets()
        Specified by:
        getAllEventTargets in interface IMicroNode
        Returns:
        A map of all registered event targets. Never null.
      • getAllEventTargets

        @Nonnull
        @ReturnsMutableCopy
        public com.helger.commons.callback.CallbackList<IMicroEventTarget> getAllEventTargets​(@Nullable
                                                                                              EMicroEvent eEvent)
        Description copied from interface: IMicroNode
        Get all event targets for a certain event.
        Specified by:
        getAllEventTargets in interface IMicroNode
        Parameters:
        eEvent - The event to be queried. May be null.
        Returns:
        A map of all registered event targets. Never null.