|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jomc.cli.commands.AbstractCommand
@Generated(value="org.jomc.tools.SourceFileProcessor 1.2.2", comments="See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2") public abstract class AbstractCommand
JOMC CLI command implementation.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.jomc.cli.Command |
---|
Command.Listener |
Field Summary |
---|
Fields inherited from interface org.jomc.cli.Command |
---|
STATUS_FAILURE, STATUS_SUCCESS |
Constructor Summary | |
---|---|
AbstractCommand()
Creates a new AbstractCommand instance. |
Method Summary | |
---|---|
int |
execute(CommandLine commandLine)
Executes the command. |
protected abstract void |
executeCommand(CommandLine commandLine)
Called by the execute method prior to the postExecuteCommand method. |
String |
getAbbreviatedName()
Gets the abbreviated name of the command. |
static Level |
getDefaultLogLevel()
Gets the default log level events are logged at. |
protected static String |
getExceptionMessage(Throwable t)
Gets a message of a given throwable recursively. |
List<Command.Listener> |
getListeners()
Gets the list of registered listeners. |
Level |
getLogLevel()
Gets the log level of the instance. |
String |
getLongDescription(Locale locale)
Gets the long description of the command. |
String |
getName()
Gets the name of the command. |
Options |
getOptions()
Gets the options of the command. |
String |
getShortDescription(Locale locale)
Gets the short description of the command. |
protected boolean |
isLoggable(Level level)
Checks if a message at a given level is provided to the listeners of the instance. |
protected void |
log(Level level,
String message,
Throwable throwable)
Notifies registered listeners. |
protected void |
postExecuteCommand(CommandLine commandLine)
Called by the execute method after the preExecuteCommand /executeCommand methods even if
those methods threw an exception. |
protected void |
preExecuteCommand(CommandLine commandLine)
Called by the execute method prior to the executeCommand method. |
static void |
setDefaultLogLevel(Level value)
Sets the default log level events are logged at. |
void |
setLogLevel(Level value)
Sets the log level of the instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
@Generated(value="org.jomc.tools.SourceFileProcessor 1.2.2", comments="See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2") public AbstractCommand()
AbstractCommand
instance.
Method Detail |
---|
public final List<Command.Listener> getListeners()
This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make
to the returned list will be present inside the object. This is why there is no set
method for the
listeners property.
getListeners
in interface Command
log(java.util.logging.Level, java.lang.String, java.lang.Throwable)
public final Level getLogLevel()
getLogLevel
in interface Command
getDefaultLogLevel()
,
setLogLevel(java.util.logging.Level)
,
isLoggable(java.util.logging.Level)
public final void setLogLevel(Level value)
setLogLevel
in interface Command
value
- The new log level of the instance or null
.getLogLevel()
,
isLoggable(java.util.logging.Level)
public final String getName()
Command
getName
in interface Command
public final String getAbbreviatedName()
Command
getAbbreviatedName
in interface Command
public final String getShortDescription(Locale locale)
Command
getShortDescription
in interface Command
locale
- The locale of the short description to return.
public final String getLongDescription(Locale locale)
Command
getLongDescription
in interface Command
locale
- The locale of the long description to return.
public final int execute(CommandLine commandLine)
Command
execute
in interface Command
commandLine
- Command line to execute.
Command.STATUS_SUCCESS
,
Command.STATUS_FAILURE
public static Level getDefaultLogLevel()
The default log level is controlled by system property
org.jomc.cli.commands.AbstractCommand.defaultLogLevel
holding the log level to log events at by
default. If that property is not set, the WARNING
default is returned.
getLogLevel()
,
Level.parse(java.lang.String)
public static void setDefaultLogLevel(Level value)
value
- The new default level events are logged at or null
.getDefaultLogLevel()
protected boolean isLoggable(Level level)
level
- The level to test.
true
, if messages at level
are provided to the listeners of the instance;
false
, if messages at level
are not provided to the listeners of the instance.
NullPointerException
- if level
is null
.getLogLevel()
,
setLogLevel(java.util.logging.Level)
protected void log(Level level, String message, Throwable throwable)
level
- The level of the event.message
- The message of the event or null
.throwable
- The throwable of the event null
.
NullPointerException
- if level
is null
.getListeners()
,
isLoggable(java.util.logging.Level)
protected void preExecuteCommand(CommandLine commandLine) throws CommandExecutionException
execute
method prior to the executeCommand
method.
commandLine
- The command line to execute.
NullPointerException
- if commandLine
is null
.
CommandExecutionException
- if executing the command fails.execute(org.apache.commons.cli.CommandLine)
protected abstract void executeCommand(CommandLine commandLine) throws CommandExecutionException
execute
method prior to the postExecuteCommand
method.
commandLine
- The command line to execute.
CommandExecutionException
- if executing the command fails.execute(org.apache.commons.cli.CommandLine)
protected void postExecuteCommand(CommandLine commandLine) throws CommandExecutionException
execute
method after the preExecuteCommand
/executeCommand
methods even if
those methods threw an exception.
commandLine
- The command line to execute.
NullPointerException
- if commandLine
is null
.
CommandExecutionException
- if executing the command fails.execute(org.apache.commons.cli.CommandLine)
protected static String getExceptionMessage(Throwable t)
t
- The Throwable
to get the message of or null
.
t
or null
.@Generated(value="org.jomc.tools.SourceFileProcessor 1.2.2", comments="See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2") public Options getOptions()
Options:
Specification | Implementation |
---|
getOptions
in interface Command
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright © 2005-2012 The JOMC Project. All Rights Reserved. |