private Map < String , String > parseArgsIntoMap ( String [ ] args ) { Map < String , String > parms = new HashMap < String , String > ( ) ; for ( int i = 0 ; i < args . length ; i ++ ) { String key = args [ i ] ; if ( ! isKeyword ( key ) ) { throw new ValidatorProcessUsageException ( "'" + key + "' is not a keyword." ) ; } if ( ! ALL_PARAMETERS . contains ( key ) ) { throw new ValidatorProcessUsageException ( "'" + key + "' is not a recognized keyword." ) ; } if ( i >= args . length - 1 ) { parms . put ( key , null ) ; } else { String value = args [ i + 1 ] ; if ( isKeyword ( value ) ) { parms . put ( key , null ) ; } else { parms . put ( key , value ) ; i ++ ; } } } return parms ; }
Decide which of the command line arguments are keywords and which are values and build a map to hold them .