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

    Constructors
    Constructor
    Description
    Construct a JsoupTool object.
  • Method Summary

    Modifier and Type
    Method
    Description
    Get the output encoding.
    org.jsoup.nodes.Element
    parse(String content)
    Parse the supplied HTML content string using jsoup.
    org.jsoup.select.Elements
    select(String content, String cssQuery)
    Select elements in the supplied HTML content 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JsoupTool

      public JsoupTool()
      Construct a JsoupTool object.
  • Method Details

    • getOutputEncoding

      public Charset getOutputEncoding()
      Get the output encoding.
      Returns:
      the output encoding.
    • setOutputEncoding

      protected void setOutputEncoding(Charset outputEncoding)
      Set the output encoding.
      Parameters:
      outputEncoding - the desired output encoding
    • parse

      public org.jsoup.nodes.Element parse(String content)
      Parse the supplied HTML content string using jsoup.
      Parameters:
      content - HTML content string
      Returns:
      An Element that wraps the supplied content.
    • select

      public org.jsoup.select.Elements select(String content, String cssQuery)
      Select elements in the supplied HTML content 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 string
      cssQuery - a selector CSS-like query
      Returns:
      The selected elements.