Class Escaper

java.lang.Object
com.mackenziehigh.sexpr.internal.Escaper

public final class Escaper extends Object
Escaper.

Herein, an escape sequence is any one of the following substrings:

  • \b
  • \t
  • \n
  • \f
  • \r
  • \'
  • \"
  • \\
  • \ uWXYZ, where WXYZ is a four-digit hexadecimal Unicode character code.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Escaper
    This is the singleton instance of this class.
  • Method Summary

    Modifier and Type
    Method
    Description
    escape(char[] input)
    This method creates a string from a char-array, with each special-character replaced with a relevant escape sequence.
    char[]
    expand(String input)
    This method replaces escape sequences in a string with the equivalent special-characters and then returns the equivalent char-array.

    Methods inherited from class java.lang.Object

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

    • instance

      public static final Escaper instance
      This is the singleton instance of this class.
  • Method Details

    • escape

      public String escape(char[] input)
      This method creates a string from a char-array, with each special-character replaced with a relevant escape sequence.
      Parameters:
      input - will be converted to a string.
      Returns:
      the new string.
    • expand

      public char[] expand(String input)
      This method replaces escape sequences in a string with the equivalent special-characters and then returns the equivalent char-array.

      In short, X.equals(expand(escape(X))).

      Parameters:
      input - is an escaped string.
      Returns:
      the non-escaped char-array.