Package com.helger.html.hc.special
Class HCSpecialNodeHandler
- java.lang.Object
-
- com.helger.html.hc.special.HCSpecialNodeHandler
-
@NotThreadSafe public final class HCSpecialNodeHandler extends Object
This class is used to handle the special nodes (JS and CSS, inline and reference).- Author:
- Philip Helger
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Iterable<? extends IHCNode>applyModifiers(Iterable<? extends IHCNode> aNodes)static voidextractSpecialContent(IHCNode aNode, AbstractHCSpecialNodes<?> aSpecialNodes, boolean bKeepOnDocumentReady)Extract all out-of-band nodes of the source node, merge JS and CSS and finally extract all special nodes into the passed object.static voidextractSpecialContent(IHCNode aNode, AbstractHCSpecialNodes<?> aSpecialNodes, IHCOnDocumentReadyProvider aOnDocumentReadyProvider)Extract all out-of-band nodes of the source node, merge JS and CSS and finally extract all special nodes into the passed object.static com.helger.commons.collection.impl.ICommonsList<IHCNode>extractSpecialNodes(Iterable<? extends IHCNode> aNodes, AbstractHCSpecialNodes<?> aSpecialNodes)static com.helger.commons.collection.impl.ICommonsList<IHCNode>getMergedInlineCSSAndJSNodes(Iterable<? extends IHCNode> aNodes, boolean bKeepOnDocumentReady)Merge all inline CSS and JS elements contained in the source nodes into one script elementsstatic com.helger.commons.collection.impl.ICommonsList<IHCNode>getMergedInlineCSSAndJSNodes(Iterable<? extends IHCNode> aNodes, IHCOnDocumentReadyProvider aOnDocumentReadyProvider)Merge all inline CSS and JS elements contained in the source nodes into one script elementsstatic booleanisOutOfBandNode(IHCNode aHCNode)Check if the passed node is an out-of-band node.static voidrecursiveExtractAndRemoveOutOfBandNodes(IHCNode aParentElement, List<IHCNode> aTargetList)Extract all out-of-band child nodes for the passed element.
-
-
-
Method Detail
-
isOutOfBandNode
public static boolean isOutOfBandNode(@Nonnull IHCNode aHCNode)
Check if the passed node is an out-of-band node.- Parameters:
aHCNode- The node to be checked. May not benull.- Returns:
trueif it is an out-of-band node,falseif not.
-
recursiveExtractAndRemoveOutOfBandNodes
public static void recursiveExtractAndRemoveOutOfBandNodes(@Nonnull IHCNode aParentElement, @Nonnull List<IHCNode> aTargetList)
Extract all out-of-band child nodes for the passed element. Must be called after the element is finished! All out-of-band nodes are detached from their parent so that the original node can be reused. Wrapped nodes where the inner node is an out of band node are also considered and removed.- Parameters:
aParentElement- The parent element to extract the nodes from. May not benull.aTargetList- The target list to be filled. May not benull.
-
applyModifiers
@Nonnull public static Iterable<? extends IHCNode> applyModifiers(@Nonnull Iterable<? extends IHCNode> aNodes)
-
getMergedInlineCSSAndJSNodes
@Nonnull @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsList<IHCNode> getMergedInlineCSSAndJSNodes(@Nonnull Iterable<? extends IHCNode> aNodes, boolean bKeepOnDocumentReady)
Merge all inline CSS and JS elements contained in the source nodes into one script elements- Parameters:
aNodes- Source list of nodes. May not benull.bKeepOnDocumentReady- iftruethan all combined document.ready() scripts are kept as document.ready() scripts. Iffalsethan all document.ready() scripts are converted to regular scripts and are executed after all other scripts. For AJAX calls, this should befalse.- Returns:
- Target list. JS and CSS and other nodes are mixed. Inline JS and CSS that comes before files, is first. Than come the CSS and JS external as well as other elements. Finally the inline JS and CSS nodes to be emitted after the files are contained. So the resulting order is at it should be except that JS and CSS and other nodes are mixed.
-
getMergedInlineCSSAndJSNodes
@Nonnull @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsList<IHCNode> getMergedInlineCSSAndJSNodes(@Nonnull Iterable<? extends IHCNode> aNodes, @Nullable IHCOnDocumentReadyProvider aOnDocumentReadyProvider)
Merge all inline CSS and JS elements contained in the source nodes into one script elements- Parameters:
aNodes- Source list of nodes. May not benull.aOnDocumentReadyProvider- if notnullthan all combined document.ready() scripts are kept as document.ready() scripts using this provider. Ifnullthan all document.ready() scripts are converted to regular scripts and are executed after all other scripts. For AJAX calls, this should benullas there is no "document ready" callback - alternatively you can provide a custom "on document ready" provider.- Returns:
- Target list. JS and CSS and other nodes are mixed. Inline JS and CSS that comes before files, is first. Than come the CSS and JS external as well as other elements. Finally the inline JS and CSS nodes to be emitted after the files are contained. So the resulting order is at it should be except that JS and CSS and other nodes are mixed.
-
extractSpecialNodes
@Nonnull @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsList<IHCNode> extractSpecialNodes(@Nonnull Iterable<? extends IHCNode> aNodes, @Nonnull AbstractHCSpecialNodes<?> aSpecialNodes)
-
extractSpecialContent
public static void extractSpecialContent(@Nonnull IHCNode aNode, @Nonnull AbstractHCSpecialNodes<?> aSpecialNodes, boolean bKeepOnDocumentReady)
Extract all out-of-band nodes of the source node, merge JS and CSS and finally extract all special nodes into the passed object.- Parameters:
aNode- Source node. May not benull.aSpecialNodes- Target special node object to be filled. May not benull.bKeepOnDocumentReady- iftruethan all combined document.ready() scripts are kept as document.ready() scripts. Iffalsethan all document.ready() scripts are converted to regular scripts and are executed after all other scripts. For AJAX calls, this should befalse.
-
extractSpecialContent
public static void extractSpecialContent(@Nonnull IHCNode aNode, @Nonnull AbstractHCSpecialNodes<?> aSpecialNodes, @Nullable IHCOnDocumentReadyProvider aOnDocumentReadyProvider)
Extract all out-of-band nodes of the source node, merge JS and CSS and finally extract all special nodes into the passed object.- Parameters:
aNode- Source node. May not benull.aSpecialNodes- Target special node object to be filled. May not benull.aOnDocumentReadyProvider- if notnullthan all combined document.ready() scripts are kept as document.ready() scripts using this provider. Ifnullthan all document.ready() scripts are converted to regular scripts and are executed after all other scripts. For AJAX calls, this should benullas there is no "document ready" callback - alternatively you can provide a custom "on document ready" provider.
-
-