edu.mscd.cs.jclo
Class JCLO

java.lang.Object
  extended by edu.mscd.cs.jclo.JCLO

public class JCLO
extends java.lang.Object

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

JCLO

public JCLO(java.lang.Object object)
A constructor that takes the Object that contains the variables acceptable on a command line. Call parse (String) to do the actual parsing.

Parameters:
object - where the variables/arguments are

JCLO

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

Parameters:
object - where the variables/arguments are
prefix - the String CLO's start with, if any
Method Detail

getValue

public java.lang.Object getValue(java.lang.String key)
Get the current value of the variable in the object

Parameters:
key - the variable name
Returns:
an Object with the value

toString

public java.lang.String toString()
An external representation of the object

Overrides:
toString in class java.lang.Object
Returns:
a formatted version of this object

usage

public java.lang.String usage()
Create and usage message for the acceptable command line variables.

Returns:
a String that specifies acceptable options

parse

public void parse(java.lang.String[] args)
Parse a command line.

Parameters:
args - the arguments to be parsed

getBoolean

public boolean getBoolean(java.lang.String key)
Get a boolean value from the object after parsing.


getByte

public byte getByte(java.lang.String key)
Get a byte value from the object after parsing.


getChar

public char getChar(java.lang.String key)
Get a character value from the object after parsing.


getShort

public short getShort(java.lang.String key)
Get a short value from the object after parsing.


getInt

public int getInt(java.lang.String key)
Get an integer value from the object after parsing.


getFloat

public float getFloat(java.lang.String key)
Get a float value from the object after parsing.


getDouble

public double getDouble(java.lang.String key)
Get a double value from the object after parsing.


getLong

public long getLong(java.lang.String key)
Get a long value from the object after parsing.


getString

public java.lang.String getString(java.lang.String key)
Get a String from the object after parsing.


getBytes

public byte[] getBytes(java.lang.String key)
Get an array of bytes from the object after parsing.


getChars

public char[] getChars(java.lang.String key)
Get an array of characaters from the object after parsing.


getShorts

public short[] getShorts(java.lang.String key)
Get an array of shorts from the object after parsing.


getInts

public int[] getInts(java.lang.String key)
Get an array of integers from the object after parsing.


getFloats

public float[] getFloats(java.lang.String key)
Get an array of floats from the object after parsing.


getDoubles

public double[] getDoubles(java.lang.String key)
Get an array of doubles from the object after parsing.


getLongs

public long[] getLongs(java.lang.String key)
Get an array of longs from the object after parsing.


getStrings

public java.lang.String[] getStrings(java.lang.String key)
Get an array of Strings from the object after parsing.


main

public static void main(java.lang.String[] args)