BasicUI
public abstract class AbstractUI
extends java.lang.Object
Modifier and Type | Class | Description |
---|---|---|
static class |
AbstractUI.Argument |
Provides the information needed by an application argument.
|
static class |
AbstractUI.Definition |
Provides a definition, that is a name and a description
|
static class |
AbstractUI.ExitCode |
Provides exit codes to be used by implementing classes.
|
static class |
AbstractUI.OptionalArgument |
Provides the information needed by an optional argument.
|
Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
ARG_PREFIX |
Prefix used for required arguments in the arguments map
|
Constructor | Description |
---|---|
AbstractUI() |
Creates a new AbstractUI using the default key/value delimiter '=' and
the default optional argument prefix '-'
|
Modifier and Type | Method | Description |
---|---|---|
void |
displayHelp(java.io.PrintStream ps) |
Displays a help text for the UI based on the implementation of
the methods getName, getOptionalArguments and getRequiredArguments.
|
static void |
exitWithCode(AbstractUI.ExitCode e) |
|
static void |
exitWithCode(AbstractUI.ExitCode e,
java.lang.String message) |
|
void |
expandShortForm(java.util.Map<java.lang.String,java.lang.String> map,
java.lang.String key,
ShortFormResolver resolver) |
Expands the short form of the value with the given key in the provided map using the specified resolver.
|
java.util.List<AbstractUI.Definition> |
getDefinitionList(FactoryCatalog<? extends Factory> catalog,
ShortFormResolver resolver) |
Creates a list of definitions based on the contents of the supplied FactoryCatalog.
|
abstract java.lang.String |
getName() |
Gets the name for the UI
|
java.util.Map<java.lang.String,java.lang.String> |
getOptional(java.lang.String[] args) |
|
abstract java.util.List<AbstractUI.OptionalArgument> |
getOptionalArguments() |
Gets optional arguments
|
java.util.List<java.lang.String> |
getRequired(java.lang.String[] args) |
|
abstract java.util.List<AbstractUI.Argument> |
getRequiredArguments() |
Gets required arguments
|
void |
setKeyValueDelimiter(java.lang.String value) |
Sets the delimiter to use between key and value in the argument
strings passed to the UI.
|
void |
setOptionalArgumentPrefix(java.lang.String value) |
Sets the optional argument prefix to use in argument strings passed to
the UI.
|
java.util.Map<java.lang.String,java.lang.String> |
toMap(java.lang.String[] args) |
Converts a string based definition of UI arguments, typically
passed by the main method, into a key-value map as described
by displayHelp
|
public static final java.lang.String ARG_PREFIX
public AbstractUI()
public void expandShortForm(java.util.Map<java.lang.String,java.lang.String> map, java.lang.String key, ShortFormResolver resolver)
map
- key
- resolver
- public java.util.List<AbstractUI.Definition> getDefinitionList(FactoryCatalog<? extends Factory> catalog, ShortFormResolver resolver)
catalog
- the catalog to create definitions forresolver
- public void setKeyValueDelimiter(java.lang.String value)
value
- the delimiter to usepublic void setOptionalArgumentPrefix(java.lang.String value)
value
- the prefix to usepublic abstract java.lang.String getName()
public abstract java.util.List<AbstractUI.Argument> getRequiredArguments()
public abstract java.util.List<AbstractUI.OptionalArgument> getOptionalArguments()
public java.util.Map<java.lang.String,java.lang.String> toMap(java.lang.String[] args)
args
- the arguments passed to the applicationpublic java.util.Map<java.lang.String,java.lang.String> getOptional(java.lang.String[] args)
public java.util.List<java.lang.String> getRequired(java.lang.String[] args)
public static void exitWithCode(AbstractUI.ExitCode e)
public static void exitWithCode(AbstractUI.ExitCode e, java.lang.String message)
public void displayHelp(java.io.PrintStream ps)
ps
- The print stream to use, typically System.out