net.dpml.cli.commandline

Class CommandLineImpl

public abstract class CommandLineImpl extends Object implements CommandLine

Instances of CommandLine represent a command line that has been processed according to the definition supplied to the parser.

Version: @PROJECT-VERSION@

Author: @PUBLISHER-NAME@

Method Summary
intgetOptionCount(String trigger)
Retrieves the number of times the specified Option appeared in this CommandLine
intgetOptionCount(Option option)
Retrieves the number of times the specified Option appeared in this CommandLine
StringgetProperty(String property)
Retrieves the value associated with the specified property
BooleangetSwitch(String trigger)
Retrieves the Boolean value associated with the specified Switch
BooleangetSwitch(String trigger, Boolean defaultValue)
Retrieves the Boolean value associated with the specified Switch
BooleangetSwitch(Option option)
Retrieves the Boolean value associated with the specified Switch
ObjectgetValue(String trigger)
Retrieves the single Argument value associated with the specified Option
ObjectgetValue(String trigger, Object defaultValue)
Retrieves the single Argument value associated with the specified Option
ObjectgetValue(Option option)
Retrieves the single Argument value associated with the specified Option
ObjectgetValue(Option option, Object defaultValue)
Retrieves the single Argument value associated with the specified Option
ListgetValues(String trigger)
Retrieves the Argument values associated with the specified Option
ListgetValues(String trigger, List defaultValues)
Retrieves the Argument values associated with the specified Option
ListgetValues(Option option)
Retrieves the Argument values associated with the specified Option
booleanhasOption(String trigger)
Detects the presence of an option with the specified trigger in this CommandLine.

Method Detail

getOptionCount

public final int getOptionCount(String trigger)
Retrieves the number of times the specified Option appeared in this CommandLine

Parameters: trigger a trigger used to lookup the Option

Returns: the number of occurrences of the option

getOptionCount

public final int getOptionCount(Option option)
Retrieves the number of times the specified Option appeared in this CommandLine

Parameters: option the Option associated to check

Returns: the number of occurrences of the option

getProperty

public final String getProperty(String property)
Retrieves the value associated with the specified property

Parameters: property the property name to lookup

Returns: the value of the property or null

getSwitch

public final Boolean getSwitch(String trigger)
Retrieves the Boolean value associated with the specified Switch

Parameters: trigger a trigger used to lookup the Option

Returns: the Boolean associated with trigger or null if none exists

getSwitch

public final Boolean getSwitch(String trigger, Boolean defaultValue)
Retrieves the Boolean value associated with the specified Switch

Parameters: trigger a trigger used to lookup the Option defaultValue the Boolean to use if none match

Returns: the Boolean associated with trigger or defaultValue if none exists

getSwitch

public final Boolean getSwitch(Option option)
Retrieves the Boolean value associated with the specified Switch

Parameters: option the Option associated with the value

Returns: the Boolean associated with option or null if none exists

getValue

public final Object getValue(String trigger)
Retrieves the single Argument value associated with the specified Option

Parameters: trigger a trigger used to lookup the Option

Returns: the matching value or null if none exists

Throws: IllegalStateException if more than one values are found

getValue

public final Object getValue(String trigger, Object defaultValue)
Retrieves the single Argument value associated with the specified Option

Parameters: trigger a trigger used to lookup the Option defaultValue the result to use if no values are found

Returns: the matching value or defaultValue if none exists

Throws: IllegalStateException if more than one values are found

getValue

public final Object getValue(Option option)
Retrieves the single Argument value associated with the specified Option

Parameters: option the Option associated with the value

Returns: the matching value or null if none exists

Throws: IllegalStateException if more than one values are found

getValue

public final Object getValue(Option option, Object defaultValue)
Retrieves the single Argument value associated with the specified Option

Parameters: option the Option associated with the value defaultValue the result to use if no values are found

Returns: the matching value or defaultValue if none exists

Throws: IllegalStateException if more than one value is found

getValues

public final List getValues(String trigger)
Retrieves the Argument values associated with the specified Option

Parameters: trigger a trigger used to lookup the Option

Returns: a list of values or an empty List if none are found

getValues

public final List getValues(String trigger, List defaultValues)
Retrieves the Argument values associated with the specified Option

Parameters: trigger a trigger used to lookup the Option defaultValues the result to return if no values are found

Returns: a list of values or defaultValues if none are found

getValues

public final List getValues(Option option)
Retrieves the Argument values associated with the specified Option

Parameters: option the Option associated with the values

Returns: a list of values or an empty List if none are found

hasOption

public final boolean hasOption(String trigger)
Detects the presence of an option with the specified trigger in this CommandLine.

Parameters: trigger the trigger to search for

Returns: true iff an option with this trigger is present