ansim/Parser.java

Go to the documentation of this file.
00001 package ansim;
00002 
00003 import ansim.Parameter;
00004 
00010 public class Parser {
00017     public static Parameter parse(String[] args) throws IllegalArgumentException {
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     }
00078 }

Generated on Wed May 5 00:06:35 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6