Options (Commons CLI 1.2 API)
Keywords: org.apache.commons.cli.Options class

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.commons.cli
Class Options

    java.lang.Object
      org.apache.commons.cli.Options

All Implemented Interfaces:
  Serializable

    public class Options

extends Object
implements Serializable

Main entry-point into the library.

Options represents a collection of `Option` objects, which describe the possible options for a command-line.

It may flexibly parse long and short options, with or without values. Additionally, it may parse only a portion of a commandline, allowing for flexible multi-stage parsing.

Version:
  $Revision: 680644 $, $Date: 2008-07-29 01:13:48 -0700 (Tue, 29 Jul 2008) $
Author:
  bob mcwhirter (bob @ werken.com), James Strachan
See Also:
  `CommandLine`, Serialized Form

Constructor Summary
`Options()`

Method Summary
`Options` | `addOption(Option opt)` Adds an option instance
`Options` | `addOption(String opt, boolean hasArg, String description)` Add an option that only contains a short-name.
`Options` | `addOption(String opt, String longOpt, boolean hasArg, String description)` Add an option that contains a short-name and a long-name.
`Options` | `addOptionGroup(OptionGroup group)` Add the specified option group.
`Option` | `getOption(String opt)` Retrieve the `Option` matching the long or short name specified.
`OptionGroup` | `getOptionGroup(Option opt)` Returns the OptionGroup the `opt` belongs to.
`Collection` | `getOptions()` Retrieve a read-only list of options in this set
`List` | `getRequiredOptions()` Returns the required options.
`boolean` | `hasOption(String opt)` Returns whether the named `Option` is a member of this `Options`.
`String` | `toString()` Dump state, suitable for debugging.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### Options

    public Options()

Method Detail

### addOptionGroup

    public Options addOptionGroup(OptionGroup group)

  Add the specified option group.

  Parameters:
    `group` - the OptionGroup that is to be added
  Returns:
    the resulting Options instance

### addOption

    public Options addOption(String opt,
                             boolean hasArg,
                             String description)

  Add an option that only contains a short-name. It may be specified as requiring an argument.

  Parameters:
    `opt` - Short single-character name of the option.
    `hasArg` - flag signally if an argument is required after this option
    `description` - Self-documenting description
  Returns:
    the resulting Options instance

### addOption

    public Options addOption(String opt,
                             String longOpt,
                             boolean hasArg,
                             String description)

  Add an option that contains a short-name and a long-name. It may be specified as requiring an argument.

  Parameters:
    `opt` - Short single-character name of the option.
    `longOpt` - Long multi-character name of the option.
    `hasArg` - flag signally if an argument is required after this option
    `description` - Self-documenting description
  Returns:
    the resulting Options instance

### addOption

    public Options addOption(Option opt)

  Adds an option instance

  Parameters:
    `opt` - the option that is to be added
  Returns:
    the resulting Options instance

### getOptions

    public Collection getOptions()

  Retrieve a read-only list of options in this set

  Returns:
    read-only Collection of `Option` objects in this descriptor

### getRequiredOptions

    public List getRequiredOptions()

  Returns the required options.

  Returns:
    List of required options

### getOption

    public Option getOption(String opt)

  Retrieve the `Option` matching the long or short name specified. The leading hyphens in the name are ignored (up to 2).

  Parameters:
    `opt` - short or long name of the `Option`
  Returns:
    the option represented by opt

### hasOption

    public boolean hasOption(String opt)

  Returns whether the named `Option` is a member of this `Options`.

  Parameters:
    `opt` - short or long name of the `Option`
  Returns:
    true if the named `Option` is a member of this `Options`

### getOptionGroup

    public OptionGroup getOptionGroup(Option opt)

  Returns the OptionGroup the `opt` belongs to.

  Parameters:
    `opt` - the option whose OptionGroup is being queried.
  Returns:
    the OptionGroup if `opt` is part of an OptionGroup, otherwise return null

### toString

    public String toString()

  Dump state, suitable for debugging.

  Overrides:
    `toString` in class `Object`
  Returns:
    Stringified form of this object

Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002-2009 The Apache Software Foundation. All Rights Reserved.