public abstract class Terminal
extends java.lang.Object
Console
, with the ability
to read either normal text or a password, and the ability to print a line
of text. Printing is also gated by the Terminal.Verbosity
of the terminal,
which allows println(Verbosity,String)
calls which act like a logger,
only actually printing if the verbosity level of the terminal is above
the verbosity of the message.Modifier and Type | Class | Description |
---|---|---|
static class |
Terminal.Verbosity |
Defines the available verbosity levels of messages to be printed.
|
Modifier and Type | Field | Description |
---|---|---|
static Terminal |
DEFAULT |
The default terminal implementation, which will be a console if available, or stdout/stderr if not.
|
Modifier | Constructor | Description |
---|---|---|
protected |
Terminal(java.lang.String lineSeparator) |
Modifier and Type | Method | Description |
---|---|---|
abstract java.io.PrintWriter |
getWriter() |
Returns a Writer which can be used to write to the terminal directly.
|
void |
print(Terminal.Verbosity verbosity,
java.lang.String msg) |
Prints message to the terminal at
verbosity level, without a newline. |
void |
println(java.lang.String msg) |
Prints a line to the terminal at
Terminal.Verbosity.NORMAL verbosity level. |
void |
println(Terminal.Verbosity verbosity,
java.lang.String msg) |
Prints a line to the terminal at
verbosity level. |
boolean |
promptYesNo(java.lang.String prompt,
boolean defaultYes) |
Prompt for a yes or no answer from the user.
|
abstract char[] |
readSecret(java.lang.String prompt) |
Reads password text from the terminal input.
|
abstract java.lang.String |
readText(java.lang.String prompt) |
Reads clear text from the terminal input.
|
void |
setVerbosity(Terminal.Verbosity verbosity) |
Sets the verbosity of the terminal.
|
public static final Terminal DEFAULT
public void setVerbosity(Terminal.Verbosity verbosity)
public abstract java.lang.String readText(java.lang.String prompt)
Console.readLine()
.public abstract char[] readSecret(java.lang.String prompt)
Console.readPassword()
}.public abstract java.io.PrintWriter getWriter()
public final void println(java.lang.String msg)
Terminal.Verbosity.NORMAL
verbosity level.public final void println(Terminal.Verbosity verbosity, java.lang.String msg)
verbosity
level.public final void print(Terminal.Verbosity verbosity, java.lang.String msg)
verbosity
level, without a newline.public final boolean promptYesNo(java.lang.String prompt, boolean defaultYes)