nl.toolforge.karma.core.cmd
Interface Command

All Known Implementing Classes:
DefaultCommand, KarmaInitializationCommand

public interface Command

A Command is an executable operation in Karma. Commands perform actions as per user requests.

Karma commands are based on the Option class in the Apache package. Karma wraps an Option and features to it.

Version:
$Id: Command.java,v 1.20 2004/09/15 20:57:21 asmedes Exp $
Author:
D.A. Smedes, W.M. Oosterom

Method Summary
 void cleanUp()
          Called after execute().
 void deregisterCommandResponseListener(CommandResponseListener responseListener)
          Deregister the CommandResponseListener.
 void execute()
          Executes the command.
 java.lang.String getAlias()
          Gets the alias for this command (its short name).
 org.apache.commons.cli.CommandLine getCommandLine()
          Gets the parsed command line for this command.
 CommandResponse getCommandResponse()
          Return the specific CommandResponse object that this command uses.
 java.lang.String getDescription()
          Gets this command's descriptive text.
 java.lang.String getHelp()
          The command's help text.
 java.lang.String getName()
          Gets the normal name of this command (its full name).
 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 context)
          Stores a reference to a CommandContext.
 

Method Detail

getName

public java.lang.String getName()
Gets the normal name of this command (its full name).

Returns:
The normal name of this command.

getAlias

public java.lang.String getAlias()
Gets the alias for this command (its short name).

Returns:
The alias for this command.

getDescription

public java.lang.String getDescription()
Gets this command's descriptive text. This is merely a one liner for the command, providing its very existence.

Returns:
The command's descriptive text.

getHelp

public java.lang.String getHelp()
The command's help text. Help text can be unlimited. Use HTML for formatting.


execute

public void execute()
             throws CommandException
Executes the command.

Throws:
CommandException - When execution failed. This exception catches all underlying exceptions and rethrows them as a CommandException, except for RuntimeExceptions.

cleanUp

public void cleanUp()
Called after execute(). Implementations can use this method to clean up resources and the like.


setContext

public void setContext(CommandContext context)
Stores a reference to a CommandContext.

Parameters:
context - An initialized command context.

setCommandLine

public void setCommandLine(org.apache.commons.cli.CommandLine commandLine)

getCommandLine

public 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.

Returns:
A command line instance.

registerCommandResponseListener

public void registerCommandResponseListener(CommandResponseListener responseListener)
Register the given CommandResponseListener as the handler for the command responses.

Parameters:
responseListener -

deregisterCommandResponseListener

public void deregisterCommandResponseListener(CommandResponseListener responseListener)
Deregister the CommandResponseListener.


getCommandResponse

public CommandResponse getCommandResponse()
Return the specific CommandResponse object that this command uses.

Returns:
CommandResponse


Copyright © 2002-2004 Toolforge. All Rights Reserved.