Package com.helger.xml.microdom
Class AbstractMicroNodeWithChildren
java.lang.Object
com.helger.xml.microdom.AbstractMicroNode
com.helger.xml.microdom.AbstractMicroNodeWithChildren
- All Implemented Interfaces:
com.helger.commons.hierarchy.IHasChildren<IMicroNode>,com.helger.commons.hierarchy.IHasChildrenRecursive<IMicroNode>,com.helger.commons.hierarchy.IHasChildrenSorted<IMicroNode>,com.helger.commons.hierarchy.IHasParent<IMicroNode>,com.helger.commons.lang.ICloneable<IMicroNode>,IMicroNode,IMicroNodeWithChildren
- Direct Known Subclasses:
MicroContainer,MicroDocument,MicroElement
public abstract class AbstractMicroNodeWithChildren
extends AbstractMicroNode
implements IMicroNodeWithChildren
Basic implementation class for the micro document object model. It overrides
all methods required for correct parent/child handling.
- Author:
- Philip Helger
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsAnyChild(Predicate<? super IMicroNode> aFilter) Check if any direct child matching the provided filter is contained.protected final com.helger.commons.collection.impl.ICommonsList<IMicroNode>final IMicroNodefindFirstChild(Predicate<? super IMicroNode> aFilter) final <DSTTYPE> DSTTYPEfindFirstChildMapped(Predicate<? super IMicroNode> aFilter, Function<? super IMicroNode, ? extends DSTTYPE> aMapper) final voidforAllChildren(Consumer<? super IMicroNode> aConsumer) final voidforAllChildren(Predicate<? super IMicroNode> aFilter, Consumer<? super IMicroNode> aConsumer) com.helger.commons.state.EContinueforAllChildrenBreakable(Function<? super IMicroNode, com.helger.commons.state.EContinue> aConsumer) final <DSTTYPE> voidforAllChildrenMapped(Predicate<? super IMicroNode> aFilter, Function<? super IMicroNode, ? extends DSTTYPE> aMapper, Consumer<? super DSTTYPE> aConsumer) final com.helger.commons.collection.impl.ICommonsList<IMicroNode>Get a list of all direct child nodes.final IMicroNodegetChildAtIndex(int nIndex) final intfinal com.helger.commons.collection.impl.ICommonsIterable<IMicroNode>final IMicroNodefinal IMicroNodeGet the concatenated text content of all directIMicroTextchild nodes of this element.<DSTTYPE> DSTTYPEgetTextContentWithConversion(Class<DSTTYPE> aDstClass) Get the concatenated text content of all directIMicroTextchild nodes of this element.final booleanbooleanAs instances of this class may not implement equals/hashCode we need a way to determine, if 2 nodes are equal by content.protected voidonAppendChild(AbstractMicroNode aChildNode) Callback that is invoked once a child is to be appended.protected final voidonInsertAfter(AbstractMicroNode aChildNode, IMicroNode aPredecessor) Callback that is invoked once a child is to be inserted after another child.protected final voidonInsertAtIndex(int nIndex, AbstractMicroNode aChildNode) Callback that is invoked once a child is to be inserted at the specified index.protected final voidonInsertBefore(AbstractMicroNode aChildNode, IMicroNode aSuccessor) Callback that is invoked once a child is to be inserted before another child.protected final com.helger.commons.state.EChangeRemove all children from this node.protected final com.helger.commons.state.EChangeonRemoveChild(IMicroNode aChildNode) Callback when a child is removed.protected final com.helger.commons.state.EChangeonRemoveChildAtIndex(int nIndex) Remove the child not at the specified index.toString()Methods inherited from class com.helger.xml.microdom.AbstractMicroNode
appendChild, detachFromParent, findParentElement, getAllEventTargets, getAllEventTargets, getNextSibling, getParent, getPreviousSibling, hasParent, insertAfter, insertAtIndex, insertBefore, internalResetParentNode, internalSetParentNode, internalTriggerEvent, isCDATA, isComment, isContainer, isDocument, isDocumentType, isElement, isEntityReference, isProcessingInstruction, isText, onEvent, registerEventTarget, removeAllChildren, removeChild, removeChildAtIndex, unregisterEventTargetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.helger.commons.hierarchy.IHasChildren
hasNoChildrenMethods inherited from interface com.helger.commons.hierarchy.IHasChildrenRecursive
forAllChildrenRecursive, forAllChildrenRecursiveMethods inherited from interface com.helger.xml.microdom.IMicroNode
appendCDATA, appendCDATA, appendCDATA, appendCDATAWithConversion, appendChild, appendChildren, appendChildren, appendComment, appendComment, appendComment, appendCommentWithConversion, appendContainer, appendElement, appendElement, appendEntityReference, appendIgnorableWhitespaceText, appendIgnorableWhitespaceText, appendIgnorableWhitespaceText, appendProcessingInstruction, appendText, appendText, appendText, appendTextWithConversion, detachFromParent, findParentElement, getAllChildrenRecursive, getAllEventTargets, getAllEventTargets, getNextSibling, getNodeName, getNodeValue, getParent, getParentElementWithName, getParentElementWithName, getPreviousSibling, getType, hasParent, insertAfter, insertAtIndex, insertBefore, isCDATA, isComment, isContainer, isDocument, isDocumentType, isElement, isEntityReference, isProcessingInstruction, isText, registerEventTarget, removeAllChildren, removeChild, removeChildAtIndex, replaceChild, unregisterEventTargetMethods inherited from interface com.helger.xml.microdom.IMicroNodeWithChildren
getClone, getTextContentTrimmed
-
Constructor Details
-
AbstractMicroNodeWithChildren
public AbstractMicroNodeWithChildren()
-
-
Method Details
-
directGetAllChildren
@Nullable @ReturnsMutableObject("efficient access") protected final com.helger.commons.collection.impl.ICommonsList<IMicroNode> directGetAllChildren()- Returns:
- The writable list of all child nodes - handle with care. May be
null.
-
onAppendChild
Description copied from class:AbstractMicroNodeCallback that is invoked once a child is to be appended.- Overrides:
onAppendChildin classAbstractMicroNode- Parameters:
aChildNode- The appended child node.
-
onInsertBefore
protected final void onInsertBefore(@Nonnull AbstractMicroNode aChildNode, @Nonnull IMicroNode aSuccessor) Description copied from class:AbstractMicroNodeCallback that is invoked once a child is to be inserted before another child.- Overrides:
onInsertBeforein classAbstractMicroNode- Parameters:
aChildNode- The new child node to be inserted.aSuccessor- The node before which the new node will be inserted.
-
onInsertAfter
protected final void onInsertAfter(@Nonnull AbstractMicroNode aChildNode, @Nonnull IMicroNode aPredecessor) Description copied from class:AbstractMicroNodeCallback that is invoked once a child is to be inserted after another child.- Overrides:
onInsertAfterin classAbstractMicroNode- Parameters:
aChildNode- The new child node to be inserted.aPredecessor- The node after which the new node will be inserted.
-
onInsertAtIndex
protected final void onInsertAtIndex(@Nonnegative int nIndex, @Nonnull AbstractMicroNode aChildNode) Description copied from class:AbstractMicroNodeCallback that is invoked once a child is to be inserted at the specified index.- Overrides:
onInsertAtIndexin classAbstractMicroNode- Parameters:
nIndex- The index where the node should be inserted.aChildNode- The new child node to be inserted.
-
onRemoveChild
@Nonnull protected final com.helger.commons.state.EChange onRemoveChild(@Nonnull IMicroNode aChildNode) Description copied from class:AbstractMicroNodeCallback when a child is removed.- Overrides:
onRemoveChildin classAbstractMicroNode- Parameters:
aChildNode- The child that is removed.- Returns:
EChange.CHANGEDif something changed
-
onRemoveChildAtIndex
@Nonnull protected final com.helger.commons.state.EChange onRemoveChildAtIndex(@Nonnegative int nIndex) Description copied from class:AbstractMicroNodeRemove the child not at the specified index.- Overrides:
onRemoveChildAtIndexin classAbstractMicroNode- Parameters:
nIndex- The 0-based index of the item to be removed.- Returns:
EChange.CHANGEDif the node was successfully removed,EChange.UNCHANGEDotherwise.
-
onRemoveAllChildren
Description copied from class:AbstractMicroNodeRemove all children from this node.- Overrides:
onRemoveAllChildrenin classAbstractMicroNode- Returns:
EChange.CHANGEDif at least one child was present, and was successfully removed,EChange.UNCHANGEDotherwise.
-
hasChildren
public final boolean hasChildren()- Specified by:
hasChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMicroNode>- Overrides:
hasChildrenin classAbstractMicroNode
-
getAllChildren
@Nullable @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<IMicroNode> getAllChildren()Description copied from interface:IMicroNodeGet a list of all direct child nodes.- Specified by:
getAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMicroNode>- Specified by:
getAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMicroNode>- Specified by:
getAllChildrenin interfaceIMicroNode- Overrides:
getAllChildrenin classAbstractMicroNode- Returns:
- May be
nullif the node has no children.
-
getChildren
@Nullable public final com.helger.commons.collection.impl.ICommonsIterable<IMicroNode> getChildren()- Specified by:
getChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMicroNode>- Overrides:
getChildrenin classAbstractMicroNode
-
forAllChildren
- Specified by:
forAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMicroNode>- Overrides:
forAllChildrenin classAbstractMicroNode
-
forAllChildrenBreakable
@Nonnull public com.helger.commons.state.EContinue forAllChildrenBreakable(@Nonnull Function<? super IMicroNode, com.helger.commons.state.EContinue> aConsumer) - Specified by:
forAllChildrenBreakablein interfacecom.helger.commons.hierarchy.IHasChildren<IMicroNode>- Overrides:
forAllChildrenBreakablein classAbstractMicroNode
-
forAllChildren
public final void forAllChildren(@Nonnull Predicate<? super IMicroNode> aFilter, @Nonnull Consumer<? super IMicroNode> aConsumer) - Specified by:
forAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMicroNode>- Overrides:
forAllChildrenin classAbstractMicroNode
-
forAllChildrenMapped
public final <DSTTYPE> void forAllChildrenMapped(@Nonnull Predicate<? super IMicroNode> aFilter, @Nonnull Function<? super IMicroNode, ? extends DSTTYPE> aMapper, @Nonnull Consumer<? super DSTTYPE> aConsumer) - Specified by:
forAllChildrenMappedin interfacecom.helger.commons.hierarchy.IHasChildren<IMicroNode>- Overrides:
forAllChildrenMappedin classAbstractMicroNode
-
containsAnyChild
Description copied from interface:IMicroNodeCheck if any direct child matching the provided filter is contained.- Specified by:
containsAnyChildin interfaceIMicroNode- Parameters:
aFilter- The filter that is applied to all child nodes. May not benull.- Returns:
trueif any child matching the provided filter is contained,falseotherwise.
-
getChildAtIndex
- Specified by:
getChildAtIndexin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMicroNode>- Overrides:
getChildAtIndexin classAbstractMicroNode
-
getChildCount
public final int getChildCount()- Specified by:
getChildCountin interfacecom.helger.commons.hierarchy.IHasChildren<IMicroNode>- Overrides:
getChildCountin classAbstractMicroNode
-
getFirstChild
- Specified by:
getFirstChildin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMicroNode>- Specified by:
getFirstChildin interfaceIMicroNode- Overrides:
getFirstChildin classAbstractMicroNode- Returns:
- The first child node of this node, or
nullif this node has no children.
-
findFirstChild
- Specified by:
findFirstChildin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMicroNode>- Overrides:
findFirstChildin classAbstractMicroNode
-
findFirstChildMapped
@Nullable public final <DSTTYPE> DSTTYPE findFirstChildMapped(@Nonnull Predicate<? super IMicroNode> aFilter, @Nonnull Function<? super IMicroNode, ? extends DSTTYPE> aMapper) - Specified by:
findFirstChildMappedin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMicroNode>- Overrides:
findFirstChildMappedin classAbstractMicroNode
-
getLastChild
- Specified by:
getLastChildin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMicroNode>- Specified by:
getLastChildin interfaceIMicroNode- Overrides:
getLastChildin classAbstractMicroNode- Returns:
- The last child node of this node, or
nullif this node has no children.
-
getTextContent
Description copied from interface:IMicroNodeWithChildrenGet the concatenated text content of all directIMicroTextchild nodes of this element.- Specified by:
getTextContentin interfaceIMicroNodeWithChildren- Returns:
nullif the element contains no text node as child
-
getTextContentWithConversion
Description copied from interface:IMicroNodeWithChildrenGet the concatenated text content of all directIMicroTextchild nodes of this element. The value is converted via theTypeConverterto the desired destination class.- Specified by:
getTextContentWithConversionin interfaceIMicroNodeWithChildren- Type Parameters:
DSTTYPE- The destination type to convert the String textContent to.- Parameters:
aDstClass- The destination class to which the text content should be converted.- Returns:
nullif the element contains no text node as child
-
isEqualContent
Description copied from interface:IMicroNodeAs instances of this class may not implement equals/hashCode we need a way to determine, if 2 nodes are equal by content.- Specified by:
isEqualContentin interfaceIMicroNode- Parameters:
o- The node to compare to this.- Returns:
trueif the nodes are of the same type and the same content,falseotherwise.
-
toString
- Overrides:
toStringin classAbstractMicroNode
-