|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.cli2.commandline.CommandLineImpl
org.apache.commons.cli2.commandline.PreferencesCommandLine
public class PreferencesCommandLine
A CommandLine implementation using the Preferences API, useful when
constructing a complex DefaultingCommandLine
This implementation uses the children of a single preference node to populate
the CommandLine. Options are keyed from their preferred name and presence in
the Preferences object is taken as presence in the CommandLine. Argument
values are taken from the Preference value and are optionally separated using
the separator char defined, at construction time. Switch values can be
specified using a simple value of true
or false
;
obviously this means that Switches with Arguments are not supported by this
implementation.
Preferences
,
DefaultingCommandLine
,
Option.getPreferredName()
Field Summary | |
---|---|
private static char |
NUL
|
private java.util.prefs.Preferences |
preferences
|
private Option |
root
|
private char |
separator
|
Constructor Summary | |
---|---|
PreferencesCommandLine(Option root,
java.util.prefs.Preferences preferences)
Creates a new PreferencesCommandLine using the specified root Option and Preferences node. |
|
PreferencesCommandLine(Option root,
java.util.prefs.Preferences preferences,
char separator)
Creates a new PreferencesCommandLine using the specified root Option, Preferences node and value separator. |
Method Summary | |
---|---|
Option |
getOption(java.lang.String trigger)
Finds the Option with the specified trigger |
java.util.List |
getOptions()
Retrieves a list of all Options found in this CommandLine |
java.util.Set |
getOptionTriggers()
Retrieves a list of all Option triggers found in this CommandLine |
java.util.Set |
getProperties()
Retrieves the set of all property names associated with this CommandLine |
java.lang.String |
getProperty(java.lang.String property,
java.lang.String defaultValue)
Retrieves the value associated with the specified property |
java.lang.Boolean |
getSwitch(Option option,
java.lang.Boolean defaultValue)
Retrieves the Boolean value associated with the specified Switch |
java.util.List |
getValues(Option option,
java.util.List defaultValues)
Retrieves the Argument values associated with the specified Option |
boolean |
hasOption(Option option)
Detects the presence of an option in this CommandLine. |
Methods inherited from class org.apache.commons.cli2.commandline.CommandLineImpl |
---|
getOptionCount, getOptionCount, getProperty, getSwitch, getSwitch, getSwitch, getValue, getValue, getValue, getValue, getValues, getValues, getValues, hasOption |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final char NUL
private final java.util.prefs.Preferences preferences
private final Option root
private final char separator
Constructor Detail |
---|
public PreferencesCommandLine(Option root, java.util.prefs.Preferences preferences)
root
- the CommandLine's root Optionpreferences
- the Preferences node to get values frompublic PreferencesCommandLine(Option root, java.util.prefs.Preferences preferences, char separator)
root
- the CommandLine's root Optionpreferences
- the Preferences node to get values fromseparator
- the character to split argument valuesMethod Detail |
---|
public boolean hasOption(Option option)
CommandLine
option
- the Option to search for
public Option getOption(java.lang.String trigger)
CommandLine
trigger
- the name of the option to retrieve
public java.util.List getValues(Option option, java.util.List defaultValues)
CommandLine
option
- the Option associated with the valuesdefaultValues
- the result to return if no values are found
public java.lang.Boolean getSwitch(Option option, java.lang.Boolean defaultValue)
CommandLine
option
- the Option associated with the valuedefaultValue
- the Boolean to use if none match
public java.lang.String getProperty(java.lang.String property, java.lang.String defaultValue)
CommandLine
property
- the property name to lookupdefaultValue
- the value to use if no other is found
public java.util.Set getProperties()
CommandLine
public java.util.List getOptions()
CommandLine
public java.util.Set getOptionTriggers()
CommandLine
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |