Package com.helger.html.hc.impl
Class AbstractHCHasChildrenMutable<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>,CHILDTYPE extends IHCNode>
- java.lang.Object
-
- com.helger.html.hc.impl.AbstractHCNode
-
- com.helger.html.hc.impl.AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>
-
- Type Parameters:
IMPLTYPE- Implementation typeCHILDTYPE- Child type
- All Implemented Interfaces:
com.helger.commons.hierarchy.IHasChildren<IHCNode>,com.helger.commons.hierarchy.IHasChildrenRecursive<IHCNode>,com.helger.commons.hierarchy.IHasChildrenSorted<IHCNode>,com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>,IHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>,IHCNode,Serializable
- Direct Known Subclasses:
AbstractHCNodeList
@NotThreadSafe public abstract class AbstractHCHasChildrenMutable<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>,CHILDTYPE extends IHCNode> extends AbstractHCNode implements IHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>
This class is an abstract HC node that represents a list of nodes without creating an HTML element by itself.- Author:
- Philip Helger
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractHCHasChildrenMutable()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IMPLTYPEaddChild(CHILDTYPE aChild)Add a new child.IMPLTYPEaddChildAt(int nIndex, CHILDTYPE aChild)protected voidafterAddChild(int nIndex, CHILDTYPE aChild)Callbackprotected voidafterRemoveChild(int nIndex, CHILDTYPE aChild)Invoked after an element was removed.protected voidbeforeAddChild(CHILDTYPE aChild)CallbackbooleancanConvertToMicroNode(IHCConversionSettingsToNode aConversionSettings)This method checks whether the node is suitable for conversion to anIMicroNode.protected com.helger.commons.collection.impl.ICommonsList<CHILDTYPE>directGetAllChildren()CHILDTYPEfindFirstChild(Predicate<? super IHCNode> aFilter)<DSTTYPE> DSTTYPEfindFirstChildMapped(Predicate<? super IHCNode> aFilter, Function<? super IHCNode,? extends DSTTYPE> aMapper)voidforAllChildren(Consumer<? super IHCNode> aConsumer)voidforAllChildren(Predicate<? super IHCNode> aFilter, Consumer<? super IHCNode> aConsumer)com.helger.commons.state.EContinueforAllChildrenBreakable(Function<? super IHCNode,com.helger.commons.state.EContinue> aConsumer)<DSTTYPE> voidforAllChildrenMapped(Predicate<? super IHCNode> aFilter, Function<? super IHCNode,? extends DSTTYPE> aMapper, Consumer<? super DSTTYPE> aConsumer)com.helger.commons.collection.impl.ICommonsList<CHILDTYPE>getAllChildren()HCNodeListgetAllChildrenAsNodeList()CHILDTYPEgetChildAtIndex(int nIndex)intgetChildCount()com.helger.commons.collection.impl.ICommonsIterable<CHILDTYPE>getChildren()protected com.helger.commons.collection.impl.ICommonsList<? extends CHILDTYPE>getChildrenFormEmitting(com.helger.commons.collection.impl.ICommonsList<CHILDTYPE> aChildren)Helper method that returns the elements in the correct order for emitting.CHILDTYPEgetFirstChild()CHILDTYPEgetLastChild()StringgetPlainText()booleanhasChildren()protected com.helger.xml.microdom.IMicroContainerinternalConvertToMicroNode(IHCConversionSettingsToNode aConversionSettings)IMPLTYPEremoveAllChildren()Remove all children of this object.IMPLTYPEremoveChild(CHILDTYPE aChild)Remove the passed direct child object.IMPLTYPEremoveChildAt(int nIndex)Remove the child at the specified index.IMPLTYPEsortAllChildren(Comparator<? super CHILDTYPE> aComparator)Sort all children with the passed comparatorStringtoString()-
Methods inherited from class com.helger.html.hc.impl.AbstractHCNode
consistencyCheck, convertToMicroNode, customizeNode, finalizeNodeState, getNodeState, internalSetNodeState, onConsistencyCheck, onCustomizeNode, onFinalizeNodeState, onRegisterExternalResources, registerExternalResources
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.helger.commons.hierarchy.IHasChildrenRecursive
forAllChildrenRecursive, forAllChildrenRecursive
-
Methods inherited from interface com.helger.html.hc.IHCHasChildrenMutable
addAndReturnChild, addAndReturnChildAt, addChildren, addChildren, addChildren, addChildrenAt, addChildrenAt, setChild
-
Methods inherited from interface com.helger.html.hc.IHCNode
consistencyCheck, convertToMicroNode, customizeNode, finalizeNodeState, getNodeState, registerExternalResources
-
-
-
-
Method Detail
-
hasChildren
public final boolean hasChildren()
- Specified by:
hasChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Overrides:
hasChildrenin classAbstractHCNode
-
beforeAddChild
@OverrideOnDemand protected void beforeAddChild(@Nonnull CHILDTYPE aChild)
Callback- Parameters:
aChild- The child that was added
-
afterAddChild
@OverrideOnDemand @OverridingMethodsMustInvokeSuper protected void afterAddChild(@Nonnegative int nIndex, @Nonnull CHILDTYPE aChild)
Callback- Parameters:
nIndex- Index where the child was added. Always ≥ 0.aChild- The child that was added
-
addChild
@Nonnull public final IMPLTYPE addChild(@Nullable CHILDTYPE aChild)
Description copied from interface:IHCHasChildrenMutableAdd a new child.- Specified by:
addChildin interfaceIHCHasChildrenMutable<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>,CHILDTYPE extends IHCNode>- Parameters:
aChild- Child to add. May benullin which case nothing happens.- Returns:
- this
-
addChildAt
@Nonnull public final IMPLTYPE addChildAt(@Nonnegative int nIndex, @Nullable CHILDTYPE aChild)
- Specified by:
addChildAtin interfaceIHCHasChildrenMutable<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>,CHILDTYPE extends IHCNode>- Parameters:
nIndex- The index to where the element should be inserted.aChild- Child to add. May benullin which case nothing happens.- Returns:
- this
-
afterRemoveChild
@OverrideOnDemand @OverridingMethodsMustInvokeSuper protected void afterRemoveChild(@Nonnegative int nIndex, @Nonnull CHILDTYPE aChild)
Invoked after an element was removed.- Parameters:
nIndex- The index where the element was removed from. Always ≥ 0. This is the OLD index and now contains a different or no child.aChild- The child that was removed. Nevernull.
-
removeChild
@Nonnull public final IMPLTYPE removeChild(@Nullable CHILDTYPE aChild)
Description copied from interface:IHCHasChildrenMutableRemove the passed direct child object.- Specified by:
removeChildin interfaceIHCHasChildrenMutable<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>,CHILDTYPE extends IHCNode>- Parameters:
aChild- The node to be removed. May benullin which case nothing happens.- Returns:
- this for chaining
-
removeChildAt
@Nonnull public final IMPLTYPE removeChildAt(@Nonnegative int nIndex)
Description copied from interface:IHCHasChildrenMutableRemove the child at the specified index.- Specified by:
removeChildAtin interfaceIHCHasChildrenMutable<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>,CHILDTYPE extends IHCNode>- Parameters:
nIndex- The index to use. Must be ≥ 0.- Returns:
- this for chaining
-
removeAllChildren
@Nonnull public final IMPLTYPE removeAllChildren()
Description copied from interface:IHCHasChildrenMutableRemove all children of this object.- Specified by:
removeAllChildrenin interfaceIHCHasChildrenMutable<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>,CHILDTYPE extends IHCNode>- Returns:
- this for chaining
-
getChildCount
@Nonnegative public final int getChildCount()
- Specified by:
getChildCountin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Overrides:
getChildCountin classAbstractHCNode
-
directGetAllChildren
@Nullable @ReturnsMutableObject("speed") protected final com.helger.commons.collection.impl.ICommonsList<CHILDTYPE> directGetAllChildren()
-
getAllChildren
@Nonnull @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<CHILDTYPE> getAllChildren()
- Specified by:
getAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Specified by:
getAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Overrides:
getAllChildrenin classAbstractHCNode
-
getChildren
@Nullable public final com.helger.commons.collection.impl.ICommonsIterable<CHILDTYPE> getChildren()
- Specified by:
getChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Overrides:
getChildrenin classAbstractHCNode
-
forAllChildren
public final void forAllChildren(@Nonnull Consumer<? super IHCNode> aConsumer)
- Specified by:
forAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Overrides:
forAllChildrenin classAbstractHCNode
-
forAllChildrenBreakable
@Nonnull public final com.helger.commons.state.EContinue forAllChildrenBreakable(@Nonnull Function<? super IHCNode,com.helger.commons.state.EContinue> aConsumer)
- Specified by:
forAllChildrenBreakablein interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Overrides:
forAllChildrenBreakablein classAbstractHCNode
-
forAllChildren
public final void forAllChildren(@Nonnull Predicate<? super IHCNode> aFilter, @Nonnull Consumer<? super IHCNode> aConsumer)
- Specified by:
forAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Overrides:
forAllChildrenin classAbstractHCNode
-
forAllChildrenMapped
public <DSTTYPE> void forAllChildrenMapped(@Nonnull Predicate<? super IHCNode> aFilter, @Nonnull Function<? super IHCNode,? extends DSTTYPE> aMapper, @Nonnull Consumer<? super DSTTYPE> aConsumer)
- Specified by:
forAllChildrenMappedin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Overrides:
forAllChildrenMappedin classAbstractHCNode
-
getChildAtIndex
@Nullable public final CHILDTYPE getChildAtIndex(@Nonnegative int nIndex)
- Specified by:
getChildAtIndexin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Overrides:
getChildAtIndexin classAbstractHCNode
-
getFirstChild
@Nullable public final CHILDTYPE getFirstChild()
- Specified by:
getFirstChildin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Overrides:
getFirstChildin classAbstractHCNode
-
findFirstChild
@Nullable public final CHILDTYPE findFirstChild(@Nonnull Predicate<? super IHCNode> aFilter)
- Specified by:
findFirstChildin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Overrides:
findFirstChildin classAbstractHCNode
-
findFirstChildMapped
@Nullable public final <DSTTYPE> DSTTYPE findFirstChildMapped(@Nonnull Predicate<? super IHCNode> aFilter, @Nonnull Function<? super IHCNode,? extends DSTTYPE> aMapper)
- Specified by:
findFirstChildMappedin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Overrides:
findFirstChildMappedin classAbstractHCNode
-
getLastChild
@Nullable public final CHILDTYPE getLastChild()
- Specified by:
getLastChildin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>>- Overrides:
getLastChildin classAbstractHCNode
-
sortAllChildren
@Nonnull public final IMPLTYPE sortAllChildren(@Nonnull Comparator<? super CHILDTYPE> aComparator)
Description copied from interface:IHCHasChildrenMutableSort all children with the passed comparator- Specified by:
sortAllChildrenin interfaceIHCHasChildrenMutable<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>,CHILDTYPE extends IHCNode>- Parameters:
aComparator- The comparator to be used. May not benull.- Returns:
- this for chaining
-
getAllChildrenAsNodeList
@Nonnull public final HCNodeList getAllChildrenAsNodeList()
- Specified by:
getAllChildrenAsNodeListin interfaceIHCHasChildrenMutable<IMPLTYPE extends AbstractHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>,CHILDTYPE extends IHCNode>- Returns:
- A new node list with all contained children. Never
nullbut maybe empty.
-
canConvertToMicroNode
@OverrideOnDemand @OverridingMethodsMustInvokeSuper public boolean canConvertToMicroNode(@Nonnull IHCConversionSettingsToNode aConversionSettings)
Description copied from interface:IHCNodeThis method checks whether the node is suitable for conversion to anIMicroNode. If this node cannot be converted, no child node will be converted as well!- Specified by:
canConvertToMicroNodein interfaceIHCNode- Overrides:
canConvertToMicroNodein classAbstractHCNode- Parameters:
aConversionSettings- The conversion settings to be used- Returns:
trueif the node can be converted to a node,falseotherwise.
-
getChildrenFormEmitting
@Nonnull @Nonempty @OverrideOnDemand protected com.helger.commons.collection.impl.ICommonsList<? extends CHILDTYPE> getChildrenFormEmitting(@Nonnull @Nonempty com.helger.commons.collection.impl.ICommonsList<CHILDTYPE> aChildren)
Helper method that returns the elements in the correct order for emitting. This can e.g. be used for sorting or ordering.- Parameters:
aChildren- The children to be emitted. Is a direct reference to the container where the children are stored. So handle with care!- Returns:
- The non-
nulllist with all child elements to be emitted.
-
internalConvertToMicroNode
@Nonnull @OverrideOnDemand @OverridingMethodsMustInvokeSuper protected com.helger.xml.microdom.IMicroContainer internalConvertToMicroNode(@Nonnull IHCConversionSettingsToNode aConversionSettings)
- Specified by:
internalConvertToMicroNodein classAbstractHCNode
-
getPlainText
@Nonnull public String getPlainText()
- Specified by:
getPlainTextin interfaceIHCNode- Overrides:
getPlainTextin classAbstractHCNode- Returns:
- The plain text representation of this text. May not be
null.
-
toString
public String toString()
- Overrides:
toStringin classAbstractHCNode
-
-