joptsimple
Class OptionSet

java.lang.Object
  extended by joptsimple.OptionSet

public class OptionSet
extends 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

Method Summary
 String argumentOf(String option)
          Gives the argument associated with the given option.
 List argumentsOf(String option)
          Gives any arguments associated with the given option.
 boolean equals(Object that)
          
 boolean has(String option)
          Tells whether the given option was detected.
 boolean hasArgument(String option)
          Tells whether there are any arguments associated with the given option.
 int hashCode()
          
 List nonOptionArguments()
          Gives the detected non-option arguments.
 Object valueOf(String option)
          Gives the argument associated with the given option.
 List valuesOf(String option)
          Gives any arguments associated with the given option.
 boolean wasDetected(String option)
          Deprecated. Use has instead.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

wasDetected

public boolean wasDetected(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(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(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 String argumentOf(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
ClassCastException - if the argument was given a type other than String
Since:
1.0
See Also:
valueOf(String)

argumentsOf

public List argumentsOf(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 Object valueOf(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 List valuesOf(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 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(Object that)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object


© Copyright 2004-2008 Paul R. Holser, Jr. All rights reserved. Licensed under the Academic Free License version 3.0. pholser@alumni.rice.edu