public class ConsoleHelper extends Object
addText(java.lang.String) or addText(org.mdiutil.lang.console.EscapedText) foee each portion of textEscapedTextprint() or println()ConsoleSerializers to the ConsoleHelper by calling
addConsoleSerializer(org.mdiutil.lang.console.ConsoleSerializer).
Serializers allow to serialize the content which has been printed to the console to a text or an HTML file.
ConsoleHelper helper = new ConsoleHelper();
helper.addText("The ");
EscapedText text = helper.addText("Blue text);
text.setForeground(EscapedColor.BLUE);
helper.println();
| Constructor and Description |
|---|
ConsoleHelper() |
| Modifier and Type | Method and Description |
|---|---|
void |
addConsoleSerializer(ConsoleSerializer serializer)
Add a console serializer.
|
void |
addText(EscapedText escText)
Add a portion of escaped text.
|
EscapedText |
addText(String text)
Add a portion of text.
|
EscapedText |
addText(String text,
short foreground)
Add a portion of escaped text.
|
EscapedText |
addText(String text,
short foreground,
int style)
Add a portion of escaped text.
|
EscapedText |
addText(String text,
short foreground,
short background,
int style)
Add a portion of escaped text.This is equivalent to:
EscapedText escText = addText(text);
escText.setForeground(foreground);
escText.setBackground(background);
escText.setStyle(style);
|
void |
clear()
Clear the current line of text
|
void |
err(String text)
Add and print a line of red text.
|
List<ConsoleSerializer> |
getConsoleSerializers()
Return the console serializers.
|
List<EscapedText> |
getText()
Return the current line of text.
|
void |
print()
Print the current line of text, without a new line.
|
void |
println()
Print the current line of text, with a new line.
|
void |
println(EscapedText escText)
Add and print a portion of escaped text, with a new line.
|
void |
println(String text,
short foreground)
Add and print a line of escaped text.
|
void |
println(String text,
short foreground,
int style)
Add and print a line of escaped text.
|
void |
println(String text,
short foreground,
short background,
int style)
Add and print a line of escaped text.
|
void |
printText(EscapedText escText)
Add and print a portion of escaped text.
|
public void addText(EscapedText escText)
escText - the escaped textpublic EscapedText addText(String text, short foreground)
EscapedText escText = addText(text); escText.setForeground(foreground);
text - the textforeground - the text foregroundpublic EscapedText addText(String text, short foreground, int style)
EscapedText escText = addText(text); escText.setForeground(foreground); escText.setStyle(style);
text - the textforeground - the text foregroundstyle - the text stylepublic EscapedText addText(String text, short foreground, short background, int style)
EscapedText escText = addText(text); escText.setForeground(foreground); escText.setBackground(background); escText.setStyle(style);
text - the textforeground - the text foregroundbackground - the text backgroundstyle - the text stylepublic void printText(EscapedText escText)
escText - the escaped textpublic void println(EscapedText escText)
escText - the escaped textpublic void println(String text, short foreground)
EscapedText escText = addText(text); escText.setForeground(foreground); println();
text - the textforeground - the text foregroundpublic void err(String text)
EscapedText escText = addText(text); escText.setForeground(EscapedColor.RED); println();
text - the textpublic void println(String text, short foreground, int style)
EscapedText escText = addText(text); escText.setForeground(foreground); escText.setStyle(style); println();
text - the textforeground - the text foregroundstyle - the text stylepublic void println(String text, short foreground, short background, int style)
EscapedText escText = addText(text); escText.setForeground(foreground); escText.setBackground(background); escText.setStyle(style); println();
text - the textforeground - the text foregroundbackground - the text backgroundstyle - the text stylepublic EscapedText addText(String text)
text - the textpublic void addConsoleSerializer(ConsoleSerializer serializer)
serializer - the serializerpublic List<ConsoleSerializer> getConsoleSerializers()
public List<EscapedText> getText()
public void clear()
public void println()
public void print()