private Command parseTokens(final String[] tokens,final ArrayList<Option> foundOptions,final ArrayList<String> foundFreeArguments,final AtomicReference<Exception> outException){
  Command c=null;
  for (int i=0; i < tokens.length; i++) {
    final String token=tokens[i];
    if (token == null || token.length() == 0) {
      continue;
    }
    boolean startsWithOptionCharacter=false;
    if (token.length() >= 2) {
      for (int j=0; j < OptionsMap.getSupportedOptionPrefixes().length; j++) {
        if (token.charAt(0) == OptionsMap.getSupportedOptionPrefixes()[j]) {
          startsWithOptionCharacter=true;
          break;
        }
      }
    }
    if (startsWithOptionCharacter) {
      final Option o;
      try {
        o=optionsMap.findOption(token);
      }
 catch (      final InvalidOptionValueException e) {
        outException.set(e);
        break;
      }
      if (o == null) {
        outException.set(new UnknownOptionException(token));
        break;
      }
      foundOptions.add(o);
      continue;
    }
    if (c == null) {
      final Command possibleCommand=commandsMap.findCommand(token);
      if (possibleCommand == null) {
        outException.set(new UnknownCommandException(token));
        break;
      }
      c=possibleCommand;
      continue;
    }
    foundFreeArguments.add(token);
  }
  return c;
}

private Command parseTokens ( final String [ ] tokens , final ArrayList < Option > foundOptions , final ArrayList < String > foundFreeArguments , final AtomicReference < Exception > outException ) { Command c = null ; for ( int i = 0 ; i < tokens . length ; i ++ ) { final String token = tokens [ i ] ; if ( token == null || token . length ( ) == 0 ) { continue ; } boolean startsWithOptionCharacter = false ; if ( token . length ( ) >= 2 ) { for ( int j = 0 ; j < OptionsMap . getSupportedOptionPrefixes ( ) . length ; j ++ ) { if ( token . charAt ( 0 ) == OptionsMap . getSupportedOptionPrefixes ( ) [ j ] ) { startsWithOptionCharacter = true ; break ; } } } if ( startsWithOptionCharacter ) { final Option o ; try { o = optionsMap . findOption ( token ) ; } catch ( final InvalidOptionValueException e ) { outException . set ( e ) ; break ; } if ( o == null ) { outException . set ( new UnknownOptionException ( token ) ) ; break ; } foundOptions . add ( o ) ; continue ; } if ( c == null ) { final Command possibleCommand = commandsMap . findCommand ( token ) ; if ( possibleCommand == null ) { outException . set ( new UnknownCommandException ( token ) ) ; break ; } c = possibleCommand ; continue ; } foundFreeArguments . add ( token ) ; } return c ; }
parse the tokens into a command , any options , and free arguments . if the command is not present ( or is not recognized ) , returns null .
