|
getopt-0.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jrowe.getopt.DefaultGetOptions
This is the default implementation of a GetOptions
object.
Inner Class Summary | |
protected class |
DefaultGetOptions.OptionRecord
Used to encapuslate Option objects. |
Field Summary | |
static String |
DEFAULT_ASSIGNMENT_STRING
This is string that signifies an assignment of a value to an option. |
static String |
DEFAULT_END_OF_OPTIONS_TOKEN
This is the default end of options token. |
static String |
DEFAULT_LIST_DELIMITER
This is string that delimits items in a list. |
static String |
DEFAULT_LONG_OPTION_PREFIX
This is the default long option prefix. |
static String |
DEFAULT_NEGATION_PREFIX
the Default Negation Prefix property. |
static String |
DEFAULT_SHORT_OPTION_PREFIX
This is the default option prefix. |
static String |
DEFAULT_STDIO_TOKEN
Deprecated. |
Fields inherited from interface jrowe.getopt.GetOptions |
OPTION_SETUP_DOS,
OPTION_SETUP_GNU,
OPTION_SETUP_POSIX |
Constructor Summary | |
DefaultGetOptions()
Creates a DefaultGetOptions object with the default
attributes. |
Method Summary | |
void |
add(Option option)
Adds an Option to the list of parseable options. |
Option |
get(char optionChar)
Returns an Option from the list of parseable options. |
Option |
get(String optionName)
Returns an Option from the list of parseable options. |
protected Object |
getArg(Option opt,
String optID,
String token)
Parses and returns the argument that ought to be assigned to the given option. |
String |
getEndOfOptionsToken()
Returns the End Of Options Token property. |
String |
getLongOptionPrefix()
Returns the Long Option Prefix property. |
String |
getNegationPrefix()
Returns the Negation Prefix property. |
protected List |
getOption(String token)
Returns the appropriate Option object(s) for the given
token. |
protected DefaultGetOptions.OptionRecord |
getOptionRecord(String optionID)
Returns the correct OptionRecord given an option id. |
protected List |
getParsedOptions()
Returns the usage string for this set of options. |
List |
getProgramArgs()
Returns the program arguments. |
String |
getShortOptionPrefix()
Returns the Short Option Prefix property. |
String |
getStdIOString()
Deprecated. |
List |
getTokenList()
Returns the Token List property. |
protected ListIterator |
getTokenListIterator()
An Iterator over the tokens passed in via the
setArgs method. |
protected static Map |
getUniqueMap(Map map)
Returns a Map object containing only the unique values
from the given Map object. |
String |
getUsage()
Returns the usage string for this set of options. |
protected void |
handleOptionException(OptionException e)
Handles an OptionException . |
boolean |
isAllowExplicitAssignments()
Returns the Allow Explicit Assignments property. |
protected boolean |
isEndOfOptionsToken(String s)
Returns whether the specified string indicates that only program arguments follow it. |
protected boolean |
isLongOption(String s)
|
boolean |
isLongOptionsEnabled()
Returns the Long Options Enabled property. |
protected boolean |
isOption(String s)
Returns whether the specified string is an option. |
boolean |
isPreferLongOptions()
Returns the Prefer Long Options property. |
protected boolean |
isShortOption(String s)
|
protected boolean |
isStdIn(String s)
Returns whether the given string matches the identifier used to represent the standard input. |
Iterator |
iterator()
Returns an Iterator object which will iterate over all
of the Options contained by this object. |
protected void |
parseArgs()
Parses the arguments specified by the setArgs method. |
void |
remove(Option option)
Removes an Option from the list of parseable options. |
Option |
remove(String optionName)
Removes an Option from the list of parseable options. |
void |
setAllowExplicitAssignments(boolean newAllowExplicitAssignments)
Sets the Allow Explicit Assignments property. |
void |
setArgs(String[] args)
Sets the arguments from the command line. |
void |
setEndOfOptionsToken(String newEndOfOptionsToken)
Sets the End Of Options Token property. |
void |
setLongOptionPrefix(String newLongOptionPrefix)
Sets the Long Option Prefix property. |
void |
setLongOptionsEnabled(boolean longOptionsEnabled)
Sets the Long Options Enabled property. |
void |
setNegationPrefix(String newNegationPrefix)
Sets the Negation Prefix property. |
void |
setPreferLongOptions(boolean newpreferLongOptions)
Sets the Prefer Long Options property. |
void |
setShortOptionPrefix(String newShortOptionPrefix)
Sets the Short Option Prefix property. |
void |
setStdIOString(String newStdIOString)
Deprecated. |
void |
setTokenList(List newtokenList)
Sets the Token List property. |
protected String |
stripAssignment(String s)
Returns the argument from a token. |
protected String |
stripOption(String s)
Splits a token into an option name. |
protected String |
stripPrefix(String s)
Strips the short or long option prefix off of the token string. |
protected void |
throwOptionException()
Throws an OptionException . |
protected void |
throwOptionException(String errorMsg,
int errorCode)
Throws an OptionException . |
Methods inherited from class java.lang.Object |
|
Field Detail |
public static final String DEFAULT_SHORT_OPTION_PREFIX
public static final String DEFAULT_LONG_OPTION_PREFIX
public static final String DEFAULT_END_OF_OPTIONS_TOKEN
public static final String DEFAULT_ASSIGNMENT_STRING
public static final String DEFAULT_STDIO_TOKEN
public static final String DEFAULT_LIST_DELIMITER
public static final String DEFAULT_NEGATION_PREFIX
#gegationPrefix
,
setNegationPrefix(java.lang.String)
,
getNegationPrefix()
Constructor Detail |
public DefaultGetOptions()
DefaultGetOptions
object with the default
attributes.Method Detail |
public void setTokenList(List newtokenList)
newtokenList
- the new value for the Token List propertygetTokenList()
public List getTokenList()
setTokenList(List)
public void setPreferLongOptions(boolean newpreferLongOptions)
newpreferLongOptions
- the new value for the Prefer Long Options propertyisPreferLongOptions()
public boolean isPreferLongOptions()
setPreferLongOptions(boolean)
public void setLongOptionsEnabled(boolean longOptionsEnabled)
longOptionsEnabled
- the new value for the Long Options Enabled propertypublic boolean isLongOptionsEnabled()
public void setShortOptionPrefix(String newShortOptionPrefix)
newShortOptionPrefix
- the new value for the Short Option Prefix propertypublic String getShortOptionPrefix()
public void setLongOptionPrefix(String newLongOptionPrefix)
newLongOptionPrefix
- the new value for the Long Option Prefix propertypublic String getLongOptionPrefix()
public void setEndOfOptionsToken(String newEndOfOptionsToken)
newEndOfOptionsToken
- the new value for the End Of Options Token propertypublic String getEndOfOptionsToken()
public void setStdIOString(String newStdIOString)
newStdIOString
- the new value for the Std IOString propertypublic String getStdIOString()
public void setAllowExplicitAssignments(boolean newAllowExplicitAssignments)
newAllowExplicitAssignments
- the new value for the Allow Explicit Assignments propertypublic boolean isAllowExplicitAssignments()
public void setNegationPrefix(String newNegationPrefix)
newNegationPrefix
- the new value for the Negation Prefix propertypublic String getNegationPrefix()
protected ListIterator getTokenListIterator()
Iterator
over the tokens passed in via the
setArgs
method.Iterator
object.public void add(Option option)
Option
to the list of parseable options.option
- The Option
to add.public Option remove(String optionName)
Option
from the list of parseable options.optionName
- The name of the Option
to remove.The
- Option
which was removed. If this object does
not contain an Option by that name, then
null
will be returned.public void remove(Option option)
Option
from the list of parseable options.option
- The Option
to remove.public Option get(String optionName)
Option
from the list of parseable options.optionName
- The name of the Option
to return.The
- Option
. If this object does not contain an
Option by that name, then null
will be
returned.public Option get(char optionChar)
Option
from the list of parseable options.optionChar
- The char property of the Option
to return.The
- Option
specified.
If this object does not contain an Option with the
specified property, then null
will be returned.public Iterator iterator()
Iterator
object which will iterate over all
of the Options
contained by this object.Iterator
public void setArgs(String[] args) throws OptionException
The options are processed immediately.
args
- The arguments from the command line.protected void handleOptionException(OptionException e)
OptionException
.e
- the exceptionpublic List getProgramArgs()
protected void parseArgs() throws OptionException
setArgs
method.protected boolean isOption(String s)
s
- The specified string.true
if the specified string is an option;
false
if the specified string is either a
program argument or an option argument.protected boolean isShortOption(String s)
protected boolean isLongOption(String s)
protected boolean isEndOfOptionsToken(String s)
s
- The specified string.true
if the specified string indicates that only
program arguments follow it.protected DefaultGetOptions.OptionRecord getOptionRecord(String optionID)
OptionRecord
given an option id.optionID
- this is either the name or the character property
on an Option
objectOptionRecord
. If no matching
OptionRecord
exists, then null
is
returned.protected List getOption(String token) throws OptionException
Option
object(s) for the given
token.token
- a token as if from the setArgs
method.List
of the matching Option
objects.OptionException
if the given option
doesn't existprotected Object getArg(Option opt, String optID, String token)
opt
- the given Option
token
- the given tokenOption
protected boolean isStdIn(String s)
s
- the stringprotected String stripOption(String s)
s
- the token stringString
containing the option nameprotected String stripPrefix(String s)
s
- the token stringprotected String stripAssignment(String s)
s
- the token stringprotected void throwOptionException() throws OptionException
OptionException
.protected void throwOptionException(String errorMsg, int errorCode) throws OptionException
OptionException
.e
- an OptionException
.public String getUsage()
protected List getParsedOptions()
protected static Map getUniqueMap(Map map)
Map
object containing only the unique values
from the given Map
object.map
- the given Map
objectMap
object containing only the unique values
|
getopt-0.3 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |