nl.toolforge.karma.core.cmd
Class DefaultCommand

java.lang.Object
  extended bynl.toolforge.karma.core.cmd.DefaultCommand
All Implemented Interfaces:
Command
Direct Known Subclasses:
AbstractBuildCommand, BuildAllModules, CommandFaker, CompositeCommand, CreateDistribution, CreateModuleCommand, CreatePassword, DeleteWorkingContext, DocAllModules, ExitCleanCommand, ListManifests, PromoteCommand, SelectManifest, StartWorkCommand, StopWorkCommand, TestAllModules, UpdateAdmin, UpdateModuleCommand, ViewManifest, ViewWorkingContexts

public abstract class DefaultCommand
extends java.lang.Object
implements Command

Default stuff for a command. Provides the datastructure and some helper methods to implementing commands.

Version:
$Id: DefaultCommand.java,v 1.25 2004/11/10 23:53:08 asmedes Exp $
Author:
D.A. Smedes

Constructor Summary
DefaultCommand(CommandDescriptor descriptor)
          Creates a command by initializing the command through its CommandDescriptor.
 
Method Summary
 void cleanUp()
          Override to clean up stuff.
 void deregisterCommandResponseListener(CommandResponseListener responseListener)
          Deregister the CommandResponseListener.
 java.lang.String getAlias()
          Gets a command's alias; the shortcut name for the command.
 org.apache.commons.cli.CommandLine getCommandLine()
          Gets the parsed command line for this command.
 CommandContext getContext()
          Accessor method for the commands' CommandContext.
 java.lang.String getDescription()
          Gets a localized version of a command's description.
protected  java.util.ResourceBundle getFrontendMessages()
          Helper method to get a resource bundle for frontend messages for commands.
 java.lang.String getHelp()
          A commands help text.
 java.lang.String getName()
          Gets a command's name.
 CommandResponseListener getResponseListener()
          Gets the response listener object for this command.
 WorkingContext getWorkingContext()
          Helper to get the current WorkingContext.
 void registerCommandResponseListener(CommandResponseListener responseListener)
          Register the given CommandResponseListener as the handler for the command responses.
 void setCommandLine(org.apache.commons.cli.CommandLine commandLine)
           
 void setContext(CommandContext contextRef)
          Sets the command context for this command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nl.toolforge.karma.core.cmd.Command
execute, getCommandResponse
 

Constructor Detail

DefaultCommand

public DefaultCommand(CommandDescriptor descriptor)
Creates a command by initializing the command through its CommandDescriptor.

Parameters:
descriptor - The command descriptor instance containing the basic information for this command
Method Detail

setContext

public final void setContext(CommandContext contextRef)
Sets the command context for this command. The command needs the command context during the executing phase.

Specified by:
setContext in interface Command
Parameters:
contextRef - The CommandContext for this command.

getName

public final java.lang.String getName()
Gets a command's name.

Specified by:
getName in interface Command
Returns:
A command's name as a String.

getAlias

public final java.lang.String getAlias()
Gets a command's alias; the shortcut name for the command. This alias could be a comma-separated String of aliasses, all of which are valid aliasses.

Specified by:
getAlias in interface Command
Returns:
A command's alias as a String.

getWorkingContext

public final WorkingContext getWorkingContext()
Helper to get the current WorkingContext.

Returns:
The current WorkingContext.

getDescription

public final java.lang.String getDescription()
Gets a localized version of a command's description.

Specified by:
getDescription in interface Command
Returns:
A command's description as a String.

setCommandLine

public final void setCommandLine(org.apache.commons.cli.CommandLine commandLine)
Specified by:
setCommandLine in interface Command

getCommandLine

public final org.apache.commons.cli.CommandLine getCommandLine()
Gets the parsed command line for this command. This command line can be queried by commands to check if options had been set, or to retrieve application data.

Specified by:
getCommandLine in interface Command
Returns:
A command line instance.

registerCommandResponseListener

public final void registerCommandResponseListener(CommandResponseListener responseListener)
Description copied from interface: Command
Register the given CommandResponseListener as the handler for the command responses.

Specified by:
registerCommandResponseListener in interface Command
Parameters:
responseListener -

deregisterCommandResponseListener

public final void deregisterCommandResponseListener(CommandResponseListener responseListener)
Description copied from interface: Command
Deregister the CommandResponseListener.

Specified by:
deregisterCommandResponseListener in interface Command

getResponseListener

public final CommandResponseListener getResponseListener()
Gets the response listener object for this command.

Returns:
The response listener object for this command.

getContext

public final CommandContext getContext()
Accessor method for the commands' CommandContext.

Returns:
The commands' command context.

getHelp

public java.lang.String getHelp()
A commands help text. Can be overridden for commands that have not provided xml data for the <help>-element.

Specified by:
getHelp in interface Command
Returns:
Help text for this command.

getFrontendMessages

protected final java.util.ResourceBundle getFrontendMessages()
Helper method to get a resource bundle for frontend messages for commands.

Returns:
The ResourceBundle for the current locale for frontend messages.

cleanUp

public void cleanUp()
Override to clean up stuff.

Specified by:
cleanUp in interface Command


Copyright © 2002-2004 Toolforge. All Rights Reserved.