java.lang.Object
com.priint.pubserver.plugin.PluginControlDefault
com.priint.pubserver.comet.bridge.dataprocessing.HtmlUtils
All Implemented Interfaces:
com.priint.pubserver.plugin.interfaces.PluginControl

public class HtmlUtils extends com.priint.pubserver.plugin.PluginControlDefault
Since:
4.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static final String
    Translator to escape non-ASCII chars to <0xNNNN>
    Space adjacent to non-ASCII chars should also be escaped.
    static final String
    Translator to escape reserved tagged text characters by backslash.
    List of reserved characters: "?", "=", ":", "_", "/", "&", "%", "#"
    Escaping is important in StyleNames and URLs
    static List<Element>
    getAncestors(Element child, String... names)
    Get a list of all element ancestors of a child element.
    static List<Element>
    getElements(Element parent, String... names)
    Get a list of direct child element of a parent element.
    static List<Element>
    Get all rows of a table in a list.
    static String
    Convert HTML DOM Document into XML String
    Used for log output
    static String
    Replaces all keys in a texts by their values.
    static String
    replaces numeric entities by their Unicode characters

    Methods inherited from class com.priint.pubserver.plugin.PluginControlDefault

    afterCreateConfigurations, afterDeleteConfigurations, afterUpdateConfigurations, createConfiguration, deleteConfigurations, getSession, getSessionId, initInstance, loadServerConfig, ping, readSessionAttribute, updateConfigurations, writeSessionAttribute

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.priint.pubserver.plugin.interfaces.PluginControl

    validateConfigurations
  • Method Details

    • getAncestors

      public static List<Element> getAncestors(Element child, String... names)
      Get a list of all element ancestors of a child element.

      Optionally filtered by tagNames.

      Parameters:
      child -
      names - list of names to filter. If no names are given, all elements on the path will be retrieved. "*" is NOT supported as tagName.
      Returns:
    • getRowsOfTable

      public static List<Element> getRowsOfTable(Element table)
      Get all rows of a table in a list.

      All rows will be retrieved regardless of their parent node (can be table, thead, tbody or tfoot element).

      Parameters:
      table -
      Returns:
    • getElements

      public static List<Element> getElements(Element parent, String... names)
      Get a list of direct child element of a parent element.

      Optionally filtered by tagNames.

      Parameters:
      parent -
      names - list of names to filter. If no names are given, all element children will be retrieved. "*" is NOT supported as tagName.
      Returns:
    • replaceNamedEntities

      public static String replaceNamedEntities(String text)
      Replaces all keys in a texts by their values. Keys are identified by the first group in a regular expression match. Keys that are not contained in the replacement map are not replaced.

      Example:

      replaceByMap("A${nbsp}C", "\\$\\{([A-Za-z]+)\\}", new HashMap<String, String>(){put("nbsp", "160"}));

      will return "A160C.

      Parameters:
      text -
      Returns:
      converted string
    • replaceNumericEntities

      public static String replaceNumericEntities(String text)
      replaces numeric entities by their Unicode characters
      Parameters:
      text -
      Returns:
      converted string
    • getStringFromDoc

      public static String getStringFromDoc(Document doc)
      Convert HTML DOM Document into XML String
      Used for log output
      Parameters:
      doc -
      Returns:
    • encodeAsTaggedText

      public static final String encodeAsTaggedText(String input)
      Translator to escape non-ASCII chars to <0xNNNN>
      Space adjacent to non-ASCII chars should also be escaped.
      Parameters:
      input -
      Returns:
      encoded text
    • escapeTaggedTextName

      public static final String escapeTaggedTextName(String input)
      Translator to escape reserved tagged text characters by backslash.
      List of reserved characters: "?", "=", ":", "_", "/", "&", "%", "#"
      Escaping is important in StyleNames and URLs