Class HTMLUtils


  • public final class HTMLUtils
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String charsToEntities​(java.lang.String str, java.lang.String encoding, java.util.Collection<java.lang.String> shortcuts)
      Converts characters that must be converted (< > & ' ' (nbsp)) into HTML entities.
      static java.lang.String entitiesToChars​(java.lang.String str)
      Converts HTML entities to normal characters
      static java.lang.String getSpacePostfix​(java.lang.String input, boolean compressWhitespace)  
      static java.lang.String getSpacePrefix​(java.lang.String input, boolean compressWhitespace)  
      static boolean isDecimalDigit​(int ch)
      Returns true if a char is a decimal digit
      static boolean isHexDigit​(int ch)
      Returns true if a char is a hex digit
      static boolean isLatinLetter​(int ch)
      Returns true if a char is a latin letter
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • entitiesToChars

        public static java.lang.String entitiesToChars​(java.lang.String str)
        Converts HTML entities to normal characters
      • isLatinLetter

        public static boolean isLatinLetter​(int ch)
        Returns true if a char is a latin letter
      • isDecimalDigit

        public static boolean isDecimalDigit​(int ch)
        Returns true if a char is a decimal digit
      • isHexDigit

        public static boolean isHexDigit​(int ch)
        Returns true if a char is a hex digit
      • charsToEntities

        public static java.lang.String charsToEntities​(java.lang.String str,
                                                       java.lang.String encoding,
                                                       java.util.Collection<java.lang.String> shortcuts)
        Converts characters that must be converted (< > & ' ' (nbsp)) into HTML entities.
        Parameters:
        str - The string to convert
        encoding - The output encoding. May be null (all characters are assumed to be supported).
        shortcuts - A collection of tag-like strings (<foo>) that will be "protected", i.e. they will not be escaped as entities.
      • getSpacePrefix

        public static java.lang.String getSpacePrefix​(java.lang.String input,
                                                      boolean compressWhitespace)
      • getSpacePostfix

        public static java.lang.String getSpacePostfix​(java.lang.String input,
                                                       boolean compressWhitespace)