class CmdlineOptions {

  public void parse() throws OptionsException {
    Getopt g = new Getopt(application, argv, sargs.toString(), largs.toArray(new LongOpt[] {}));
    g.setOpterr(false); // We'll do our own error handling
    
    int c;
    while ((c = g.getopt()) != -1) {
      switch (c) {
      case '?':
        // Get invalid option
        int ix = g.getOptind();
        String option = argv[(ix == 0 ? 0 : ix-1)];
        throw new OptionsException(option, g.getOptarg());
      default:
        ListenerIF listener = listeners.get(new Integer(c));
        if (listener != null)
          listener.processOption((char)c, g.getOptarg());
        else
          System.err.println ("Warning: option '" + (char)c + "' ignored");
        break;
      }
    }
    
    // Get non-option arguments
    for (int i = g.getOptind(); i < argv.length ; i++) {
      arguments.add(argv[i]);
    }
  }

  public  CmdlineOptions(String application, String[] argv);

}