org.exolab.castor.util

Class CommandLineOptions


public class CommandLineOptions
extends java.lang.Object

A utility class for generating command line options
Version:
$Revision: 1.1.1.1 $ $Date: 2003/03/03 07:09:03 $
Author:
Keith Visco

Field Summary

(package private) PrintWriter
errorWriter
(package private) Vector
flags
(package private) Hashtable
optionInfo

Constructor Summary

CommandLineOptions()

Method Summary

void
addFlag(String flag)
Adds the flag to list of available command line options
void
addFlag(String flag, String comment)
Adds the flag to list of available command line options
void
addFlag(String flag, String usageText, String comment)
Adds the flag to list of available command line options
void
addFlag(String flag, String usageText, String comment, boolean optional)
Adds the flag to list of available command line options
Properties
getOptions(String[] args)
parses the arguments into a hashtable with the proper flag as the key
void
printHelp(PrintWriter pw)
void
printUsage(PrintWriter pw)
void
setComment(String flag, String comment)
Sets a comment for the flag
void
setOptional(String flag, boolean optional)
Sets whether or not a given flag is optional
void
setUsageInfo(String flag, String usage)
Sets the text to print after the flag when printing the usage line

Field Details

errorWriter

(package private)  PrintWriter errorWriter

flags

(package private)  Vector flags

optionInfo

(package private)  Hashtable optionInfo

Constructor Details

CommandLineOptions

public CommandLineOptions()

Method Details

addFlag

public void addFlag(String flag)
Adds the flag to list of available command line options
Parameters:
flag - the flag to add as an available command line option

addFlag

public void addFlag(String flag,
                    String comment)
Adds the flag to list of available command line options
Parameters:
flag - the flag to add as an available command line option
comment - a comment for the flag

addFlag

public void addFlag(String flag,
                    String usageText,
                    String comment)
Adds the flag to list of available command line options
Parameters:
flag - the flag to add as an available command line option
usageText - the text that appears after the flag in the usage string
comment - a comment for the flag

addFlag

public void addFlag(String flag,
                    String usageText,
                    String comment,
                    boolean optional)
Adds the flag to list of available command line options
Parameters:
flag - the flag to add as an available command line option
usageText - the text that appears after the flag in the usage string
comment - a comment for the flag

getOptions

public Properties getOptions(String[] args)
parses the arguments into a hashtable with the proper flag as the key

printHelp

public void printHelp(PrintWriter pw)

printUsage

public void printUsage(PrintWriter pw)

setComment

public void setComment(String flag,
                       String comment)
Sets a comment for the flag
Parameters:
flag - the flag to set the comment for
comment - the comment to use when printing help for the given flag

setOptional

public void setOptional(String flag,
                        boolean optional)
Sets whether or not a given flag is optional
Parameters:
flag - the flag to set optionality for
optional - the boolean indicating the optionality for the given flag

setUsageInfo

public void setUsageInfo(String flag,
                         String usage)
Sets the text to print after the flag when printing the usage line
Parameters:
flag - the flag to set the usage info for
usage - the usage text

Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com