Class 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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String encodeAsTaggedText​(java.lang.String input)
      Translator to escape non-ASCII chars to <0xNNNN>
      Space adjacent to non-ASCII chars should also be escaped.
      static java.lang.String escapeTaggedTextName​(java.lang.String input)
      Translator to escape reserved tagged text characters by backslash.
      List of reserved characters: "?", "=", ":", "_", "/", "&", "%", "#"
      Escaping is important in StyleNames and URLs
      static java.util.List<org.w3c.dom.Element> getAncestors​(org.w3c.dom.Element child, java.lang.String... names)
      Get a list of all element ancestors of a child element.
      static java.util.List<org.w3c.dom.Element> getElements​(org.w3c.dom.Element parent, java.lang.String... names)
      Get a list of direct child element of a parent element.
      static java.util.List<org.w3c.dom.Element> getRowsOfTable​(org.w3c.dom.Element table)
      Get all rows of a table in a list.
      static java.lang.String getStringFromDoc​(org.w3c.dom.Document doc)
      Convert HTML DOM Document into XML String
      Used for log output
      static java.lang.String replaceNamedEntities​(java.lang.String text)
      Replaces all keys in a texts by their values.
      static java.lang.String replaceNumericEntities​(java.lang.String text)
      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 Detail

      • getAncestors

        public static java.util.List<org.w3c.dom.Element> getAncestors​(org.w3c.dom.Element child,
                                                                       java.lang.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 java.util.List<org.w3c.dom.Element> getRowsOfTable​(org.w3c.dom.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 java.util.List<org.w3c.dom.Element> getElements​(org.w3c.dom.Element parent,
                                                                      java.lang.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 java.lang.String replaceNamedEntities​(java.lang.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 java.lang.String replaceNumericEntities​(java.lang.String text)
        replaces numeric entities by their Unicode characters
        Parameters:
        text -
        Returns:
        converted string
      • getStringFromDoc

        public static java.lang.String getStringFromDoc​(org.w3c.dom.Document doc)
        Convert HTML DOM Document into XML String
        Used for log output
        Parameters:
        doc -
        Returns:
      • encodeAsTaggedText

        public static final java.lang.String encodeAsTaggedText​(java.lang.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 java.lang.String escapeTaggedTextName​(java.lang.String input)
        Translator to escape reserved tagged text characters by backslash.
        List of reserved characters: "?", "=", ":", "_", "/", "&", "%", "#"
        Escaping is important in StyleNames and URLs