Definition at line 10 of file ansim/Parser.java.
Static Public Member Functions | |
| static Parameter | parse (String[] args) throws IllegalArgumentException |
| static Parameter ansim::Parser::parse | ( | String[] | args | ) | throws IllegalArgumentException [inline, static] |
method for parsing command line arguments
| args | command line arguments |
| IllegalArgumentException |
Definition at line 17 of file ansim/Parser.java.
00017 { 00018 String net = ""; 00019 String trace = ""; 00020 String out = ""; 00021 00022 boolean hasNet = false; 00023 boolean hasTrace = false; 00024 boolean hasOut = false; 00025 00026 for (int i=0; i<args.length; i++) { 00027 if ("ns2".equals(args[i].toLowerCase())) { 00028 } 00029 00030 if ("-n".equals(args[i])) { 00031 // net file 00032 if (++i<args.length) { 00033 if (!args[i].startsWith("-")) { 00034 net = args[i]; 00035 hasNet = true; 00036 } 00037 } 00038 } 00039 00040 if ("-t".equals(args[i])) { 00041 // trace file 00042 if (++i<args.length) { 00043 if (!args[i].startsWith("-")) { 00044 trace = args[i]; 00045 hasTrace = true; 00046 } 00047 } 00048 } 00049 00050 if ("-o".equals(args[i])) { 00051 // out file 00052 if (++i<args.length) { 00053 if (!args[i].startsWith("-")) { 00054 out = args[i]; 00055 hasOut = true; 00056 } 00057 } 00058 } 00059 } 00060 00061 // must have net file argument 00062 if (!hasNet) { 00063 throw new IllegalArgumentException("no netfile specified!"); 00064 } 00065 00066 // must have trace file argument 00067 if (!hasTrace) { 00068 throw new IllegalArgumentException("no tracefile specified!"); 00069 } 00070 00071 // must have out file argument 00072 if (!hasOut) { 00073 throw new IllegalArgumentException("no outfile specified!"); 00074 } 00075 00076 return new Parameter(net, trace, out); 00077 }
1.5.6