public class HtmlUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> List<T> |
elementsToList(Collection<org.jsoup.nodes.Element> elements,
Function<org.jsoup.nodes.Element,T> eleToObject)
Applies a specified mapping function to every Element of a Collection,
to generate a List of mapped objects.
|
static List<String> |
elementsToStringList(Collection<org.jsoup.nodes.Element> elements)
|
static String |
getAttribute(org.jsoup.nodes.Element element,
String attributeKey)
Retrieves an attribute value of an HTML Element.
|
static <T extends Enum<T>> |
getEnumAttribute(org.jsoup.nodes.Element element,
String attributeKey,
Class<T> enumClass)
Retrieves an attribute value of an HTML Element
and attempts to map it to an Enum.
|
static <T> T |
getObject(org.jsoup.nodes.Element element,
String tagName,
Function<org.jsoup.nodes.Element,T> eleToObject)
Retrieves the first occurrence of an Element with a specified
tag and maps it to an object via a specified mapping function.
|
static <T> List<T> |
getObjects(org.jsoup.nodes.Element element,
String tagName,
Function<org.jsoup.nodes.Element,T> eleToObject)
Retrieves all occurrences of Elements with specified tags
and maps them to a List of objects via a specified mapping function.
|
static <T> List<T> |
getObjectsFromParent(org.jsoup.nodes.Element element,
String parentTagName,
Function<org.jsoup.nodes.Element,T> eleToObject)
Retrieves all child Elements of a specified parent tag and
maps them to a List of objects via a specified mapping function.
|
static String |
getString(org.jsoup.nodes.Element element,
String tagName)
Retrieves the text of the first occurrence of a specified tag
derived from a specified Element.
|
static List<String> |
getStrings(org.jsoup.nodes.Element element,
String tagName)
Retrieves the texts of all occurrences of Elements with a specified tag name.
|
static List<String> |
getStringsFromParent(org.jsoup.nodes.Element element,
String parentTagName)
Retrieves the texts of all children of a specified parent Element.
|
public static String getString(org.jsoup.nodes.Element element, String tagName)
element - the HTML Element that contains the tagtagName - the name of the tag of which the text is to be retrievedpublic static List<String> getStringsFromParent(org.jsoup.nodes.Element element, String parentTagName)
public static List<String> getStrings(org.jsoup.nodes.Element element, String tagName)
public static <T> T getObject(org.jsoup.nodes.Element element,
String tagName,
Function<org.jsoup.nodes.Element,T> eleToObject)
T - the output type of the mapping functionelement - the HTML Element that contains the requested tagtagName - the name of the requested tageleToObject - a function that maps the found Element to Tpublic static <T> List<T> getObjects(org.jsoup.nodes.Element element, String tagName, Function<org.jsoup.nodes.Element,T> eleToObject)
T - the output type of the mapping functionelement - the HTML Element that contains the requested tagstagName - the name of the requested tageleToObject - a function that maps the found Elements to Tpublic static <T> List<T> getObjectsFromParent(org.jsoup.nodes.Element element, String parentTagName, Function<org.jsoup.nodes.Element,T> eleToObject)
T - the output type of the mapping functionelement - the HTML Element that contains the parent tagparentTagName - the name of the parent tageleToObject - a function that maps the child Elements to Tpublic static String getAttribute(org.jsoup.nodes.Element element, String attributeKey)
element - the HTML Element from which the attribute is retrievedattributeKey - the key of the attributepublic static <T extends Enum<T>> T getEnumAttribute(org.jsoup.nodes.Element element, String attributeKey, Class<T> enumClass)
T - the type of the Enumelement - the HTML Element from which the attribute is retrievedattributeKey - the key of the attributeenumClass - the Enum class to which the attribute value must be mappedpublic static <T> List<T> elementsToList(Collection<org.jsoup.nodes.Element> elements, Function<org.jsoup.nodes.Element,T> eleToObject)
T - the output type of the mapping functionelements - the Element that are to be mapped to objectseleToObject - a function that maps the Elements to Tpublic static List<String> elementsToStringList(Collection<org.jsoup.nodes.Element> elements)
elements - the Elements that are to be converted to StringsCopyright © 2017–2019. All rights reserved.