java.lang.Object
com.espertech.esper.common.internal.util.apachecommonstext.StringEscapeUtils

public class StringEscapeUtils extends Object

Escapes and unescapes Strings for Java, Java Script, HTML and XML.

#ThreadSafe#

This code has been adapted from Apache Commons Lang 3.5.

Since:
1.0
  • Field Details

    • ESCAPE_JAVA

      public static final CharSequenceTranslator ESCAPE_JAVA
      Translator object for escaping Java.

      While escapeJava(String) is the expected method of use, this object allows the Java escaping functionality to be used as the foundation for a custom translator.

  • Constructor Details

    • StringEscapeUtils

      public StringEscapeUtils()

      StringEscapeUtils instances should NOT be constructed in standard programming.

      Instead, the class should be used as:

      StringEscapeUtils.escapeJava("foo");

      This constructor is public to permit tools that require a JavaBean instance to operate.

  • Method Details

    • builder

      public static StringEscapeUtils.Builder builder(CharSequenceTranslator translator)
      Parameters:
      translator - the text translator
      Returns:
      StringEscapeUtils.Builder
    • escapeJava

      public static final String escapeJava(String input)

      Escapes the characters in a String using Java String rules.

      Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.)

      So a tab becomes the characters '\\' and 't'.

      The only difference between Java strings and JavaScript strings is that in JavaScript, a single quote and forward-slash (/) are escaped.

      Example:

       input string: He didn't say, "Stop!"
       output string: He didn't say, \"Stop!\"
       
      Parameters:
      input - String to escape values in, may be null
      Returns:
      String with escaped values, null if null string input