Package com.helger.html.hc.impl
Class AbstractHCNode
- java.lang.Object
-
- com.helger.html.hc.impl.AbstractHCNode
-
- All Implemented Interfaces:
com.helger.commons.hierarchy.IHasChildren<IHCNode>,com.helger.commons.hierarchy.IHasChildrenRecursive<IHCNode>,com.helger.commons.hierarchy.IHasChildrenSorted<IHCNode>,IHCNode,Serializable
- Direct Known Subclasses:
AbstractHCElement,AbstractHCHasChildrenMutable,AbstractHCTextNode,AbstractHCWrappingNode,HCCDATANode,HCCommentNode,HCDOMWrapper,HCEntityNode
@NotThreadSafe public abstract class AbstractHCNode extends Object implements IHCNode
Default implementation of theIHCNodeinterface.- Author:
- Philip Helger
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractHCNode()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description booleancanConvertToMicroNode(IHCConversionSettingsToNode aConversionSettings)This method checks whether the node is suitable for conversion to anIMicroNode.voidconsistencyCheck(IHCConversionSettingsToNode aConversionSettings)Perform consistency checks on this node.
This method is called at last once perIHCNode.com.helger.xml.microdom.IMicroNodeconvertToMicroNode(IHCConversionSettingsToNode aConversionSettings)The main conversion to a micro node.
Note: must be an IMicroNode since e.g. the text node returns an IMicroText.voidcustomizeNode(IHCCustomizer aCustomizer, EHTMLVersion eHTMLVersion, IHCHasChildrenMutable<?,? super IHCNode> aTargetNode)Customize the current node with the respective customizer.
This method is called at last once perIHCNode.voidfinalizeNodeState(IHCConversionSettingsToNode aConversionSettings, IHCHasChildrenMutable<?,? super IHCNode> aTargetNode)Finalize the node by applying any internal state that was not yet converted to a HC element.
This method is called at last once perIHCNode.IHCNodefindFirstChild(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<? extends IHCNode>getAllChildren()IHCNodegetChildAtIndex(int nIndex)intgetChildCount()com.helger.commons.collection.impl.ICommonsIterable<? extends IHCNode>getChildren()IHCNodegetFirstChild()IHCNodegetLastChild()EHCNodeStategetNodeState()StringgetPlainText()booleanhasChildren()protected abstract com.helger.xml.microdom.IMicroNodeinternalConvertToMicroNode(IHCConversionSettingsToNode aConversionSettings)voidinternalSetNodeState(EHCNodeState eNodeState)Change the node state internally.protected voidonConsistencyCheck(IHCConversionSettingsToNode aConversionSettings)protected voidonCustomizeNode(IHCCustomizer aCustomizer, EHTMLVersion eHTMLVersion, IHCHasChildrenMutable<?,? super IHCNode> aTargetNode)protected voidonFinalizeNodeState(IHCConversionSettingsToNode aConversionSettings, IHCHasChildrenMutable<?,? super IHCNode> aTargetNode)Finalize the node by applying any internal state that was not yet converted to a HC element.protected voidonRegisterExternalResources(IHCConversionSettingsToNode aConversionSettings, boolean bForcedRegistration)voidregisterExternalResources(IHCConversionSettingsToNode aConversionSettings, boolean bForcedRegistration)Register external JS and CSS resources required for this node, but only if this HC node can be converted to a micro node as determined byIHCNode.canConvertToMicroNode(IHCConversionSettingsToNode).StringtoString()
-
-
-
Method Detail
-
hasChildren
@OverrideOnDemand public boolean hasChildren()
- Specified by:
hasChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IHCNode>
-
getChildCount
@OverrideOnDemand @Nonnegative public int getChildCount()
- Specified by:
getChildCountin interfacecom.helger.commons.hierarchy.IHasChildren<IHCNode>
-
getAllChildren
@Nullable @OverrideOnDemand public com.helger.commons.collection.impl.ICommonsList<? extends IHCNode> getAllChildren()
-
getChildren
@OverrideOnDemand @Nullable public com.helger.commons.collection.impl.ICommonsIterable<? extends IHCNode> getChildren()
- Specified by:
getChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IHCNode>
-
forAllChildren
public void forAllChildren(@Nonnull Consumer<? super IHCNode> aConsumer)
- Specified by:
forAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IHCNode>
-
forAllChildrenBreakable
@Nonnull public com.helger.commons.state.EContinue forAllChildrenBreakable(@Nonnull Function<? super IHCNode,com.helger.commons.state.EContinue> aConsumer)
- Specified by:
forAllChildrenBreakablein interfacecom.helger.commons.hierarchy.IHasChildren<IHCNode>
-
forAllChildren
public void forAllChildren(@Nonnull Predicate<? super IHCNode> aFilter, @Nonnull Consumer<? super IHCNode> aConsumer)
- Specified by:
forAllChildrenin interfacecom.helger.commons.hierarchy.IHasChildren<IHCNode>
-
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<IHCNode>
-
getChildAtIndex
@Nullable @OverrideOnDemand public IHCNode getChildAtIndex(@Nonnegative int nIndex)
- Specified by:
getChildAtIndexin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IHCNode>
-
getFirstChild
@Nullable @OverrideOnDemand public IHCNode getFirstChild()
- Specified by:
getFirstChildin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IHCNode>
-
findFirstChild
@Nullable public IHCNode findFirstChild(@Nonnull Predicate<? super IHCNode> aFilter)
- Specified by:
findFirstChildin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IHCNode>
-
findFirstChildMapped
@Nullable public <DSTTYPE> DSTTYPE findFirstChildMapped(@Nonnull Predicate<? super IHCNode> aFilter, @Nonnull Function<? super IHCNode,? extends DSTTYPE> aMapper)
- Specified by:
findFirstChildMappedin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IHCNode>
-
getLastChild
@Nullable @OverrideOnDemand public IHCNode getLastChild()
- Specified by:
getLastChildin interfacecom.helger.commons.hierarchy.IHasChildrenSorted<IHCNode>
-
getNodeState
@Nonnull public EHCNodeState getNodeState()
- Specified by:
getNodeStatein interfaceIHCNode- Returns:
- The current node state and never
null.
-
internalSetNodeState
public final void internalSetNodeState(@Nonnull EHCNodeState eNodeState)
Change the node state internally. Handle with care!- Parameters:
eNodeState- The new node state. May not benull.
-
onCustomizeNode
@OverrideOnDemand protected void onCustomizeNode(@Nonnull IHCCustomizer aCustomizer, @Nonnull EHTMLVersion eHTMLVersion, @Nonnull IHCHasChildrenMutable<?,? super IHCNode> aTargetNode)
-
customizeNode
public final void customizeNode(@Nullable IHCCustomizer aCustomizer, @Nonnull EHTMLVersion eHTMLVersion, @Nonnull IHCHasChildrenMutable<?,? super IHCNode> aTargetNode)
Description copied from interface:IHCNodeCustomize the current node with the respective customizer.
This method is called at last once perIHCNode.- Specified by:
customizeNodein interfaceIHCNode- Parameters:
aCustomizer- The customizer to use. May benull.eHTMLVersion- The HTML version to be used. May not benull.aTargetNode- The target node where additional nodes should be added. May not benull.
-
onFinalizeNodeState
@OverrideOnDemand @OverridingMethodsMustInvokeSuper protected void onFinalizeNodeState(@Nonnull IHCConversionSettingsToNode aConversionSettings, @Nonnull IHCHasChildrenMutable<?,? super IHCNode> aTargetNode)
Finalize the node by applying any internal state that was not yet converted to a HC element. This method is called at maximum once per IHCNode. It is safe to still add classes, style or children to this node in this method.- Parameters:
aConversionSettings- HC conversion settingsaTargetNode- The target node where additional nodes should be added
-
finalizeNodeState
public final void finalizeNodeState(@Nonnull IHCConversionSettingsToNode aConversionSettings, @Nonnull IHCHasChildrenMutable<?,? super IHCNode> aTargetNode)
Description copied from interface:IHCNodeFinalize the node by applying any internal state that was not yet converted to a HC element.
This method is called at last once perIHCNode.- Specified by:
finalizeNodeStatein interfaceIHCNode- Parameters:
aConversionSettings- The current conversion settings to be used. May not benull.aTargetNode- The target node where additional nodes should be added. May not benull.
-
onConsistencyCheck
@OverrideOnDemand @OverridingMethodsMustInvokeSuper protected void onConsistencyCheck(@Nonnull IHCConversionSettingsToNode aConversionSettings)
- Parameters:
aConversionSettings- HC conversion settings
-
consistencyCheck
public final void consistencyCheck(@Nonnull IHCConversionSettingsToNode aConversionSettings)
Description copied from interface:IHCNodePerform consistency checks on this node.
This method is called at last once perIHCNode.- Specified by:
consistencyCheckin interfaceIHCNode- Parameters:
aConversionSettings- The current conversion settings to be used. May not benull.
-
canConvertToMicroNode
@OverrideOnDemand 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- Parameters:
aConversionSettings- The conversion settings to be used- Returns:
trueif the node can be converted to a node,falseotherwise.
-
onRegisterExternalResources
@OverrideOnDemand protected void onRegisterExternalResources(@Nonnull IHCConversionSettingsToNode aConversionSettings, boolean bForcedRegistration)
- Parameters:
aConversionSettings- HC conversion settingsbForcedRegistration-trueif the registration is forced by the caller.
-
registerExternalResources
public final void registerExternalResources(@Nonnull IHCConversionSettingsToNode aConversionSettings, boolean bForcedRegistration)
Description copied from interface:IHCNodeRegister external JS and CSS resources required for this node, but only if this HC node can be converted to a micro node as determined byIHCNode.canConvertToMicroNode(IHCConversionSettingsToNode). Using the bForceRegistration parameter, this can be forced.
This method is called at last once perIHCNode.- Specified by:
registerExternalResourcesin interfaceIHCNode- Parameters:
aConversionSettings- Conversion settings to be used. Nevernull.bForcedRegistration-trueto force registration,falseto register resources only if the node can be converted to a micro node.
-
internalConvertToMicroNode
@Nullable @OverrideOnDemand protected abstract com.helger.xml.microdom.IMicroNode internalConvertToMicroNode(@Nonnull IHCConversionSettingsToNode aConversionSettings)
-
convertToMicroNode
@Nullable public final com.helger.xml.microdom.IMicroNode convertToMicroNode(@Nonnull IHCConversionSettingsToNode aConversionSettings)
Description copied from interface:IHCNodeThe main conversion to a micro node.
Note: must be an IMicroNode since e.g. the text node returns an IMicroText.- Specified by:
convertToMicroNodein interfaceIHCNode- Parameters:
aConversionSettings- The conversion settings to be used. May not benull.- Returns:
- The fully created HTML node
-
getPlainText
@OverrideOnDemand @Nonnull public String getPlainText()
- Specified by:
getPlainTextin interfaceIHCNode- Returns:
- The plain text representation of this text. May not be
null.
-
-