Overview | Package | Class | Tree | Deprecated | Index | Help
| Qizx/Open v0.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.xfra.qizxopen.util
Class CLOptions

    java.lang.Object
      |
      +--net.xfra.qizxopen.util.CLOptions

public class CLOptions
extends java.lang.Object

Command line option analyzer.

Nested Class Summary
`static class` | `CLOptions.Exception`

Field Summary
`static int` | `ALL_ARG` Gets all following arguments to a String array field.
`static int` | `HELP_ARG` Prints help.
`static int` | `NEXT_ARG` Gets the following argument to a String field.
`static int` | `RESET_ARG` Resets a boolean field (no argument).
`static int` | `SET_ARG` Sets a boolean field (no argument).
`static int` | `STICKY_ARG` Gets the end of the argument to a String field.

Constructor Summary
`CLOptions(java.lang.String appName)` Creation with an application name.

Method Summary
`void` | `argument(java.lang.String key, java.lang.String field, int cardinality, java.lang.String help)` Declares an argument (aka Anonymous Option).
`void` | `declare(java.lang.String key, int type, java.lang.String help)`
`void` | `declare(java.lang.String key, java.lang.String field, int type, java.lang.String help)` Declares an option.
`void` | `parse(java.lang.String[] args, java.lang.Object storage)` Parses the command line.
`void` | `printHelp(java.io.PrintStream out)`

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

Field Detail

### NEXT_ARG

    public static final int NEXT_ARG

  Gets the following argument to a String field.

  See Also:
    Constant Field Values

### STICKY_ARG

    public static final int STICKY_ARG

  Gets the end of the argument to a String field.

  See Also:
    Constant Field Values

### SET_ARG

    public static final int SET_ARG

  Sets a boolean field (no argument).

  See Also:
    Constant Field Values

### RESET_ARG

    public static final int RESET_ARG

  Resets a boolean field (no argument).

  See Also:
    Constant Field Values

### ALL_ARG

    public static final int ALL_ARG

  Gets all following arguments to a String array field.

  See Also:
    Constant Field Values

### HELP_ARG

    public static final int HELP_ARG

  Prints help.

  See Also:
    Constant Field Values

Constructor Detail

### CLOptions

    public CLOptions(java.lang.String appName)

  Creation with an application name.

  Options must then be defined by declare().

Parameters:
  `appName` - name of the application

Method Detail

### declare

    public void declare(java.lang.String key,
                        java.lang.String field,
                        int type,
                        java.lang.String help)

  Declares an option.

  Parameters:
    `key` - appearance of the option switch. A null key means an anonymous argument. an anonymous argument may be repeatable if the type is ALL_ARG.
    `field` - name of a Java field of the 'storage' argument of next(): receives the value. Its type is used for automatic conversion. A field ALL_ARG must be of type String[].
    `type` - values: NEXT_ARG, SET_ARG, RESET_ARG, ALL_ARG, HELP_ARG.
    `help` - option help description.

### declare

    public void declare(java.lang.String key,
                        int type,
                        java.lang.String help)

### argument

    public void argument(java.lang.String key,
                         java.lang.String field,
                         int cardinality,
                         java.lang.String help)

  Declares an argument (aka Anonymous Option).

  Parameters:
    `cardinality` - A value of 1 means that the argument must be present once, 0 that the argument is optional, 2 or more that the argument may be repeated (in that case, each call to next will get the next value). Only the last argument may be optional or repeated.

### parse

    public void parse(java.lang.String[] args,
                      java.lang.Object storage)
               throws CLOptions.Exception

  Parses the command line.

  The values of options are stored into the (public) fields of 'storage' that have the name specified in declare().

  Checks

    `CLOptions.Exception`

### printHelp

    public void printHelp(java.io.PrintStream out)

Overview | Package | Class | Tree | Deprecated | Index | Help
| Copyright Xavier FRANC 2003-2004
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD