Enum AnsiEscape

java.lang.Object
java.lang.Enum<AnsiEscape>
org.apache.logging.log4j.core.pattern.AnsiEscape
All Implemented Interfaces:
Serializable, Comparable<AnsiEscape>

public enum AnsiEscape extends Enum<AnsiEscape>
Converts text into ANSI escape sequences.

The names for colors and attributes are standard, but the exact shade/hue/value of colors are not, and depend on the device used to display them.

  • Enum Constant Details

    • CSI

      public static final AnsiEscape CSI
      The Control Sequence Introducer (or Control Sequence Initiator).

      Most sequences are more than two characters and start with the characters ESC and [ (the left bracket).

    • SUFFIX

      public static final AnsiEscape SUFFIX
      Escape suffix.
    • SEPARATOR

      public static final AnsiEscape SEPARATOR
      Escape separator.
    • NORMAL

      public static final AnsiEscape NORMAL
      Normal general attribute.
    • BRIGHT

      public static final AnsiEscape BRIGHT
      Deprecated.
      This attribute sets font-weight as "bold" and doesn't set color brightness. Use BOLD if you need to change font-weight and BRIGHT_* to use a bright color.
      Bright general attribute.
    • BOLD

      public static final AnsiEscape BOLD
      Bold general attribute.
    • DIM

      public static final AnsiEscape DIM
      Dim general attribute.
    • UNDERLINE

      public static final AnsiEscape UNDERLINE
      Underline general attribute.
    • REVERSE

      public static final AnsiEscape REVERSE
      Reverse general attribute.
    • HIDDEN

      public static final AnsiEscape HIDDEN
      Normal general attribute.
    • BLACK

      public static final AnsiEscape BLACK
      Black foreground color.
    • FG_BLACK

      public static final AnsiEscape FG_BLACK
      Black foreground color.
    • RED

      public static final AnsiEscape RED
      Red foreground color.
    • FG_RED

      public static final AnsiEscape FG_RED
      Red foreground color.
    • GREEN

      public static final AnsiEscape GREEN
      Green foreground color.
    • FG_GREEN

      public static final AnsiEscape FG_GREEN
      Green foreground color.
    • YELLOW

      public static final AnsiEscape YELLOW
      Yellow foreground color.
    • FG_YELLOW

      public static final AnsiEscape FG_YELLOW
      Yellow foreground color.
    • BLUE

      public static final AnsiEscape BLUE
      Blue foreground color.
    • FG_BLUE

      public static final AnsiEscape FG_BLUE
      Blue foreground color.
    • MAGENTA

      public static final AnsiEscape MAGENTA
      Magenta foreground color.
    • FG_MAGENTA

      public static final AnsiEscape FG_MAGENTA
      Magenta foreground color.
    • CYAN

      public static final AnsiEscape CYAN
      Cyan foreground color.
    • FG_CYAN

      public static final AnsiEscape FG_CYAN
      Cyan foreground color.
    • WHITE

      public static final AnsiEscape WHITE
      White foreground color.
    • FG_WHITE

      public static final AnsiEscape FG_WHITE
      White foreground color.
    • DEFAULT

      public static final AnsiEscape DEFAULT
      Default foreground color.
    • FG_DEFAULT

      public static final AnsiEscape FG_DEFAULT
      Default foreground color.
    • BG_BLACK

      public static final AnsiEscape BG_BLACK
      Black background color.
    • BG_RED

      public static final AnsiEscape BG_RED
      Red background color.
    • BG_GREEN

      public static final AnsiEscape BG_GREEN
      Green background color.
    • BG_YELLOW

      public static final AnsiEscape BG_YELLOW
      Yellow background color.
    • BG_BLUE

      public static final AnsiEscape BG_BLUE
      Blue background color.
    • BG_MAGENTA

      public static final AnsiEscape BG_MAGENTA
      Magenta background color.
    • BG_CYAN

      public static final AnsiEscape BG_CYAN
      Cyan background color.
    • BG_WHITE

      public static final AnsiEscape BG_WHITE
      White background color.
    • BRIGHT_BLACK

      public static final AnsiEscape BRIGHT_BLACK
      Bright black foreground color.
    • FG_BRIGHT_BLACK

      public static final AnsiEscape FG_BRIGHT_BLACK
      Bright black foreground color.
    • BRIGHT_RED

      public static final AnsiEscape BRIGHT_RED
      Bright red foreground color.
    • FG_BRIGHT_RED

      public static final AnsiEscape FG_BRIGHT_RED
      Bright red foreground color.
    • BRIGHT_GREEN

      public static final AnsiEscape BRIGHT_GREEN
      Bright green foreground color.
    • FG_BRIGHT_GREEN

      public static final AnsiEscape FG_BRIGHT_GREEN
      Bright green foreground color.
    • BRIGHT_YELLOW

      public static final AnsiEscape BRIGHT_YELLOW
      Bright yellow foreground color.
    • FG_BRIGHT_YELLOW

      public static final AnsiEscape FG_BRIGHT_YELLOW
      Bright yellow foreground color.
    • BRIGHT_BLUE

      public static final AnsiEscape BRIGHT_BLUE
      Bright blue foreground color.
    • FG_BRIGHT_BLUE

      public static final AnsiEscape FG_BRIGHT_BLUE
      Bright blue foreground color.
    • BRIGHT_MAGENTA

      public static final AnsiEscape BRIGHT_MAGENTA
      Bright magenta foreground color.
    • FG_BRIGHT_MAGENTA

      public static final AnsiEscape FG_BRIGHT_MAGENTA
      Bright magenta foreground color.
    • BRIGHT_CYAN

      public static final AnsiEscape BRIGHT_CYAN
      Bright cyan foreground color.
    • FG_BRIGHT_CYAN

      public static final AnsiEscape FG_BRIGHT_CYAN
      Bright cyan foreground color.
    • BRIGHT_WHITE

      public static final AnsiEscape BRIGHT_WHITE
      Bright white foreground color.
    • FG_BRIGHT_WHITE

      public static final AnsiEscape FG_BRIGHT_WHITE
      Bright white foreground color.
    • BG_BRIGHT_BLACK

      public static final AnsiEscape BG_BRIGHT_BLACK
      Bright black background color.
    • BG_BRIGHT_RED

      public static final AnsiEscape BG_BRIGHT_RED
      Bright red background color.
    • BG_BRIGHT_GREEN

      public static final AnsiEscape BG_BRIGHT_GREEN
      Bright green background color.
    • BG_BRIGHT_YELLOW

      public static final AnsiEscape BG_BRIGHT_YELLOW
      Bright yellow background color.
    • BG_BRIGHT_BLUE

      public static final AnsiEscape BG_BRIGHT_BLUE
      Bright blue background color.
    • BG_BRIGHT_MAGENTA

      public static final AnsiEscape BG_BRIGHT_MAGENTA
      Bright magenta background color.
    • BG_BRIGHT_CYAN

      public static final AnsiEscape BG_BRIGHT_CYAN
      Bright cyan background color.
    • BG_BRIGHT_WHITE

      public static final AnsiEscape BG_BRIGHT_WHITE
      Bright white background color.
  • Method Details

    • values

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

      public static AnsiEscape valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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 type has no constant with the specified name
      NullPointerException - if the argument is null
    • getDefaultStyle

      public static String getDefaultStyle()
      Gets the default style.
      Returns:
      the default style
    • getCode

      public String getCode()
      Gets the escape code.
      Returns:
      the escape code.
    • createMap

      public static Map<String,String> createMap(String values, String[] dontEscapeKeys)
      Creates a Map from a source array where values are ANSI escape sequences. The format is:
       Key1=Value, Key2=Value, ...
       
      For example:
       ERROR=red bold, WARN=yellow bold, INFO=green, ...
       
      You can use whitespace around the comma and equal sign. The names in values MUST come from the AnsiEscape enum, case is normalized to upper-case internally.
      Parameters:
      values - the source string to parse.
      dontEscapeKeys - do not escape these keys, leave the values as is in the map
      Returns:
      a new map
    • createMap

      public static Map<String,String> createMap(String[] values, String[] dontEscapeKeys)
      Creates a Map from a source array where values are ANSI escape sequences. Each array entry must be in the format:
       Key1 = Value
       
      For example:
       ERROR=red bold
       
      You can use whitespace around the equal sign and between the value elements. The names in values MUST come from the AnsiEscape enum, case is normalized to upper-case internally.
      Parameters:
      values - the source array to parse.
      dontEscapeKeys - do not escape these keys, leave the values as is in the map
      Returns:
      a new map
    • createSequence

      public static String createSequence(String... names)
      Creates an ANSI escape sequence from the given AnsiEscape names.
      Parameters:
      names - AnsiEscape names.
      Returns:
      An ANSI escape sequence.