Package liquibase.ui
Class ConsoleUIService
- java.lang.Object
-
- liquibase.AbstractExtensibleObject
-
- liquibase.ui.ConsoleUIService
-
- All Implemented Interfaces:
Cloneable
,ExtensibleObject
,Plugin
,UIService
- Direct Known Subclasses:
MavenUi
public class ConsoleUIService extends AbstractExtensibleObject implements UIService
UIService
implementation that sends messages to stdout and stderr.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ConsoleUIService.ConsoleWrapper
Wrapper aroundConsole
to allow replacements as needed.
-
Field Summary
Fields Modifier and Type Field Description static String
MINGW64
static String
MINTTY
static String
MSYSTEM
static String
TERM_PROGRAM
-
Fields inherited from interface liquibase.plugin.Plugin
PRIORITY_DATABASE, PRIORITY_DEFAULT, PRIORITY_NOT_APPLICABLE, PRIORITY_SPECIALIZED
-
-
Constructor Summary
Constructors Modifier Constructor Description ConsoleUIService()
protected
ConsoleUIService(ConsoleUIService.ConsoleWrapper console)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getAllowPrompt()
Return current setting of allow prompt flagprotected ConsoleUIService.ConsoleWrapper
getConsole()
Creates theConsoleUIService.ConsoleWrapper
to use.PrintStream
getErrorStream()
boolean
getOutputStackTraces()
PrintStream
getOutputStream()
int
getPriority()
ReturnsPlugin.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 anIllegalArgumentException
, the user will be given the chance to re-enter the value.
If the inputHandler returns true forInputHandler.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 allowedvoid
setErrorStream(PrintStream errorStream)
void
setOutputStackTraces(boolean outputStackTraces)
Set to true to output stacktraces.void
setOutputStream(PrintStream outputStream)
-
Methods inherited from class liquibase.AbstractExtensibleObject
clone, describe, equals, get, get, get, getAttributes, getFieldValue, getObjectMetaData, getValuePath, has, hashCode, set, toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface liquibase.ExtensibleObject
clone, describe, get, get, getAttributes, getObjectMetaData, getValuePath, has, set
-
-
-
-
Field Detail
-
TERM_PROGRAM
public static final String TERM_PROGRAM
- See Also:
- Constant Field Values
-
MINTTY
public static final String MINTTY
- See Also:
- Constant Field Values
-
MSYSTEM
public static final String MSYSTEM
- See Also:
- Constant Field Values
-
MINGW64
public static final String MINGW64
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConsoleUIService
public ConsoleUIService()
-
ConsoleUIService
protected ConsoleUIService(ConsoleUIService.ConsoleWrapper console)
-
-
Method Detail
-
getPriority
public int getPriority()
ReturnsPlugin.PRIORITY_NOT_APPLICABLE
because it must be manually configured as needed- Specified by:
getPriority
in interfaceUIService
-
sendMessage
public void sendMessage(String message)
Description copied from interface:UIService
Send a "normal" message to the user.- Specified by:
sendMessage
in interfaceUIService
-
sendErrorMessage
public void sendErrorMessage(String message)
Description copied from interface:UIService
Send an "error" message to the user.- Specified by:
sendErrorMessage
in interfaceUIService
-
sendErrorMessage
public void sendErrorMessage(String message, Throwable exception)
Description copied from interface:UIService
Send an "error" message to the user along with a stacktrace.- Specified by:
sendErrorMessage
in interfaceUIService
-
setAllowPrompt
public void setAllowPrompt(boolean allowPrompt) throws IllegalArgumentException
Description copied from interface:UIService
Method to set flag indicating whether prompting is allowed- Specified by:
setAllowPrompt
in interfaceUIService
- Parameters:
allowPrompt
- New flag value- Throws:
IllegalArgumentException
- If parameter is not allowed
-
getAllowPrompt
public boolean getAllowPrompt()
Description copied from interface:UIService
Return current setting of allow prompt flag- Specified by:
getAllowPrompt
in interfaceUIService
- Returns:
- boolean
-
prompt
public <T> T prompt(String prompt, T valueIfNoEntry, InputHandler<T> inputHandler, Class<T> type)
Description copied from interface:UIService
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 anIllegalArgumentException
, the user will be given the chance to re-enter the value.
If the inputHandler returns true forInputHandler.shouldAllowEmptyInput()
and the user enters an empty value when prompted, or hits "enter", the valueIfNoEntry will be returned. If the inputHandler returns false forInputHandler.shouldAllowEmptyInput()
, the user will be reprompted until they enter a non-empty value, which will then be returned.
-
getConsole
protected ConsoleUIService.ConsoleWrapper getConsole()
Creates theConsoleUIService.ConsoleWrapper
to use.
-
getOutputStream
public PrintStream getOutputStream()
-
setOutputStream
public void setOutputStream(PrintStream outputStream)
-
getErrorStream
public PrintStream getErrorStream()
-
setErrorStream
public void setErrorStream(PrintStream errorStream)
-
getOutputStackTraces
public boolean getOutputStackTraces()
-
setOutputStackTraces
public void setOutputStackTraces(boolean outputStackTraces)
Set to true to output stacktraces. Defaults to not outputing them.
-
-