Package io.github.cs1302uga
Class JsoupTool
java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
io.github.cs1302uga.JsoupTool
@DefaultKey("soup")
public class JsoupTool
extends org.apache.velocity.tools.generic.SafeConfig
An Apache Velocity tool that provides utility methods to manipulate HTML code using
jsoup HTML5 parser.
- Author:
- Michael E. Cotterell
-
Field Summary
Fields inherited from class org.apache.velocity.tools.generic.SafeConfig
LOCK_CONFIG_KEY, log, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet the output encoding.org.jsoup.nodes.Element
Parse the supplied HTMLcontent
string using jsoup.org.jsoup.select.Elements
Select elements in the supplied HTMLcontent
string that match the selector CSS query, with this element as the starting context.protected void
setOutputEncoding
(Charset outputEncoding) Set the output encoding.Methods inherited from class org.apache.velocity.tools.generic.SafeConfig
configure, configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig, setSafeMode
-
Constructor Details
-
JsoupTool
public JsoupTool()Construct aJsoupTool
object.
-
-
Method Details
-
getOutputEncoding
Get the output encoding.- Returns:
- the output encoding.
-
setOutputEncoding
Set the output encoding.- Parameters:
outputEncoding
- the desired output encoding
-
parse
Parse the supplied HTMLcontent
string using jsoup.- Parameters:
content
- HTML content string- Returns:
- An
Element
that wraps the suppliedcontent
.
-
select
Select elements in the supplied HTMLcontent
string that match the selector CSS query, with this element as the starting context. Matched elements may include this element, or any of its children.- Parameters:
content
- HTML content stringcssQuery
- a selector CSS-like query- Returns:
- The selected elements.
-