Class CharEscaperBuilder.CharArrayDecorator

java.lang.Object
com.google.common.escape.Escaper
com.google.common.escape.CharEscaper
com.google.common.escape.CharEscaperBuilder.CharArrayDecorator
Enclosing class:
CharEscaperBuilder

private static class CharEscaperBuilder.CharArrayDecorator extends CharEscaper
Simple decorator that turns an array of replacement char[]s into a CharEscaper, this results in a very fast escape method.
  • Field Details

    • replacements

      private final char[][] replacements
    • replaceLength

      private final int replaceLength
  • Constructor Details

    • CharArrayDecorator

      CharArrayDecorator(char[][] replacements)
  • Method Details

    • escape

      public String escape(String s)
      Description copied from class: CharEscaper
      Returns the escaped form of a given literal string.
      Overrides:
      escape in class CharEscaper
      Parameters:
      s - the literal string to be escaped
      Returns:
      the escaped form of string
    • escape

      @CheckForNull protected char[] escape(char c)
      Description copied from class: CharEscaper
      Returns the escaped form of the given character, or null if this character does not need to be escaped. If an empty array is returned, this effectively strips the input character from the resulting text.

      If the character does not need to be escaped, this method should return null, rather than a one-character array containing the character itself. This enables the escaping algorithm to perform more efficiently.

      An escaper is expected to be able to deal with any char value, so this method should not throw any exceptions.

      Specified by:
      escape in class CharEscaper
      Parameters:
      c - the character to escape if necessary
      Returns:
      the replacement characters, or null if no escaping was needed