< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/Options.java

Print this page




 407      */
 408     public void displayHelp(final boolean extended) {
 409         for (final OptionTemplate t : Options.validOptions) {
 410             if ((extended || !t.isUndocumented()) && t.getResource().equals(resource)) {
 411                 err.println(t);
 412                 err.println();
 413             }
 414         }
 415     }
 416 
 417     /**
 418      * Processes the arguments and stores their information. Throws
 419      * IllegalArgumentException on error. The message can be analyzed by the
 420      * displayHelp function to become more context sensitive
 421      *
 422      * @param args arguments from command line
 423      */
 424     public void process(final String[] args) {
 425         final LinkedList<String> argList = new LinkedList<>();
 426         addSystemProperties(NASHORN_ARGS_PREPEND_PROPERTY, argList);


 427         Collections.addAll(argList, args);


 428         addSystemProperties(NASHORN_ARGS_PROPERTY, argList);



 429 

 430         while (!argList.isEmpty()) {
 431             final String arg = argList.remove(0);
 432             Objects.requireNonNull(arg);
 433 
 434             // skip empty args
 435             if (arg.isEmpty()) {
 436                 continue;
 437             }
 438 
 439             // user arguments to the script
 440             if ("--".equals(arg)) {
 441                 arguments.addAll(argList);
 442                 argList.clear();
 443                 continue;
 444             }
 445 
 446             // If it doesn't start with -, it's a file. But, if it is just "-",
 447             // then it is a file representing standard input.
 448             if (!arg.startsWith("-") || arg.length() == 1) {
 449                 files.add(arg);




 407      */
 408     public void displayHelp(final boolean extended) {
 409         for (final OptionTemplate t : Options.validOptions) {
 410             if ((extended || !t.isUndocumented()) && t.getResource().equals(resource)) {
 411                 err.println(t);
 412                 err.println();
 413             }
 414         }
 415     }
 416 
 417     /**
 418      * Processes the arguments and stores their information. Throws
 419      * IllegalArgumentException on error. The message can be analyzed by the
 420      * displayHelp function to become more context sensitive
 421      *
 422      * @param args arguments from command line
 423      */
 424     public void process(final String[] args) {
 425         final LinkedList<String> argList = new LinkedList<>();
 426         addSystemProperties(NASHORN_ARGS_PREPEND_PROPERTY, argList);
 427         processArgList(argList);
 428         assert argList.isEmpty();
 429         Collections.addAll(argList, args);
 430         processArgList(argList);
 431         assert argList.isEmpty();
 432         addSystemProperties(NASHORN_ARGS_PROPERTY, argList);
 433         processArgList(argList);
 434         assert argList.isEmpty();
 435     }
 436 
 437     private void processArgList(final LinkedList<String> argList) {
 438         while (!argList.isEmpty()) {
 439             final String arg = argList.remove(0);
 440             Objects.requireNonNull(arg);
 441 
 442             // skip empty args
 443             if (arg.isEmpty()) {
 444                 continue;
 445             }
 446 
 447             // user arguments to the script
 448             if ("--".equals(arg)) {
 449                 arguments.addAll(argList);
 450                 argList.clear();
 451                 continue;
 452             }
 453 
 454             // If it doesn't start with -, it's a file. But, if it is just "-",
 455             // then it is a file representing standard input.
 456             if (!arg.startsWith("-") || arg.length() == 1) {
 457                 files.add(arg);


< prev index next >