org.crosswire.common.options

## Class GetOptions

- java.lang.Object
- - org.crosswire.common.options.GetOptions

-     public class GetOptions
      extends Object

  GetOptions parses an argument list for requested arguments given by an OptionList.
  This supports short and long options:
  Short Options have the following characteristics.
  - A single dash, '-', starts a flag or a flag sequence. An example of a flag is '-c' and a flag sequence is '-xyz'.
  - A flag may have a required argument. The flag may or may not be separated by a space from it's argument. For example, both -fbar and -f bar are acceptable.
  - A flag may have an optional argument. The flag must not be separated by a space from it's optional argument. For example, -fbar is acceptable provides bar as the argument, but -f bar has bar as a non-option argument.
  - These rules can combine. For example, -xyzfoo can be the same as -x -y -z foo
  - If an Option expects an argument, then that argument can have a leading '-'. That is, if -x requires an option then the argument -y can be given as -x-y or -x -y.
  Long Options have the following characteristics:
  - A double dash '--' starts a single flag. For example --print. Note, a long option is typically descriptive, but can be a single character.
  - An argument may be given in one of two ways --file=filename or --file filename. That is, separated by an '=' sign or whitespace.
  Note:
  - Options can be repeated. What that means is up to the program.
  - The '--' sequence terminates argument processing.
  - A '-' by itself is not a flag.
  - Unrecognized flags are an error.
  - Unrecognized arguments are moved after the processed flags.
  Author:
    DM Smith
  See Also:
    `The GNU Lesser General Public License for details.`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private String[]` | `args`
    `private List<String>` | `nonOptionArgs` The position in the array that is currently being studied.
    `private String` | `programName`
    `private OptionList` | `programOptions`
    `private Map<Option,String>` | `suppliedOptions`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GetOptions(String programName, String[] args, OptionList programOptions)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getProgramName()`
    `private void` | `parse()`
    `void` | `setProgramName(String programName)`
    `static void` | `swap(Object[] array, int firstStart, int firstEnd, int secondEnd)` Swap adjacent blocks in an array.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### programName

          private String programName

    - #### args

          private String[] args

    - #### programOptions

          private OptionList programOptions

    - #### nonOptionArgs

          private List<String> nonOptionArgs

      The position in the array that is currently being studied.

    - #### suppliedOptions

          private Map<Option,String> suppliedOptions

  - ### Constructor Detail

    - #### GetOptions

          public GetOptions(String programName,
                    String[] args,
                    OptionList programOptions)

  - ### Method Detail

    - #### getProgramName

          public String getProgramName()

      Returns:
        the programName

    - #### setProgramName

          public void setProgramName(String programName)

      Parameters:
        `programName` - the programName to set

    - #### parse

          private void parse()

    - #### swap

          public static void swap(Object[] array,
                  int firstStart,
                  int firstEnd,
                  int secondEnd)

      Swap adjacent blocks in an array.
      Parameters:
        `array` - The array to modify in place
        `firstStart` - the index of the start of the first block
        `firstEnd` - the index of the end of the first block
        `secondEnd` - the index of the end of the second block. Note: the start of the second block is firstEnd + 1