public class ConsoleUIService extends AbstractExtensibleObject implements UIService
UIService implementation that sends messages to stdout and stderr.| Modifier and Type | Class and Description |
|---|---|
static class |
ConsoleUIService.ConsoleWrapper
Wrapper around
Console to allow replacements as needed. |
| Modifier and Type | Field and Description |
|---|---|
static String |
MINGW64 |
static String |
MINTTY |
static String |
MSYSTEM |
static String |
TERM_PROGRAM |
PRIORITY_DEFAULT, PRIORITY_NOT_APPLICABLE, PRIORITY_SPECIALIZED| Modifier | Constructor and Description |
|---|---|
|
ConsoleUIService() |
protected |
ConsoleUIService(ConsoleUIService.ConsoleWrapper console) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
getAllowPrompt()
Return current setting of allow prompt flag
|
protected ConsoleUIService.ConsoleWrapper |
getConsole()
Creates the
ConsoleUIService.ConsoleWrapper to use. |
PrintStream |
getErrorStream() |
boolean |
getOutputStackTraces() |
PrintStream |
getOutputStream() |
int |
getPriority()
Returns
Plugin.PRIORITY_NOT_APPLICABLE because it must be manually configured as needed |
<T> T |
prompt(String prompt,
T valueIfNoEntry,
InputHandler<T> inputHandler,
Class<T> type)
Prompt the user with the message and wait for a response.
If this UIService implementation does not support user prompts, return the default value. If inputHandler is null, DefaultInputHandler will be used.If inputHandler throws an IllegalArgumentException, the user will be given the chance to re-enter the value.If the inputHandler returns true for InputHandler.shouldAllowEmptyInput() and the user enters an empty value
when prompted, or hits "enter", the valueIfNoEntry will be returned. |
void |
sendErrorMessage(String message)
Send an "error" message to the user.
|
void |
sendErrorMessage(String message,
Throwable exception)
Send an "error" message to the user along with a stacktrace.
|
void |
sendMessage(String message)
Send a "normal" message to the user.
|
void |
setAllowPrompt(boolean allowPrompt)
Method to set flag indicating whether prompting is allowed
|
void |
setErrorStream(PrintStream errorStream) |
void |
setOutputStackTraces(boolean outputStackTraces)
Set to true to output stacktraces.
|
void |
setOutputStream(PrintStream outputStream) |
clone, describe, equals, get, get, get, getAttributes, getFieldValue, getObjectMetaData, getValuePath, has, hashCode, set, toStringfinalize, getClass, notify, notifyAll, wait, wait, waitclone, describe, get, get, getAttributes, getObjectMetaData, getValuePath, has, setpublic static final String TERM_PROGRAM
public static final String MINTTY
public static final String MSYSTEM
public static final String MINGW64
public ConsoleUIService()
protected ConsoleUIService(ConsoleUIService.ConsoleWrapper console)
public int getPriority()
Plugin.PRIORITY_NOT_APPLICABLE because it must be manually configured as neededgetPriority in interface UIServicepublic void sendMessage(String message)
UIServicesendMessage in interface UIServicepublic void sendErrorMessage(String message)
UIServicesendErrorMessage in interface UIServicepublic void sendErrorMessage(String message, Throwable exception)
UIServicesendErrorMessage in interface UIServicepublic void setAllowPrompt(boolean allowPrompt)
throws IllegalArgumentException
UIServicesetAllowPrompt in interface UIServiceallowPrompt - New flag valueIllegalArgumentException - If parameter is not allowedpublic boolean getAllowPrompt()
UIServicegetAllowPrompt in interface UIServicepublic <T> T prompt(String prompt, T valueIfNoEntry, InputHandler<T> inputHandler, Class<T> type)
UIServiceDefaultInputHandler will be used.IllegalArgumentException, the user will be given the chance to re-enter the value.InputHandler.shouldAllowEmptyInput() and the user enters an empty value
when prompted, or hits "enter", the valueIfNoEntry will be returned. If the inputHandler returns false for
InputHandler.shouldAllowEmptyInput(), the user will be reprompted until they enter a non-empty value,
which will then be returned.protected ConsoleUIService.ConsoleWrapper getConsole()
ConsoleUIService.ConsoleWrapper to use.public PrintStream getOutputStream()
public void setOutputStream(PrintStream outputStream)
public PrintStream getErrorStream()
public void setErrorStream(PrintStream errorStream)
public boolean getOutputStackTraces()
public void setOutputStackTraces(boolean outputStackTraces)
Copyright © 2022 Liquibase.org. All rights reserved.