Package editor.util

Class HTMLEscapeUtil


  • public class HTMLEscapeUtil
    extends java.lang.Object
    Static utilities for writing out HTML
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String NBSP
      Constant representing non-breaking space escape character
      static java.lang.String URL_PARAMETER_SEPARATOR
      Character used to separate parameters in a URL query string
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private HTMLEscapeUtil()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String escape​(java.lang.String string)
      Escape a string by replacing all occurrences of special characters (such as > and <) by their corresponding escapes.
      static java.lang.String escape​(java.lang.String string, boolean escapeNewLine)  
      private static java.lang.String escape​(java.lang.String string, boolean escapeNewLine, boolean isTextArea)  
      static java.lang.String escapeAttribute​(java.lang.String string)
      Escape a string for use as an HTML attribute by replacing all double quotes and '&'.
      static java.lang.String escapeForTextArea​(java.lang.String string)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NBSP

        public static final java.lang.String NBSP
        Constant representing non-breaking space escape character
        See Also:
        Constant Field Values
      • URL_PARAMETER_SEPARATOR

        public static final java.lang.String URL_PARAMETER_SEPARATOR
        Character used to separate parameters in a URL query string
        See Also:
        Constant Field Values
    • Constructor Detail

      • HTMLEscapeUtil

        private HTMLEscapeUtil()
    • Method Detail

      • escape

        public static java.lang.String escape​(java.lang.String string)
        Escape a string by replacing all occurrences of special characters (such as > and <) by their corresponding escapes.
        Parameters:
        string - the string to be escaped
        Returns:
        the escaped string or, if the original string does not contain any special characters, the original string.
      • escape

        public static java.lang.String escape​(java.lang.String string,
                                              boolean escapeNewLine)
      • escapeForTextArea

        public static java.lang.String escapeForTextArea​(java.lang.String string)
      • escape

        private static java.lang.String escape​(java.lang.String string,
                                               boolean escapeNewLine,
                                               boolean isTextArea)
      • escapeAttribute

        public static java.lang.String escapeAttribute​(java.lang.String string)
        Escape a string for use as an HTML attribute by replacing all double quotes and '&'.