Enum Class EscapeCode

java.lang.Object
java.lang.Enum<EscapeCode>
org.refcodes.data.EscapeCode
All Implemented Interfaces:
Serializable, Comparable<EscapeCode>, Constable

public enum EscapeCode extends Enum<EscapeCode>
The EscapeCode enumeration contains all of Java's escape codes (https://docs.oracle.com/javase/tutorial/java/data/characters.html) and the escape sequences (being the defused escape codes) as well as methods to retrieve the escape code from the escape sequence (as of toEscapeCode(String)) and vice versa (as of toEscapeCode(char)).
  • Enum Constant Details

    • TAB

      public static final EscapeCode TAB
    • BACKSPACE

      public static final EscapeCode BACKSPACE
    • NEWLINE

      public static final EscapeCode NEWLINE
    • CARRIAGE_RETURN

      public static final EscapeCode CARRIAGE_RETURN
    • FORM_FEED

      public static final EscapeCode FORM_FEED
    • SINGLE_QUOTE

      public static final EscapeCode SINGLE_QUOTE
    • DOUBLE_QUOTE

      public static final EscapeCode DOUBLE_QUOTE
    • BASCKSLASH

      public static final EscapeCode BASCKSLASH
  • Method Details

    • values

      public static EscapeCode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static EscapeCode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • getEscapeSequence

      public String getEscapeSequence()
      Retrieves the escape sequence String for the according EscapeCode being the escaped escape code.
      Returns:
      The according escape sequence.
    • getEscapeCode

      public char getEscapeCode()
      Retrieves the escape code character for the according EscapeCode.
      Returns:
      The according escape code.
    • toEscapeCode

      public static EscapeCode toEscapeCode(char aEscapeCode)
      Translate the provided EscapeCode character to the according escape sequence.
      Parameters:
      aEscapeCode - The escape code character to translate to the according EscapeCode element.
      Returns:
      The according EscapeCode or null if the provided escape code did not represent an escape code as of the EscapeCode enumeration.
    • toEscapeCode

      public static EscapeCode toEscapeCode(String aEscapeSequence)
      Translate the provided escape sequence to the according EscapeCode element.
      Parameters:
      aEscapeSequence - The escape sequence to translate to the according EscapeCode element.
      Returns:
      The according EscapeCode or null if the provided escape code did not represent an escape code as of the EscapeCode enumeration.