changeset 23:4a09278b5c95

indy: tweak demo driver
author jrose
date Thu, 02 Jul 2009 03:34:27 -0700
parents 2d71974f86ca
children f5ed38073bc3
files netbeans/indy-demo/src/Main.java
diffstat 1 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/netbeans/indy-demo/src/Main.java	Thu Jul 02 03:19:50 2009 -0700
+++ b/netbeans/indy-demo/src/Main.java	Thu Jul 02 03:34:27 2009 -0700
@@ -30,6 +30,7 @@
 */
 
 import java.dyn.*;
+import java.util.*;
 import static java.dyn.MethodHandles.*;
 
 public class Main {
@@ -42,12 +43,30 @@
         recipes.FastAndSlow.class,
         recipes.Curry.class
     };
-    public static void main(String[] args) throws Throwable {
-        for (Class c : CLASSES) {
+    public static void doClasses(Class[] classes, String[] args) throws Throwable {
+        for (Class c : classes) {
             MethodHandle main = lookup().findStatic(c, "main",
                     methodType(void.class, String[].class));
             System.out.println("******** "+c.getName()+"."+main);
             main.<void>invoke(args);
         }
     }
+    public static void main(String[] args) throws Throwable {
+        int arg1 = 0;
+        if (args.length >= 1) {
+            try {
+                arg1 = Integer.parseInt(args[0]);
+                args = Arrays.copyOfRange(args, 1, args.length);
+            } catch (NumberFormatException ex) {
+            }
+        }
+        if (arg1 == 0) {
+            doClasses(CLASSES, args);
+        } else {
+            for (int i = 0; i < arg1; i++) {
+                System.out.println("******** ITERATION #"+i);
+                doClasses(CLASSES, args);
+            }
+        }
+    }
 }