|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectedu.mscd.cs.jclo.JCLO
public class JCLO
This class is used to parse command-line arguments based on a the variables with an object. Each variable in the class specifies a command-line argument that can be accepted; the name of the variable becomes the name of the command-line argument. As Java does not allow dashes '-' in variables, use two underscores '__' if you want a dash in an argument. Also, if you want to have a numeric argument (e.g.: '-1'), start the variable name with a single underscore. JCLO uses reflection to determine the type of each variable in the passed object and sets the values in the object passed to it via parsing the command line. If you include a String array named "additional", all non-dashed arguments will be placed in it.
| Constructor Summary | |
|---|---|
JCLO(java.lang.Object object)
A constructor that takes the Object that contains the variables acceptable on a command line. |
|
JCLO(java.lang.String prefix,
java.lang.Object object)
A constructor that takes an Object, a prefix, and a boolean that specifies whether to accept single or double dashes; call parse (String) to do the actual parsing. |
|
| Method Summary | |
|---|---|
boolean |
getBoolean(java.lang.String key)
Get a boolean value from the object after parsing. |
byte |
getByte(java.lang.String key)
Get a byte value from the object after parsing. |
byte[] |
getBytes(java.lang.String key)
Get an array of bytes from the object after parsing. |
char |
getChar(java.lang.String key)
Get a character value from the object after parsing. |
char[] |
getChars(java.lang.String key)
Get an array of characaters from the object after parsing. |
double |
getDouble(java.lang.String key)
Get a double value from the object after parsing. |
double[] |
getDoubles(java.lang.String key)
Get an array of doubles from the object after parsing. |
float |
getFloat(java.lang.String key)
Get a float value from the object after parsing. |
float[] |
getFloats(java.lang.String key)
Get an array of floats from the object after parsing. |
int |
getInt(java.lang.String key)
Get an integer value from the object after parsing. |
int[] |
getInts(java.lang.String key)
Get an array of integers from the object after parsing. |
long |
getLong(java.lang.String key)
Get a long value from the object after parsing. |
long[] |
getLongs(java.lang.String key)
Get an array of longs from the object after parsing. |
short |
getShort(java.lang.String key)
Get a short value from the object after parsing. |
short[] |
getShorts(java.lang.String key)
Get an array of shorts from the object after parsing. |
java.lang.String |
getString(java.lang.String key)
Get a String from the object after parsing. |
java.lang.String[] |
getStrings(java.lang.String key)
Get an array of Strings from the object after parsing. |
java.lang.Object |
getValue(java.lang.String key)
Get the current value of the variable in the object |
static void |
main(java.lang.String[] args)
|
void |
parse(java.lang.String[] args)
Parse a command line. |
java.lang.String |
toString()
An external representation of the object |
java.lang.String |
usage()
Create and usage message for the acceptable command line variables. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JCLO(java.lang.Object object)
object - where the variables/arguments are
public JCLO(java.lang.String prefix,
java.lang.Object object)
object - where the variables/arguments areprefix - the String CLO's start with, if any| Method Detail |
|---|
public java.lang.Object getValue(java.lang.String key)
key - the variable name
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String usage()
public void parse(java.lang.String[] args)
args - the arguments to be parsedpublic boolean getBoolean(java.lang.String key)
public byte getByte(java.lang.String key)
public char getChar(java.lang.String key)
public short getShort(java.lang.String key)
public int getInt(java.lang.String key)
public float getFloat(java.lang.String key)
public double getDouble(java.lang.String key)
public long getLong(java.lang.String key)
public java.lang.String getString(java.lang.String key)
public byte[] getBytes(java.lang.String key)
public char[] getChars(java.lang.String key)
public short[] getShorts(java.lang.String key)
public int[] getInts(java.lang.String key)
public float[] getFloats(java.lang.String key)
public double[] getDoubles(java.lang.String key)
public long[] getLongs(java.lang.String key)
public java.lang.String[] getStrings(java.lang.String key)
public static void main(java.lang.String[] args)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||