joptsimple
Class OptionSet

java.lang.Object
  extended by joptsimple.OptionSet

public class OptionSet
extends java.lang.Object

Representation of a group of detected command line options, their arguments, and non-option arguments.

Since:
1.0
Version:
$Id: OptionSet.java,v 1.4 2008/04/15 02:19:07 pholser Exp $
Author:
Paul Holser

Field Summary
private  java.util.Map detectedOptions
           
private  java.util.List nonOptionArguments
           
 
Constructor Summary
OptionSet()
           
 
Method Summary
(package private)  void add(java.lang.String option)
           
(package private)  void addAll(java.util.List options)
           
(package private)  void addAllWithArgument(java.util.List options, java.lang.Object argument)
           
(package private)  void addNonOptionArgument(java.lang.String argument)
           
(package private)  void addWithArgument(java.lang.String option, java.lang.Object argument)
           
 java.lang.String argumentOf(java.lang.String option)
          Gives the argument associated with the given option.
 java.util.List argumentsOf(java.lang.String option)
          Gives any arguments associated with the given option.
 boolean equals(java.lang.Object that)
          
 boolean has(java.lang.String option)
          Tells whether the given option was detected.
 boolean hasArgument(java.lang.String option)
          Tells whether there are any arguments associated with the given option.
 int hashCode()
          
 java.util.List nonOptionArguments()
          Gives the detected non-option arguments.
 java.lang.Object valueOf(java.lang.String option)
          Gives the argument associated with the given option.
 java.util.List valuesOf(java.lang.String option)
          Gives any arguments associated with the given option.
 boolean wasDetected(java.lang.String option)
          Deprecated. Use has instead.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

detectedOptions

private final java.util.Map detectedOptions

nonOptionArguments

private final java.util.List nonOptionArguments
Constructor Detail

OptionSet

OptionSet()
Method Detail

wasDetected

public boolean wasDetected(java.lang.String option)
Deprecated. Use has instead.

Tells whether the given option was detected.

Parameters:
option - the option to search for
Returns:
true if the option was detected
Since:
1.0

has

public boolean has(java.lang.String option)

Tells whether the given option was detected.

Parameters:
option - the option to search for
Returns:
true if the option was detected
Since:
2.4

hasArgument

public boolean hasArgument(java.lang.String option)

Tells whether there are any arguments associated with the given option.

Parameters:
option - the option to search for
Returns:
true if the option was detected and at least one argument was detected for the option
Since:
1.0

argumentOf

public java.lang.String argumentOf(java.lang.String option)

Gives the argument associated with the given option.

Parameters:
option - the option to search for
Returns:
the argument of the given option as a String; null if no argument is present, or that option was not detected
Throws:
OptionException - if more than one argument was detected for the option
java.lang.ClassCastException - if the argument was given a type other than String
Since:
1.0
See Also:
valueOf(String)

argumentsOf

public java.util.List argumentsOf(java.lang.String option)

Gives any arguments associated with the given option.

Parameters:
option - the option to search for
Returns:
the arguments associated with the option, as a list of objects of the type given to the arguments; an empty list if no such arguments are present, or if the option was not detected
Since:
1.0
See Also:
valuesOf(String)

valueOf

public java.lang.Object valueOf(java.lang.String option)

Gives the argument associated with the given option. If the argument was given a type, it will take on that type; otherwise, use argumentOf to get the argument as a String.

Parameters:
option - the option to search for
Returns:
the argument of the given option; null if no argument is present, or that option was not detected
Throws:
OptionException - if more than one argument was detected for the option
Since:
2.0

valuesOf

public java.util.List valuesOf(java.lang.String option)

Gives any arguments associated with the given option.

Parameters:
option - the option to search for
Returns:
the arguments associated with the option, as a list of objects of the type given to the arguments; an empty list if no such arguments are present, or if the option was not detected
Since:
2.0

nonOptionArguments

public java.util.List nonOptionArguments()

Gives the detected non-option arguments.

Returns:
the detected non-option arguments as a list of Strings.
Since:
2.1

equals

public boolean equals(java.lang.Object that)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

add

void add(java.lang.String option)

addWithArgument

void addWithArgument(java.lang.String option,
                     java.lang.Object argument)

addNonOptionArgument

void addNonOptionArgument(java.lang.String argument)

addAll

void addAll(java.util.List options)

addAllWithArgument

void addAllWithArgument(java.util.List options,
                        java.lang.Object argument)