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 Summary
Enum Constants Enum Constant Description BG_BLACK
Black background color.BG_BLUE
Blue background color.BG_CYAN
Cyan background color.BG_GREEN
Green background color.BG_MAGENTA
Magenta background color.BG_RED
Red background color.BG_WHITE
White background color.BG_YELLOW
Yellow background color.BLACK
Black foreground color.BLINK
Blink general attribute.BLUE
Blue foreground color.BRIGHT
Bright general attribute.CSI
The Control Sequence Introducer (or Control Sequence Initiator).CYAN
Cyan foreground color.DEFAULT
Default foreground color.DIM
Dim general attribute.FG_BLACK
Black foreground color.FG_BLUE
Blue foreground color.FG_CYAN
Cyan foreground color.FG_DEFAULT
Default foreground color.FG_GREEN
Green foreground color.FG_MAGENTA
Magenta foreground color.FG_RED
Red foreground color.FG_WHITE
White foreground color.FG_YELLOW
Yellow foreground color.GREEN
Green foreground color.HIDDEN
Normal general attribute.MAGENTA
Magenta foreground color.NORMAL
Normal general attribute.RED
Red foreground color.REVERSE
Reverse general attribute.SEPARATOR
Escape separator.SUFFIX
Escape suffix.UNDERLINE
Underline general attribute.WHITE
White foreground color.YELLOW
Yellow foreground color.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Map<String,String>
createMap(String[] values, String[] dontEscapeKeys)
Creates a Map from a source array where values are ANSI escape sequences.static Map<String,String>
createMap(String values, String[] dontEscapeKeys)
Creates a Map from a source array where values are ANSI escape sequences.static String
createSequence(String... names)
Creates an ANSI escape sequence from the given AnsiEscape names.String
getCode()
Gets the escape code.static String
getDefaultStyle()
Gets the default style.static AnsiEscape
valueOf(String name)
Returns the enum constant of this type with the specified name.static AnsiEscape[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
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
Bright general attribute.
-
DIM
public static final AnsiEscape DIM
Dim general attribute.
-
UNDERLINE
public static final AnsiEscape UNDERLINE
Underline general attribute.
-
BLINK
public static final AnsiEscape BLINK
Blink 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.
-
-
Method Detail
-
values
public static AnsiEscape[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (AnsiEscape c : AnsiEscape.values()) System.out.println(c);
- 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 nameNullPointerException
- 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.
-
-