Package com.helger.html.hc.html
Class AbstractHCElementWithInternalChildren<IMPLTYPE extends AbstractHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>,CHILDTYPE extends IHCNode>
- java.lang.Object
-
- com.helger.html.hc.impl.AbstractHCNode
-
- com.helger.html.hc.html.AbstractHCElement<IMPLTYPE>
-
- com.helger.html.hc.html.AbstractHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>
-
- Type Parameters:
IMPLTYPE- Implementation typeCHILDTYPE- Contained 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>,IHCElement<IMPLTYPE>,IHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>,IHCHasCSSClasses<IMPLTYPE>,IHCHasCSSStyles<IMPLTYPE>,IHCHasChildrenMutable<IMPLTYPE,CHILDTYPE>,IHCHasID<IMPLTYPE>,IHCNode,Serializable
- Direct Known Subclasses:
AbstractHCElementWithChildren,AbstractHCList,AbstractHCMediaElement,AbstractHCTablePart,HCColGroup,HCDL,HCOptGroup,HCOption,HCRow,HCRuby
@NotThreadSafe public abstract class AbstractHCElementWithInternalChildren<IMPLTYPE extends AbstractHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>,CHILDTYPE extends IHCNode> extends AbstractHCElement<IMPLTYPE> implements IHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>
Base class for elements with special children.- Author:
- Philip Helger
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class com.helger.html.hc.html.AbstractHCElement
DEFAULT_HIDDEN, DEFAULT_SPELLCHECK, DEFAULT_TRANSLATE, DEFAULT_UNFOCUSABLE
-
Fields inherited from interface com.helger.html.hc.html.IHCElement
DEFAULT_TABINDEX
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractHCElementWithInternalChildren(EHTMLElement eElement)
-
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.com.helger.commons.collection.impl.ICommonsList<CHILDTYPE>children()protected voidfillMicroElement(com.helger.xml.microdom.IMicroElement aElement, IHCConversionSettingsToNode aConversionSettings)Set all attributes and child elements of this objectCHILDTYPEfindFirstChild(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()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.html.AbstractHCElement
addClass, addEventHandler, addStyle, containsClass, containsEventHandler, containsStyle, createMicroElement, customAttrs, finishMicroElement, getAccessKey, getAllClasses, getAllClassesAsString, getAllClassNames, getAllStyles, getAllStylesAsString, getAllStyleValues, getContentEditable, getDirection, getDraggable, getElement, getEventHandler, getEventMap, getID, getLanguage, getRole, getStyleValue, getTabIndex, getTagName, getTitle, getTranslate, hasAnyClass, hasAnyStyle, hasStyle, internalConvertToMicroNode, isHidden, isSpellCheck, isTranslateOff, isTranslateOn, isTranslateUndefined, isUnfocusable, isValidID, onConsistencyCheck, onFinalizeNodeState, prependEventHandler, removeAllClasses, removeAllEventHandler, removeAllStyles, removeClass, removeStyle, setAccessKey, setContentEditable, setDirection, setDraggable, setEventHandler, setHidden, setID, setID, setLanguage, setRole, setSpellCheck, setTabIndex, setTitle, setTranslate, setUnfocusable
-
Methods inherited from class com.helger.html.hc.impl.AbstractHCNode
consistencyCheck, convertToMicroNode, customizeNode, finalizeNodeState, getNodeState, internalSetNodeState, onCustomizeNode, 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.html.IHCElement
addEventHandler, containsEventHandler, customAttrs, getAccessKey, getContentEditable, getDirection, getDraggable, getElement, getEventHandler, getEventMap, getLanguage, getRole, getTabIndex, getTagName, getTitle, getTranslate, isHidden, isSpellCheck, isTranslateOff, isTranslateOn, isTranslateUndefined, isUnfocusable, prependEventHandler, removeAllEventHandler, setAccessKey, setContentEditable, setDirection, setDraggable, setEventHandler, setHidden, setLanguage, setRole, setSpellCheck, setTabIndex, setTitle, setTranslate, setTranslate, setUnfocusable, withCustomAttrs
-
Methods inherited from interface com.helger.html.hc.html.IHCElementWithInternalChildren
recursiveContainsChildWithTagName
-
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.html.IHCHasCSSClasses
addClass, addClasses, addClasses, addClasses, containsClass, getAllClasses, getAllClassesAsString, getAllClassNames, hasAnyClass, removeAllClasses, removeClass
-
Methods inherited from interface com.helger.html.hc.html.IHCHasCSSStyles
addStyle, addStyle, addStyles, addStyles, addStyles, containsStyle, getAllStyles, getAllStylesAsString, getAllStyleValues, getStyleValue, hasAnyStyle, hasStyle, removeAllStyles, removeStyle
-
Methods inherited from interface com.helger.html.hc.IHCHasID
ensureID, getID, hasID, hasNoID, setID, setUniqueID
-
Methods inherited from interface com.helger.html.hc.IHCNode
consistencyCheck, convertToMicroNode, customizeNode, finalizeNodeState, getNodeState, registerExternalResources
-
-
-
-
Constructor Detail
-
AbstractHCElementWithInternalChildren
protected AbstractHCElementWithInternalChildren(@Nonnull EHTMLElement eElement)
-
-
Method Detail
-
hasChildren
public final boolean hasChildren()
- Specified by:
hasChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCElementWithInternalChildren<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 AbstractHCElementWithInternalChildren<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 AbstractHCElementWithInternalChildren<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 AbstractHCElementWithInternalChildren<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 AbstractHCElementWithInternalChildren<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 AbstractHCElementWithInternalChildren<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 AbstractHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>>- Overrides:
getChildCountin classAbstractHCNode
-
getAllChildren
@Nonnull @ReturnsMutableCopy public final com.helger.commons.collection.impl.ICommonsList<CHILDTYPE> getAllChildren()
- Specified by:
getAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>>- Specified by:
getAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>>- Overrides:
getAllChildrenin classAbstractHCNode
-
children
@Nullable @ReturnsMutableObject public final com.helger.commons.collection.impl.ICommonsList<CHILDTYPE> children()
-
getChildren
@Nullable public final com.helger.commons.collection.impl.ICommonsIterable<CHILDTYPE> getChildren()
- Specified by:
getChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IMPLTYPE extends AbstractHCElementWithInternalChildren<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 AbstractHCElementWithInternalChildren<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 AbstractHCElementWithInternalChildren<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 AbstractHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>>- Overrides:
forAllChildrenin classAbstractHCNode
-
forAllChildrenMapped
public final <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 AbstractHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>>- Overrides:
forAllChildrenMappedin classAbstractHCNode
-
getChildAtIndex
@Nullable public final CHILDTYPE getChildAtIndex(@Nonnegative int nIndex)
- Specified by:
getChildAtIndexin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>>- Overrides:
getChildAtIndexin classAbstractHCNode
-
getFirstChild
@Nullable public final CHILDTYPE getFirstChild()
- Specified by:
getFirstChildin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCElementWithInternalChildren<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 AbstractHCElementWithInternalChildren<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 AbstractHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>>- Overrides:
findFirstChildMappedin classAbstractHCNode
-
getLastChild
@Nullable public final CHILDTYPE getLastChild()
- Specified by:
getLastChildin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IMPLTYPE extends AbstractHCElementWithInternalChildren<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 AbstractHCElementWithInternalChildren<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 AbstractHCElementWithInternalChildren<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.
-
fillMicroElement
@OverrideOnDemand @OverridingMethodsMustInvokeSuper protected void fillMicroElement(com.helger.xml.microdom.IMicroElement aElement, IHCConversionSettingsToNode aConversionSettings)
Description copied from class:AbstractHCElementSet all attributes and child elements of this object- Overrides:
fillMicroElementin classAbstractHCElement<IMPLTYPE extends AbstractHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>>- Parameters:
aElement- The current micro element to be filled. Nevernull.aConversionSettings- The conversion settings to be used. Nevernull.
-
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 classAbstractHCElement<IMPLTYPE extends AbstractHCElementWithInternalChildren<IMPLTYPE,CHILDTYPE>>
-
-