com.generationjava.util
Interface CArgs

All Known Implementing Classes:
AbstractCArgs

public interface CArgs

A command line argument parser. The aim is to make writing a static public void main(String[]) a lot easier. So as well as command line parsing, it also supplies other needed functionality.


Field Summary
static Constant CLASS_VALUE
           
static Constant DATE_VALUE
           
static Constant FILE_VALUE
           
static Constant FILES_VALUE
           
static Constant NO_VALUE
           
static Constant NUMBER_VALUE
           
static Constant OBJECT_VALUE
           
static Constant STRING_VALUE
          STRING_VALUE
static Constant URL_VALUE
           
 
Method Summary
 java.lang.Number createNumber(java.lang.String number)
          Create a Number.
 java.lang.Object createObject(java.lang.String classname)
          Create an object.
 void die(java.lang.String str)
          Quit the JVM with the given message.
 void error(java.lang.String str)
          Write an error to the error stream.
 boolean getErrorDies()
          Will the program die on an error.
 java.io.PrintStream getErrorStream()
          Stream to print errors to.
 java.lang.String[] getLeftover()
          Get whatever arguments were not parsed.
 java.lang.String getUsage()
          Get the text to print when usage() is invoked.
 java.io.PrintStream getUsageStream()
          Stream to print usage to.
 void setArgs(java.lang.String[] args)
          Set the command line arguments to be parsed.
 void setErrorDies(boolean b)
          Set it so that the JVM dies on an error.
 void setErrorStream(java.io.PrintStream ps)
          Stream to print errors to.
 void setPattern(java.lang.String pattern)
          Set the pattern of command line arguments.
 void setUsage(java.lang.String usage)
          Set the text to print when usage() is invoked.
 void setUsageStream(java.io.PrintStream ps)
          Stream to print usage to.
 void usage()
          Print the usage statement to the usage stream.
 

Field Detail

STRING_VALUE

public static final Constant STRING_VALUE
STRING_VALUE

OBJECT_VALUE

public static final Constant OBJECT_VALUE

NUMBER_VALUE

public static final Constant NUMBER_VALUE

DATE_VALUE

public static final Constant DATE_VALUE

CLASS_VALUE

public static final Constant CLASS_VALUE

FILE_VALUE

public static final Constant FILE_VALUE

FILES_VALUE

public static final Constant FILES_VALUE

URL_VALUE

public static final Constant URL_VALUE

NO_VALUE

public static final Constant NO_VALUE
Method Detail

die

public void die(java.lang.String str)
Quit the JVM with the given message.
Parameters:
str - String to give as a reason for dying.

error

public void error(java.lang.String str)
Write an error to the error stream. The JVM may be killed if the errorDies() property has been set.
Parameters:
msg - String to write to the error stream.

setErrorDies

public void setErrorDies(boolean b)
Set it so that the JVM dies on an error.
Parameters:
b - boolean yes/no to die on an error.

getErrorDies

public boolean getErrorDies()
Will the program die on an error.
Returns:
boolean yes/no to die on an error.

setErrorStream

public void setErrorStream(java.io.PrintStream ps)
Stream to print errors to.
Parameters:
ps - PrintStream to print errors to.

getErrorStream

public java.io.PrintStream getErrorStream()
Stream to print errors to.
Returns:
PrintStream to print errors to.

usage

public void usage()
Print the usage statement to the usage stream.

setUsageStream

public void setUsageStream(java.io.PrintStream ps)
Stream to print usage to.
Parameters:
ps - PrintStream to print usage to.

getUsageStream

public java.io.PrintStream getUsageStream()
Stream to print usage to.
Returns:
PrintStream to print usage to.

setUsage

public void setUsage(java.lang.String usage)
Set the text to print when usage() is invoked.
Parameters:
usage - String to print for usage.

getUsage

public java.lang.String getUsage()
Get the text to print when usage() is invoked.
Returns:
String to print for usage.

createObject

public java.lang.Object createObject(java.lang.String classname)
Create an object. If something goes wrong, it returns null rather than throwing an Exception.
Parameters:
classname - String name of class to create.

createNumber

public java.lang.Number createNumber(java.lang.String number)
Create a Number. If the value in the String is not a legal number, then return null.
Parameters:
number - String value of the number.

setArgs

public void setArgs(java.lang.String[] args)
Set the command line arguments to be parsed.
Parameters:
args - String[] command line arguments.

getLeftover

public java.lang.String[] getLeftover()
Get whatever arguments were not parsed.
Returns:
String[] of unparsed command line arguments.

setPattern

public void setPattern(java.lang.String pattern)
Set the pattern of command line arguments. This describes what types of arguments there are and what legal arguments there are.
Parameters:
String - Encoding describing arguments.


Copyright © 2000-2002 GenerationJava. All Rights Reserved.