Enum AnsiEscape
- java.lang.Object
-
- java.lang.Enum<AnsiEscape>
-
- org.apache.logging.log4j.core.pattern.AnsiEscape
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Comparable<AnsiEscape>
public enum AnsiEscape extends java.lang.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_BLACKBlack background color.BG_BLUEBlue background color.BG_BRIGHT_BLACKBright black background color.BG_BRIGHT_BLUEBright blue background color.BG_BRIGHT_CYANBright cyan background color.BG_BRIGHT_GREENBright green background color.BG_BRIGHT_MAGENTABright magenta background color.BG_BRIGHT_REDBright red background color.BG_BRIGHT_WHITEBright white background color.BG_BRIGHT_YELLOWBright yellow background color.BG_CYANCyan background color.BG_GREENGreen background color.BG_MAGENTAMagenta background color.BG_REDRed background color.BG_WHITEWhite background color.BG_YELLOWYellow background color.BLACKBlack foreground color.BLINKBlink general attribute.BLUEBlue foreground color.BOLDBold general attribute.BRIGHTDeprecated.This attribute sets font-weight as "bold" and doesn't set color brightness.BRIGHT_BLACKBright black foreground color.BRIGHT_BLUEBright blue foreground color.BRIGHT_CYANBright cyan foreground color.BRIGHT_GREENBright green foreground color.BRIGHT_MAGENTABright magenta foreground color.BRIGHT_REDBright red foreground color.BRIGHT_WHITEBright white foreground color.BRIGHT_YELLOWBright yellow foreground color.CSIThe Control Sequence Introducer (or Control Sequence Initiator).CYANCyan foreground color.DEFAULTDefault foreground color.DIMDim general attribute.FG_BLACKBlack foreground color.FG_BLUEBlue foreground color.FG_BRIGHT_BLACKBright black foreground color.FG_BRIGHT_BLUEBright blue foreground color.FG_BRIGHT_CYANBright cyan foreground color.FG_BRIGHT_GREENBright green foreground color.FG_BRIGHT_MAGENTABright magenta foreground color.FG_BRIGHT_REDBright red foreground color.FG_BRIGHT_WHITEBright white foreground color.FG_BRIGHT_YELLOWBright yellow foreground color.FG_CYANCyan foreground color.FG_DEFAULTDefault foreground color.FG_GREENGreen foreground color.FG_MAGENTAMagenta foreground color.FG_REDRed foreground color.FG_WHITEWhite foreground color.FG_YELLOWYellow foreground color.GREENGreen foreground color.HIDDENNormal general attribute.MAGENTAMagenta foreground color.NORMALNormal general attribute.REDRed foreground color.REVERSEReverse general attribute.SEPARATOREscape separator.SUFFIXEscape suffix.UNDERLINEUnderline general attribute.WHITEWhite foreground color.YELLOWYellow foreground color.
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Stringcodeprivate static java.lang.StringDEFAULT_STYLE
-
Constructor Summary
Constructors Modifier Constructor Description privateAnsiEscape(java.lang.String code)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.Map<java.lang.String,java.lang.String>createMap(java.lang.String[] values, java.lang.String[] dontEscapeKeys)Creates a Map from a source array where values are ANSI escape sequences.static java.util.Map<java.lang.String,java.lang.String>createMap(java.lang.String values, java.lang.String[] dontEscapeKeys)Creates a Map from a source array where values are ANSI escape sequences.static java.lang.StringcreateSequence(java.lang.String... names)Creates an ANSI escape sequence from the given AnsiEscape names.java.lang.StringgetCode()Gets the escape code.static java.lang.StringgetDefaultStyle()Gets the default style.static AnsiEscapevalueOf(java.lang.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
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.
-
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.
-
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 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(java.lang.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:
java.lang.IllegalArgumentException- if this enum type has no constant with the specified namejava.lang.NullPointerException- if the argument is null
-
getDefaultStyle
public static java.lang.String getDefaultStyle()
Gets the default style.- Returns:
- the default style
-
getCode
public java.lang.String getCode()
Gets the escape code.- Returns:
- the escape code.
-
createMap
public static java.util.Map<java.lang.String,java.lang.String> createMap(java.lang.String values, java.lang.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 java.util.Map<java.lang.String,java.lang.String> createMap(java.lang.String[] values, java.lang.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 java.lang.String createSequence(java.lang.String... names)
Creates an ANSI escape sequence from the given AnsiEscape names.- Parameters:
names- AnsiEscape names.- Returns:
- An ANSI escape sequence.
-
-