public class ConsoleMessageHandler extends MessageHandler
Modifier and Type | Field and Description |
---|---|
protected java.io.PrintStream |
err
Print stream for error messages.
|
protected java.io.PrintStream |
out
Print stream for progress messages.
|
protected boolean |
verbose
Indicates if stack traces for exceptions should be shown.
|
Constructor and Description |
---|
ConsoleMessageHandler()
Creates a new handler that writes to the "standard out" and
"standard err" streams of the process.
|
ConsoleMessageHandler(java.io.PrintStream out)
Creates a message handler writing all messages to a single stream.
|
ConsoleMessageHandler(java.io.PrintStream out,
java.io.PrintStream err)
Creates a message handler writing progress and error messages to separate
streams.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
getErrorMessageText(java.util.List<Problem> problems,
boolean verbose)
Creates an error report for a list of problems.
|
void |
message(java.lang.String s,
int progress)
Reports a calculation progress message.
|
void |
reportError(java.util.List<Problem> problems)
Reports a list of errors.
|
void |
setVerbose(boolean verbose)
Switch verbose output on or off.
|
finishedComputation, reportError, reportError
protected java.io.PrintStream out
protected java.io.PrintStream err
protected boolean verbose
public ConsoleMessageHandler()
public ConsoleMessageHandler(java.io.PrintStream out)
out
- The stream to write to.public ConsoleMessageHandler(java.io.PrintStream out, java.io.PrintStream err)
out
- Stream for progress messages.err
- Stream for error messages.public void setVerbose(boolean verbose)
verbose
- true
for verbose outputpublic void message(java.lang.String s, int progress)
MessageHandler
message
in class MessageHandler
s
- Describes the calculation currently being performed. If
the string is null
, the currently shown message
remains the same, only the progress indicator is to be updated.progress
- Integer between 0 and 100 indicating the progress
(100=finished). If progress is negative, the currently shown
progress remains the same, only the message is to be updated.public void reportError(java.util.List<Problem> problems)
MessageHandler
reportError
in class MessageHandler
problems
- The list of problems to report.public static java.lang.String getErrorMessageText(java.util.List<Problem> problems, boolean verbose)
Returns a string containing the error reported created by
reportError(List)
.
problems
- List of problems to report.verbose
- Set to true
for verbose output with exception
stack traces