Package com.helger.html.hc
Class HCHelper
- java.lang.Object
-
- com.helger.html.hc.HCHelper
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static com.helger.commons.collection.impl.ICommonsList<IHCNode>getAsFlattenedList(IHCNode aNode)Inline all contained node lists so that a "flat" list results.static com.helger.commons.collection.impl.ICommonsList<IHCNode>getAsFlattenedList(Iterable<? extends IHCNode> aNodes)Inline all contained node lists so that a "flat" list results.static StringgetAsHTMLID(String sSrc)Convert the passed ID string to a valid HTML ID.static com.helger.commons.collection.impl.ICommonsList<com.helger.xml.microdom.IMicroElement>getChildElements(com.helger.xml.microdom.IMicroElement aElement, EHTMLElement eHTMLElement)Get a list of all HTML child elements of the given element.static com.helger.xml.microdom.IMicroElementgetFirstChildElement(com.helger.xml.microdom.IMicroElement aElement, EHTMLElement eHTMLElement)Find the first HTML child element within a start element.static IHCNodegetUnwrappedNode(IHCNode aHCNode)Resolve all wrappings viaIHCWrappingNodeof the passed node.static booleanisWrappedNode(IHCNode aHCNode)Check if the passed node is a wrapped node by checking if it implementsIHCWrappingNode.static voiditerateChildren(IHCNode aNode, IHCIteratorCallback aCallback)Recursively iterate all child nodes of the passed node.static voiditerateChildrenNoCopy(IHCNode aNode, IHCIteratorCallback aCallback)Recursively iterate all child nodes of the passed node.static voiditerateChildrenNonBreakable(IHCNode aNode, IHCIteratorNonBreakableCallback aCallback)Recursively iterate all child nodes of the passed node.static voiditerateTree(IHCNode aNode, IHCIteratorCallback aCallback)Recursively iterate the node and all child nodes of the passed node.static voiditerateTreeNoCopy(IHCNode aNode, IHCIteratorCallback aCallback)Recursively iterate the node and all child nodes of the passed node.static voiditerateTreeNonBreakable(IHCNode aNode, IHCIteratorNonBreakableCallback aCallback)Recursively iterate the node and all child nodes of the passed node.static booleanrecursiveContainsAtLeastOneTextNode(IHCNode aStartNode)
-
-
-
Method Detail
-
iterateTree
public static void iterateTree(@Nonnull IHCNode aNode, @Nonnull IHCIteratorCallback aCallback)
Recursively iterate the node and all child nodes of the passed node. The difference toiterateChildren(IHCNode, IHCIteratorCallback)is, that the callback is also invoked on the passed node.- Parameters:
aNode- The node to be iterated.aCallback- The callback to be invoked on every child
-
iterateTreeNoCopy
public static void iterateTreeNoCopy(@Nonnull IHCNode aNode, @Nonnull IHCIteratorCallback aCallback)
Recursively iterate the node and all child nodes of the passed node. The difference toiterateChildrenNoCopy(IHCNode, IHCIteratorCallback)is, that the callback is also invoked on the passed node.- Parameters:
aNode- The node to be iterated.aCallback- The callback to be invoked on every child
-
iterateChildren
public static void iterateChildren(@Nonnull IHCNode aNode, @Nonnull IHCIteratorCallback aCallback)
Recursively iterate all child nodes of the passed node.- Parameters:
aNode- The node who's children should be iterated.aCallback- The callback to be invoked on every child
-
iterateChildrenNoCopy
public static void iterateChildrenNoCopy(@Nonnull IHCNode aNode, @Nonnull IHCIteratorCallback aCallback)
Recursively iterate all child nodes of the passed node.- Parameters:
aNode- The node who's children should be iterated.aCallback- The callback to be invoked on every child
-
iterateTreeNonBreakable
public static void iterateTreeNonBreakable(@Nonnull IHCNode aNode, @Nonnull IHCIteratorNonBreakableCallback aCallback)
Recursively iterate the node and all child nodes of the passed node. The difference toiterateChildrenNonBreakable(IHCNode, IHCIteratorNonBreakableCallback)is, that the callback is also invoked on the passed node.- Parameters:
aNode- The node to be iterated.aCallback- The callback to be invoked on every child
-
iterateChildrenNonBreakable
public static void iterateChildrenNonBreakable(@Nonnull IHCNode aNode, @Nonnull IHCIteratorNonBreakableCallback aCallback)
Recursively iterate all child nodes of the passed node.- Parameters:
aNode- The node who's children should be iterated.aCallback- The callback to be invoked on every child
-
recursiveContainsAtLeastOneTextNode
public static boolean recursiveContainsAtLeastOneTextNode(@Nullable IHCNode aStartNode)
-
getFirstChildElement
@Nullable public static com.helger.xml.microdom.IMicroElement getFirstChildElement(@Nonnull com.helger.xml.microdom.IMicroElement aElement, @Nonnull EHTMLElement eHTMLElement)
Find the first HTML child element within a start element. This check considers both lower- and upper-case element names. Mixed case is not supported!- Parameters:
aElement- The element to search ineHTMLElement- The HTML element to search.- Returns:
nullif no such child element is present.
-
getChildElements
@Nonnull @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsList<com.helger.xml.microdom.IMicroElement> getChildElements(@Nonnull com.helger.xml.microdom.IMicroElement aElement, @Nonnull EHTMLElement eHTMLElement)
Get a list of all HTML child elements of the given element. This methods handles lower- and upper-cased elements.- Parameters:
aElement- The element to search ineHTMLElement- The HTML element to search- Returns:
- A non-
nulllist where the lower-case elements are listed before the upper-case elements.
-
getAsFlattenedList
@Nonnull @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsList<IHCNode> getAsFlattenedList(@Nullable IHCNode aNode)
Inline all contained node lists so that a "flat" list results. This only flattens something if the passed node is anHCNodeListand all node-lists directly contained in the other node lists. Node-lists that are hidden deep inside the tree are not considered!- Parameters:
aNode- The source node. May benull.- Returns:
- A non-
nullflattened list.
-
getAsFlattenedList
@Nonnull @ReturnsMutableCopy public static com.helger.commons.collection.impl.ICommonsList<IHCNode> getAsFlattenedList(@Nullable Iterable<? extends IHCNode> aNodes)
Inline all contained node lists so that a "flat" list results. This only flattens something if the passed node is anHCNodeListand all node-lists directly contained in the other node lists. Node-lists that are hidden deep inside the tree are not considered!- Parameters:
aNodes- The source nodes. May benullor empty.- Returns:
- A non-
nullflattened list.
-
getUnwrappedNode
@Nullable public static IHCNode getUnwrappedNode(@Nullable IHCNode aHCNode)
Resolve all wrappings viaIHCWrappingNodeof the passed node. This is usually either an HCOutOfBandNode or a HCConditionalCommentNode.- Parameters:
aHCNode- The node to be unwrapped. May benull.- Returns:
- The unwrapped node. May be the same as the parameter, if the node
is not wrapped. May be
nullif the parameter node isnull.
-
isWrappedNode
public static boolean isWrappedNode(@Nullable IHCNode aHCNode)
Check if the passed node is a wrapped node by checking if it implementsIHCWrappingNode.- Parameters:
aHCNode- The node to be checked. May benull.- Returns:
trueif the node is notnulland if it implementsIHCWrappingNode.
-
-