1
2 import net.sourceforge.jparam.paramset.ParamSet;
3 import net.sourceforge.jparam.paramset.iParam;
4 import net.sourceforge.jparam.paramset.ioParam;
5 import ducks.Duck;
6 import ducks.DuckRegistrations;
7
8 public class test2 {
9
10
11 private static boolean DEBUG = false;
12
13 public static void main(String[] args) {
14
15 DuckRegistrations.registerDucks();
16
17 try {
18
19 ParamSet ps = new ParamSet();
20 ps.addParam(new iParam("d"));
21 String input[] = { "d=duckling(0.5,7)" };
22 ps.input(input);
23 } catch (Exception e) {
24 handleException(e);
25 }
26
27 try {
28 ParamSet ps = new ParamSet();
29
30 ps.addParam(new ioParam(
31 String input[] = { "d=duck(\"Testing output\")" };
32
33 ps.input(input);
34 ps.output(System.out);
35 } catch (Exception e) {
36 handleException(e);
37 }
38
39 try {
40 ParamSet ps = new ParamSet();
41
42 ps.addParam(new iParam(
43 } catch (Exception e) {
44 handleException(e);
45 }
46
47 try {
48 ParamSet ps = new ParamSet();
49 ps
50 .addParam(new iParam(
51 "I am a string")));
52 } catch (Exception e) {
53 handleException(e);
54 }
55
56 try {
57 ParamSet ps = new ParamSet();
58 ps.addParam(new iParam("d", new Duck()));
59 } catch (Exception e) {
60 handleException(e);
61 }
62 }
63
64 private static void handleException(Exception e) {
65 System.out.println("Got following error - ");
66 System.out.println(e.getMessage());
67 if (DEBUG) {
68 e.printStackTrace(System.out);
69 }
70 }
71 }