com.symbian.et.test.cmdline
Class CmdLine

java.lang.Object
  extended bycom.symbian.et.test.cmdline.CmdLine
Direct Known Subclasses:
BuildCmdLine, DummyCmdLine, HelpCmdLine, PrintCmdLine, RunCmdLine, VersionCmdLine

public abstract class CmdLine
extends java.lang.Object

modelizes the syntax of a command

Author:
EngineeringTools

Field Summary
private  AnyData iAnyDataChecker
           
private  CmdOperational iCmdOperation
           
private  CmdLineSet iCmdSet
           
private  java.lang.String iCommand
           
private  org.apache.commons.cli.CommandLine iCommandLine
           
private  java.lang.String iDescription
           
private  org.apache.commons.cli.HelpFormatter iFormatter
           
private  org.apache.commons.cli.Options iOptions
           
private  java.util.ArrayList iParametersChecks
           
private  java.util.ArrayList iParametersToCheck
           
 
Constructor Summary
CmdLine(java.lang.String aCommand, CmdOperational aCmdOperation, java.lang.String aDescription)
          standard constructor
 
Method Summary
 void addSwitch(java.lang.String aSwitchName, boolean aIsSingle, java.lang.String aDescription, boolean aIsMandatory, boolean aHasArgs)
          adds a switch to a command
 void addSwitch(java.lang.String aSwitchName, boolean aIsSingle, java.lang.String aDescription, boolean aIsMandatory, DataAcceptable aDataCheck)
          adds a switch to a command
 void checkAdditionalConstraints(org.apache.commons.cli.CommandLine aCommandLine)
          checks additional constraints
method only useful if overridden by specialized classes
this is the method to be overriden if one wants to specify specific forbidden switch combinations
 void checkConstraints(org.apache.commons.cli.CommandLine aCommandLine)
          parses a command to check its validity
 CmdLine find(java.lang.String aSoughtCommand)
          finds a particular command in the associated command set, given a command name
 org.apache.commons.cli.CommandLine getCommandLine()
          retrieves the org.apache.commons.cli.CommandLine object that parses the command line
use this to customize the command line
 org.apache.commons.cli.Options getOptions()
           
 boolean isCommand(java.lang.String aCommand)
          determines if a particular command name matches the command
 void printAllCmds()
          displays the name of all the commands
 void printCommand()
          displays command name
 void printCopyright()
          prints tool copyright
 void printDescription()
          prints description of the particular command
 void printHelp()
          displays help
 void printPurpose()
          displays command purpose
 void printToolName()
          displays tool name
 void printToolVersion()
          displays tool version
protected  void setCmdSet(CmdLineSet aCmdSet)
          associates to a command set
 java.lang.Object start(org.apache.commons.cli.CommandLine aCmdLine)
          starts command
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

iCommand

private java.lang.String iCommand

iCmdOperation

private CmdOperational iCmdOperation

iDescription

private java.lang.String iDescription

iCmdSet

private CmdLineSet iCmdSet

iOptions

private org.apache.commons.cli.Options iOptions

iFormatter

private org.apache.commons.cli.HelpFormatter iFormatter

iCommandLine

private org.apache.commons.cli.CommandLine iCommandLine

iParametersToCheck

private java.util.ArrayList iParametersToCheck

iParametersChecks

private java.util.ArrayList iParametersChecks

iAnyDataChecker

private AnyData iAnyDataChecker
Constructor Detail

CmdLine

public CmdLine(java.lang.String aCommand,
               CmdOperational aCmdOperation,
               java.lang.String aDescription)
standard constructor

Parameters:
aCommand - name of the command
aCmdOperation - object that implements command
aDescription - brief description of the command (used by help command)
Method Detail

getCommandLine

public org.apache.commons.cli.CommandLine getCommandLine()
                                                  throws CmdLineException
retrieves the org.apache.commons.cli.CommandLine object that parses the command line
use this to customize the command line

Throws:
CmdLineException

setCmdSet

protected void setCmdSet(CmdLineSet aCmdSet)
associates to a command set

Parameters:
aCmdSet - command set

isCommand

public final boolean isCommand(java.lang.String aCommand)
determines if a particular command name matches the command

Parameters:
aCommand - command name

addSwitch

public void addSwitch(java.lang.String aSwitchName,
                      boolean aIsSingle,
                      java.lang.String aDescription,
                      boolean aIsMandatory,
                      boolean aHasArgs)
adds a switch to a command

Parameters:
aSwitchName - name of the switch //TODO: single = double
aDescription - description of the switch (for help command)
aIsMandatory - make switch mandatory
aHasArgs - make switch arguments possible //TODO: is it 'mandatory' or 'possible'

addSwitch

public void addSwitch(java.lang.String aSwitchName,
                      boolean aIsSingle,
                      java.lang.String aDescription,
                      boolean aIsMandatory,
                      DataAcceptable aDataCheck)
adds a switch to a command

Parameters:
aSwitchName - name of the switch //TODO: single = double
aDescription - description of the switch (for help command)
aIsMandatory - make switch mandatory
aDataCheck - facility to check the validity of the parameter

checkConstraints

public final void checkConstraints(org.apache.commons.cli.CommandLine aCommandLine)
                            throws org.apache.commons.cli.ParseException
parses a command to check its validity

Parameters:
aCommandLine - org.apache.commons.cli.CommandLine object
Throws:
org.apache.commons.cli.ParseException - if the command provided is not syntaxically correct

checkAdditionalConstraints

public void checkAdditionalConstraints(org.apache.commons.cli.CommandLine aCommandLine)
                                throws org.apache.commons.cli.ParseException
checks additional constraints
method only useful if overridden by specialized classes
this is the method to be overriden if one wants to specify specific forbidden switch combinations

Parameters:
aCommandLine -
Throws:
org.apache.commons.cli.ParseException

printHelp

public void printHelp()
displays help


printDescription

public void printDescription()
prints description of the particular command


printPurpose

public void printPurpose()
displays command purpose


getOptions

public final org.apache.commons.cli.Options getOptions()

start

public final java.lang.Object start(org.apache.commons.cli.CommandLine aCmdLine)
                             throws CmdLineException
starts command

Returns:
object object returned by command implementation object
Throws:
CmdNotInitializedException
CmdLineException

printCommand

public void printCommand()
displays command name


printToolVersion

public void printToolVersion()
                      throws CmdLineException
displays tool version

Throws:
CmdParsingFailureException - if command is not linked to any command set
CmdLineException

printToolName

public void printToolName()
                   throws CmdLineException
displays tool name

Throws:
CmdParsingFailureException - if command is not linked to any command set
CmdLineException

printAllCmds

public void printAllCmds()
displays the name of all the commands


find

public CmdLine find(java.lang.String aSoughtCommand)
finds a particular command in the associated command set, given a command name

Parameters:
aSoughtCommand -
Returns:
sought command

printCopyright

public void printCopyright()
prints tool copyright