Class HtmlDomUtil


  • public class HtmlDomUtil
    extends Object
    Utility functions to deal with HTML using W3C DOM operations.
    • Field Detail

      • ENC

        public static final Charset ENC
        Standard character encoding we prefer (UTF-8).
    • Constructor Detail

      • HtmlDomUtil

        public HtmlDomUtil()
    • Method Detail

      • compress

        public static byte[] compress​(byte[] raw)
                               throws IOException
        Compress the document.
        Throws:
        IOException
      • find

        public static Element find​(Node parent,
                                   String name)
        Find an element by its "id" attribute; null if no element is found.
      • addHidden

        public static void addHidden​(Element form,
                                     String name,
                                     String value)
        Append an HTML <input type="hidden"> to the form.
      • newDocument

        public static Document newDocument()
        Construct a new empty document.
      • attachNonce

        public static Optional<String> attachNonce​(String html,
                                                   String nonce)
        Attaches nonce to all script elements in html.

        The returned html is not guaranteed to have the same formatting as the input.

        Returns:
        Updated html or {#link Optional.empty()} if parsing failed.