|
|||||||||
| Home >> All >> org >> pqt >> [ cloptions overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.pqt.cloptions
Class OptionProcessor

java.lang.Objectorg.pqt.cloptions.OptionProcessor
- public class OptionProcessor
- extends java.lang.Object
a class for handling command line options and parameters. The class contains one central routine, called process, which processes command line arguments. The class must be initialized using an array of items which are subclasses of the class Option. As the command line arguments are processed routines in these option classes are called, and when the process is finished it is the values in these classes which represent the command line options that have been set. The OptionProcessor class also contains various utility routines for reading items from the command line. Options can have either a long form (a word made up of alphabetic characters and '_') or a short form (a single letter). On the command line a single dash ('-') may be followed by one or more options in short form (providing there are no spaces in between the options), while a double dash ('--') is followed by a (single) option in long form.
| Field Summary | |
(package private) boolean |
afterDash
|
(package private) int |
argPosn
|
(package private) java.lang.StringBuffer |
argString
|
(package private) Option[] |
clOptionArray
|
java.util.Vector |
fileNames
contains any filenames (words not preceeded by a '-') read on the command line, in the order in which they appear |
(package private) boolean |
matchCaseShort
|
int |
optionsRead
the number of options read |
(package private) int |
savedArgPosn
|
| Constructor Summary | |
OptionProcessor(Option[] optionArray)
initialize using a given array of Option(s) |
|
| Method Summary | |
boolean |
getBoolean()
if the next character in the command string is a '+' or '-' read it |
int |
getChar()
get a single character from the command line options string |
int |
getCharNoSpace()
get a single character from the command line options string, ignoring any white space |
java.lang.String |
getLongName()
read a long option name from the command line string. |
float |
getNumValue()
read a numeric value (which can be in full floating point form) from the command line string |
protected java.lang.String |
getString_()
|
protected java.lang.String |
getString()
read in a string (enclosed in double quotes) from the command line string |
java.lang.String |
getStringValue()
read a string, either enclosed in quotes (in which case the string can contain spaces) or not enclosed in quotes (in which case spaces are not allowed). |
private boolean |
isIdChar(int c)
|
boolean |
isNumChar(int c)
return true if the character c could be part of a floating point number# |
boolean |
longCheck(Option op,
java.lang.String s)
check a string against an option |
void |
matchCase(boolean flag)
sets whether short options are case sensitive (long options never are) |
int |
peekChar()
get a single character from the command line options string, without changing the current position in the string (ie a subsequent getChar will return the same character) |
int |
peekCharNoSpace()
get a single character from the command line options string, without changing the current position in the string (ie a subsequent getChar will return the same character) ignore any white space |
int |
process(java.lang.String[] argArray)
process the given array of string arguments |
void |
restorePosn()
restore the current position in the command string, as saved by savePosn |
void |
savePosn()
save the current position in the command string |
boolean |
shortCheck(Option op,
int c)
check a character against an option |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
clOptionArray
Option[] clOptionArray
argString
java.lang.StringBuffer argString
argPosn
int argPosn
savedArgPosn
int savedArgPosn
matchCaseShort
boolean matchCaseShort
afterDash
boolean afterDash
fileNames
public java.util.Vector fileNames
- contains any filenames (words not preceeded by a '-') read on the command
line, in the order in which they appear
optionsRead
public int optionsRead
- the number of options read
| Constructor Detail |
OptionProcessor
public OptionProcessor(Option[] optionArray)
- initialize using a given array of Option(s)
| Method Detail |
process
public int process(java.lang.String[] argArray) throws OptionException
- process the given array of string arguments
matchCase
public void matchCase(boolean flag)
- sets whether short options are case sensitive (long options never are)
getChar
public int getChar()
- get a single character from the command line options string
getCharNoSpace
public int getCharNoSpace()
- get a single character from the command line options string, ignoring any
white space
peekChar
public int peekChar()
- get a single character from the command line options string, without changing
the current position in the string (ie a subsequent getChar will return the same
character)
peekCharNoSpace
public int peekCharNoSpace()
- get a single character from the command line options string, without changing
the current position in the string (ie a subsequent getChar will return the same
character) ignore any white space
isIdChar
private boolean isIdChar(int c)
getLongName
public java.lang.String getLongName()
- read a long option name from the command line string. A long option name consists
of alphabetic characters and '_' with no spaces
getString
protected java.lang.String getString()
- read in a string (enclosed in double quotes) from the command line string
getString_
protected java.lang.String getString_()
getStringValue
public java.lang.String getStringValue()
- read a string, either enclosed in quotes (in which case the string can
contain spaces) or not enclosed in quotes (in which case spaces are not
allowed). Initial whitespace is skipped
isNumChar
public boolean isNumChar(int c)
- return true if the character c could be part of a floating point number#
getNumValue
public float getNumValue()
- read a numeric value (which can be in full floating point form) from the
command line string
getBoolean
public boolean getBoolean()
- if the next character in the command string is a '+' or '-' read it
shortCheck
public boolean shortCheck(Option op, int c)
- check a character against an option
longCheck
public boolean longCheck(Option op, java.lang.String s)
- check a string against an option
savePosn
public void savePosn()
- save the current position in the command string
restorePosn
public void restorePosn()
- restore the current position in the command string, as saved by savePosn
|
|||||||||
| Home >> All >> org >> pqt >> [ cloptions overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
org.pqt.cloptions.OptionProcessor