org.ow2.petals.cli.shell.command
Class Command

java.lang.Object
  extended by org.ow2.petals.cli.shell.command.Command
Direct Known Subclasses:
Deploy, Exit, Help, ListArtefacts, ListRegistry, Load, Print, Pwd, Set, Show, Shutdown, Stop, Undeploy, Version

public abstract class Command
extends java.lang.Object

A petals CLI Command is executed inside a petals CLI shell.

Author:
sandre

Constructor Summary
Command()
          Initialize the command by inferring its name from the class name
Command(Shell shell)
          Create a new command
 
Method Summary
 void checkArguments(java.lang.String[] args, int min)
          Check the number of arguments to be greater than a specified number
 void checkArguments(java.lang.String[] args, int min, int max)
           
abstract  void execute(java.lang.String[] args)
           
 java.lang.String getDescription()
          Get the description of this command
 java.lang.String getName()
          Get the name of the command from its class name
protected  Shell getShell()
          Get the shell this command is bound to
 java.lang.String getUsage()
          Get the usage message for this command
protected  void setDescription(java.lang.String description)
          Set the description
protected  void setUsage(java.lang.String usage)
          Set the usage message
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Command

public Command()
Initialize the command by inferring its name from the class name


Command

public Command(Shell shell)
Create a new command

Parameters:
shell - the shell this command will be bound to
Method Detail

getName

public final java.lang.String getName()
Get the name of the command from its class name

Returns:
the name of the Class in low cases

getUsage

public final java.lang.String getUsage()
Get the usage message for this command

Returns:
A string describing command's arguments

getDescription

public final java.lang.String getDescription()
Get the description of this command

Returns:
A string describing the purpose and use of this command

getShell

protected final Shell getShell()
Get the shell this command is bound to

Returns:
a petals CLI shell

setUsage

protected final void setUsage(java.lang.String usage)
Set the usage message

Parameters:
usage -

setDescription

protected final void setDescription(java.lang.String description)
Set the description

Parameters:
description -

checkArguments

public void checkArguments(java.lang.String[] args,
                           int min)
                    throws CommandException
Check the number of arguments to be greater than a specified number

Parameters:
args - the array of arguments
min - the minimal number of elements args must contain
Throws:
CommandException - if args is null or contains less than min elements

checkArguments

public void checkArguments(java.lang.String[] args,
                           int min,
                           int max)
                    throws CommandException
Parameters:
args -
min -
max -
Throws:
CommandException

execute

public abstract void execute(java.lang.String[] args)
                      throws CommandException
Throws:
CommandException


Copyright © 2005-2011 Petals Link (EBM Websourcing). All Rights Reserved.