Enum AnsiColorEscapeCodes
- java.lang.Object
-
- java.lang.Enum<AnsiColorEscapeCodes>
-
- de.bernd_michaely.common.cli.parser.AnsiColorEscapeCodes
-
- All Implemented Interfaces:
Serializable
,Comparable<AnsiColorEscapeCodes>
public enum AnsiColorEscapeCodes extends Enum<AnsiColorEscapeCodes>
ANSI escape sequences for 3/4 bit colors.- See Also:
- ANSI escape code
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static String
formatAsAnsiColored(String s, AnsiColorEscapeCodes colorFg, AnsiColorEscapeCodes colorBg, boolean bright)
Returns a color formatted version of the provided string.int
getBgCode(boolean bright)
Returns the background color code.int
getFgCode(boolean bright)
Returns the foreground color code.static AnsiColorEscapeCodes
valueOf(String name)
Returns the enum constant of this type with the specified name.static AnsiColorEscapeCodes[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
BLACK
public static final AnsiColorEscapeCodes BLACK
-
RED
public static final AnsiColorEscapeCodes RED
-
GREEN
public static final AnsiColorEscapeCodes GREEN
-
YELLOW
public static final AnsiColorEscapeCodes YELLOW
-
BLUE
public static final AnsiColorEscapeCodes BLUE
-
MAGENTA
public static final AnsiColorEscapeCodes MAGENTA
-
CYAN
public static final AnsiColorEscapeCodes CYAN
-
WHITE
public static final AnsiColorEscapeCodes WHITE
-
-
Method Detail
-
values
public static AnsiColorEscapeCodes[] 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 (AnsiColorEscapeCodes c : AnsiColorEscapeCodes.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static AnsiColorEscapeCodes 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
-
getFgCode
public int getFgCode(boolean bright)
Returns the foreground color code.- Parameters:
bright
- true for bright color- Returns:
- the foreground color code
-
getBgCode
public int getBgCode(boolean bright)
Returns the background color code.- Parameters:
bright
- true for bright color- Returns:
- the background color code
-
formatAsAnsiColored
public static String formatAsAnsiColored(String s, AnsiColorEscapeCodes colorFg, AnsiColorEscapeCodes colorBg, boolean bright)
Returns a color formatted version of the provided string.- Parameters:
s
- the provided stringcolorFg
- the foreground color (null for no coloring)colorBg
- the background color (null for no coloring)bright
- true for bright color- Returns:
- a color formatted version of the provided string (the empty string in case of a null value)
-
-