|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.test.CmdParam
public class CmdParam
This class provides standard processing of command line parameters.
$Id: CmdParam.java,v 1.43 2007-10-04 19:58:39 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
This class provides standard processing of command line parameters. Command line parameters can be of the form
-this-is-a-switchand
-this_is_a_switchare equivalent.
-switch
turns on the switch.
-no_switch
(negative form) turns off the switch.
-s
turns on the switch.
-ns
(negative form) turns off the switch.
CmdParam
instance is required for the
negative form.
Field Summary | |
---|---|
static int |
INT
Parameter is an integer. |
static int |
LIST
Parameter is a list of strings. |
static int |
REAL
Parameter is a real. |
static int |
STRING
Parameter is a String. |
static int |
SWITCH
Parameter is a switch. |
Constructor Summary | |
---|---|
CmdParam(java.lang.String longName,
boolean optional,
int type,
java.lang.Object defaultValue,
int helpMsg)
Define a parameter. |
|
CmdParam(java.lang.String name,
boolean optional,
int type,
java.lang.Object defaultValue,
java.lang.String description)
Define a parameter. |
Method Summary | |
---|---|
int |
getIntValue()
Return the int value of the parameter. |
java.lang.String |
getStringValue()
Return the string value of the parameter. |
Vector<java.lang.String> |
getStringValues()
Return the string value of the parameter. |
java.lang.Object |
getValue()
Return the value of the parameter. |
static void |
parse(java.lang.String command,
java.lang.String[] cmdParameters,
CmdParam[] parameters)
Parse a string for parameters. |
static boolean |
parse(java.lang.String command,
java.lang.String[] cmdParameters,
CmdParam[] parameters,
CmdParam unspecified)
Parse a string for parameters. |
boolean |
specified()
Return true if the parameter was specified. |
java.lang.String |
toString()
|
static void |
usage(java.io.PrintStream s,
java.lang.String command,
CmdParam[] parameters)
Print out a usage message based upon the parameters. |
static void |
usage(java.io.PrintStream s,
java.lang.String command,
CmdParam[] parameters,
CmdParam unspecified)
Print out a usage message based upon the parameters. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int STRING
public static final int INT
public static final int REAL
public static final int SWITCH
public static final int LIST
Constructor Detail |
---|
public CmdParam(java.lang.String longName, boolean optional, int type, java.lang.Object defaultValue, int helpMsg)
longName
- of the parameteroptional
- true if this is an optional parametertype
- the parameter typedefaultValue
- the default value - may be nullhelpMsg
- an index to a description of the parameter - may be nullMsg
public CmdParam(java.lang.String name, boolean optional, int type, java.lang.Object defaultValue, java.lang.String description)
name
- of the parameteroptional
- true if this is an optional parametertype
- the parameter typedefaultValue
- the default value - may be nulldescription
- a description of the parameter - may be nullMsg
Method Detail |
---|
public java.lang.Object getValue()
public int getIntValue()
int
value of the parameter.
public java.lang.String getStringValue()
public Vector<java.lang.String> getStringValues()
public boolean specified()
public static void parse(java.lang.String command, java.lang.String[] cmdParameters, CmdParam[] parameters) throws InvalidKeyException
command
- is the command usedcmdParameters
- the array of strings specifying the command
line parametersparameters
- an array of allowed parameters
InvalidKeyException
- if there is a command line
parameter errorpublic static boolean parse(java.lang.String command, java.lang.String[] cmdParameters, CmdParam[] parameters, CmdParam unspecified) throws InvalidKeyException
command
- is the command usedcmdParameters
- the array of strings specifying the command
line parametersparameters
- an array of allowed parametersunspecified
- is non-null if prameters may be supplied without switches
InvalidKeyException
- if there is a command line parameter errorpublic static void usage(java.io.PrintStream s, java.lang.String command, CmdParam[] parameters)
s
- is the stream to be printed oncommand
- is the command nameparameters
- is the array of parameter definitionspublic static void usage(java.io.PrintStream s, java.lang.String command, CmdParam[] parameters, CmdParam unspecified)
s
- is the stream to be printed oncommand
- is the command nameparameters
- is the array of parameter definitionsunspecified
- is non-null if prameters may be supplied without switchespublic java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |