|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectthings.common.commands.CommandRoot
public abstract class CommandRoot
Command root for all the commands.
It will automatically expect a root directory as the first entity (#0). This one is reserved. You can have scripts or wrappers obfuscate it if none of your commands care about it.
Version History
EPG - Initial - 1 NOV 01 EPG - Welded more tightly into the system, inclufing logging. - 10 AUG 06
Field Summary | |
---|---|
ThingsPropertyReaderToolkit |
configProps
Configuration properties, if provided. |
ThingsPropertyView |
configPropsView
Configuration properties from a writable view, if provided. |
Logger |
defaultLogger
A default logger. |
static int |
ENTITY_ROOT_DIRECTORY
Built-in entities. |
static int |
OPTION_HELP1
|
static int |
OPTION_HELP2
|
static int |
OPTION_VERBOSE
Built-in options. |
ThingsPropertyReaderToolkit |
valueProps
Value properties, if provided. |
ThingsPropertyView |
valuePropsView
Value properties from a writable view, if provided. |
static java.lang.String |
VALUES_CONFIGURATION
Build-in values |
static java.lang.String |
VALUES_VALUES
|
Constructor Summary | |
---|---|
CommandRoot()
The constructor. |
Method Summary | |
---|---|
protected abstract void |
declare()
Declare usage. |
protected void |
declareEntities(int name,
java.lang.String helpText,
boolean isRequired)
Declare an entity. |
protected void |
declareOption(int option,
java.lang.String helpText)
Declare an option. |
protected void |
declareValues(java.lang.String name,
java.lang.String helpText,
boolean isRequired)
Declare a value. |
protected void |
ERROR(java.lang.String message)
Raise an error and let the command root render it to the user. |
protected void |
ERROR(java.lang.String message,
java.lang.Throwable t)
Raise an error and let the command root render it to the user. |
java.io.PrintWriter |
getConsole()
Get the console print writer. |
java.lang.String |
getEntity(int item)
Get an entity (numbered parameter). |
java.lang.String |
getEntityRequired(int item,
java.lang.String message)
Get an entity (numbered parameter). |
protected java.lang.String |
getFooter()
OVERRIDE IF YOU WANT TO PROVIDE PARAMETER INFORMATION to the command help. |
protected java.lang.String |
getHeader()
OVERRIDE IF YOU WANT TO PROVIDE MORE INFO in the help about what the command does. |
protected abstract java.lang.String |
getName()
Get the command name. |
protected abstract java.lang.String |
getToken()
Get the command token. |
java.lang.String |
getValue(java.lang.String name)
Get a value. |
void |
mainEntry(java.lang.String[] args)
A main entry for the command. |
protected int |
numberOfEntites()
Get the number of entities. |
protected int |
numberOfValues()
Get the number of values. |
boolean |
optionIsSet(int character)
Convenience to check if an option is set. |
abstract void |
run()
Run the command. |
protected void |
suppressListingRootInstallEntity()
When called during declaration, any subsequent list or help will not show the install root entity. |
void |
usage()
Print the usage (help). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int OPTION_VERBOSE
public static final int OPTION_HELP1
public static final int OPTION_HELP2
public static final java.lang.String VALUES_CONFIGURATION
public static final java.lang.String VALUES_VALUES
public static final int ENTITY_ROOT_DIRECTORY
public ThingsPropertyReaderToolkit configProps
public ThingsPropertyReaderToolkit valueProps
public ThingsPropertyView valuePropsView
public ThingsPropertyView configPropsView
public Logger defaultLogger
Constructor Detail |
---|
public CommandRoot() throws java.lang.Throwable
java.lang.Throwable
Method Detail |
---|
protected abstract void declare() throws java.lang.Throwable
java.lang.Throwable
public abstract void run() throws java.lang.Throwable
java.lang.Throwable
protected abstract java.lang.String getName()
protected abstract java.lang.String getToken()
protected java.lang.String getHeader()
protected java.lang.String getFooter()
protected void declareOption(int option, java.lang.String helpText) throws java.lang.Throwable
option
- The character for the option.helpText
- The help text.
java.lang.Throwable
- Most likely a ThingsException if parameters are bad or if the option was already declared.protected void declareValues(java.lang.String name, java.lang.String helpText, boolean isRequired) throws java.lang.Throwable
name
- The option name. Not case sensitive. Internally, they are normalized to lower case.helpText
- The help text.isRequired
- is it required? false means it is optional.
java.lang.Throwable
- Most likely a ThingsException if parameters are bad or if the option was already declared.ThingsException
protected void declareEntities(int name, java.lang.String helpText, boolean isRequired) throws java.lang.Throwable
name
- The option name. Not case sensitive. Internally, they are normalized to lower case.helpText
- The help text.isRequired
- is it required? false means it is optional.
java.lang.Throwable
- Most likely a ThingsException if parameters are bad or if the option was already declared.ThingsException
protected void suppressListingRootInstallEntity()
protected void ERROR(java.lang.String message) throws java.lang.Throwable
message
- the error
java.lang.Throwable
protected void ERROR(java.lang.String message, java.lang.Throwable t) throws java.lang.Throwable
message
- the errort
- the causing exception.
java.lang.Throwable
protected int numberOfEntites()
protected int numberOfValues()
public void mainEntry(java.lang.String[] args)
This will not throw any exceptions.
args
- The command line arguments. What's passed from main() works dandy.public void usage()
The formats:
aaa - REQUIRED, AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA b - BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB cccccccccccc - OPTIONAL, CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC " %-3s - %-8s, %-71s" " %-81s" " %c - %-81s" " %-81s" " %-12s - %-8s, %-71s" " %-81s"
public java.io.PrintWriter getConsole()
public java.lang.String getEntity(int item) throws ThingsException
item
- The item number.
ThingsException
public java.lang.String getEntityRequired(int item, java.lang.String message) throws ThingsException
item
- The item number.message
- The entity name or description. It's used if an error occurs.
ThingsException
public java.lang.String getValue(java.lang.String name) throws ThingsException
name
- The item name.
ThingsException
public boolean optionIsSet(int character)
character
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |