org.apache.commons.cli2.commandline
Class CommandLineImpl

java.lang.Object
  extended by org.apache.commons.cli2.commandline.CommandLineImpl
All Implemented Interfaces:
CommandLine
Direct Known Subclasses:
DefaultingCommandLine, PreferencesCommandLine, PropertiesCommandLine, WriteableCommandLineImpl

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.


Constructor Summary
CommandLineImpl()
           
 
Method Summary
 int getOptionCount(Option option)
          Retrieves the number of times the specified Option appeared in this CommandLine
 int getOptionCount(String trigger)
          Retrieves the number of times the specified Option appeared in this CommandLine
 String getProperty(Option option, String property)
          Retrieves the value associated with the specified property
 Boolean getSwitch(Option option)
          Retrieves the Boolean value associated with the specified Switch
 Boolean getSwitch(String trigger)
          Retrieves the Boolean value associated with the specified Switch
 Boolean getSwitch(String trigger, Boolean defaultValue)
          Retrieves the Boolean value associated with the specified Switch
 Object getValue(Option option)
          Retrieves the single Argument value associated with the specified Option
 Object getValue(Option option, Object defaultValue)
          Retrieves the single Argument value associated with the specified Option
 Object getValue(String trigger)
          Retrieves the single Argument value associated with the specified Option
 Object getValue(String trigger, Object defaultValue)
          Retrieves the single Argument value associated with the specified Option
 List getValues(Option option)
          Retrieves the Argument values associated with the specified Option
 List getValues(String trigger)
          Retrieves the Argument values associated with the specified Option
 List getValues(String trigger, List defaultValues)
          Retrieves the Argument values associated with the specified Option
 boolean hasOption(String trigger)
          Detects the presence of an option with the specified trigger in this CommandLine.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.commons.cli2.CommandLine
getOption, getOptions, getOptionTriggers, getProperties, getProperties, getProperty, getProperty, getSwitch, getValues, hasOption
 

Constructor Detail

CommandLineImpl

public CommandLineImpl()
Method Detail

hasOption

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

Specified by:
hasOption in interface CommandLine
Parameters:
trigger - the trigger to search for
Returns:
true iff an option with this trigger is present

getValues

public final List getValues(String trigger)
Description copied from interface: CommandLine
Retrieves the Argument values associated with the specified Option

Specified by:
getValues in interface CommandLine
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)
Description copied from interface: CommandLine
Retrieves the Argument values associated with the specified Option

Specified by:
getValues in interface CommandLine
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)
Description copied from interface: CommandLine
Retrieves the Argument values associated with the specified Option

Specified by:
getValues in interface CommandLine
Parameters:
option - the Option associated with the values
Returns:
a list of values or an empty List if none are found

getValue

public final Object getValue(String trigger)
Description copied from interface: CommandLine
Retrieves the single Argument value associated with the specified Option

Specified by:
getValue in interface CommandLine
Parameters:
trigger - a trigger used to lookup the Option
Returns:
the matching value or null if none exists

getValue

public final Object getValue(String trigger,
                             Object defaultValue)
Description copied from interface: CommandLine
Retrieves the single Argument value associated with the specified Option

Specified by:
getValue in interface CommandLine
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

getValue

public final Object getValue(Option option)
Description copied from interface: CommandLine
Retrieves the single Argument value associated with the specified Option

Specified by:
getValue in interface CommandLine
Parameters:
option - the Option associated with the value
Returns:
the matching value or null if none exists

getValue

public final Object getValue(Option option,
                             Object defaultValue)
Description copied from interface: CommandLine
Retrieves the single Argument value associated with the specified Option

Specified by:
getValue in interface CommandLine
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

getSwitch

public final Boolean getSwitch(String trigger)
Description copied from interface: CommandLine
Retrieves the Boolean value associated with the specified Switch

Specified by:
getSwitch in interface CommandLine
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)
Description copied from interface: CommandLine
Retrieves the Boolean value associated with the specified Switch

Specified by:
getSwitch in interface CommandLine
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)
Description copied from interface: CommandLine
Retrieves the Boolean value associated with the specified Switch

Specified by:
getSwitch in interface CommandLine
Parameters:
option - the Option associated with the value
Returns:
the Boolean associated with option or null if none exists

getProperty

public final String getProperty(Option option,
                                String property)
Description copied from interface: CommandLine
Retrieves the value associated with the specified property

Specified by:
getProperty in interface CommandLine
Parameters:
option - the option i.e., -D
property - the property name to lookup
Returns:
the value of the property or null

getOptionCount

public final int getOptionCount(String trigger)
Description copied from interface: CommandLine
Retrieves the number of times the specified Option appeared in this CommandLine

Specified by:
getOptionCount in interface 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)
Description copied from interface: CommandLine
Retrieves the number of times the specified Option appeared in this CommandLine

Specified by:
getOptionCount in interface CommandLine
Parameters:
option - the Option associated to check
Returns:
the number of occurrences of the option


Copyright © 2002-2010 Apache Software Foundation. All Rights Reserved.