1 17 18 package SOFA.SOFAnode.Util.DFSRChecker.DFSR; 19 20 21 import SOFA.SOFAnode.Util.DFSRChecker.parser.Debug; 22 23 import com.martiansoftware.jsap.*; 24 import com.martiansoftware.jsap.stringparsers.IntegerStringParser; 25 import com.martiansoftware.jsap.stringparsers.StringStringParser; 26 27 30 public class Options { 31 34 public static final int DOTVISUALIZATION = 1; 35 36 39 public static final int ACTIONTESTCOMPLIANCE = 1; 40 41 public static final int ACTIONTESTCONSENT = 2; 42 43 public static final int ACTIONVISUALIZE = 3; 44 45 48 public static final int IAYES = 0; 49 50 public static final int IANO = 1; 51 52 public static final int IANOTRACE = 2; 53 54 55 58 public static int action = ACTIONTESTCOMPLIANCE; 59 60 63 public static boolean multinodes = true; 64 65 68 public static boolean forwardcutting = true; 69 70 73 public static boolean explicit = false; 74 75 public static int explicitsize = 1000; 76 77 81 public static int totalmemory = 60; 82 83 86 public static int statememory = 48; 87 88 92 public static int visualizationtype = 0; 93 94 97 public static boolean badactivity = true; 98 public static boolean noactivity = true; 99 public static int infiniteactivity = 1; 100 101 104 public static String inputfile = ""; 105 106 112 public static String [] parseCommandLine(String [] args) { 113 JSAP jsap; 114 JSAPResult res; 115 116 try { 117 jsap = new JSAP(); 118 IntegerStringParser isp = JSAP.INTEGER_PARSER; 119 StringStringParser ssp = JSAP.STRING_PARSER; 120 121 jsap.registerParameter(new FlaggedOption("action", ssp, "test", JSAP.REQUIRED, 'a', "action" ) ); 122 jsap.registerParameter(new Switch("disablemultinodes",'m',"nomultinodes") ); 123 jsap.registerParameter(new Switch("disableexplicit",'e',"noexplicit") ); 124 jsap.registerParameter(new Switch("disableforwardcut",'c',"noforwardcut") ); 125 jsap.registerParameter(new Switch("disablebadactivity", 'b', "nobadactivity")); 126 jsap.registerParameter(new Switch("disablenoactivity", 'n', "nonoactivity")); 127 jsap.registerParameter(new FlaggedOption("verbose", ssp, "0", JSAP.NOT_REQUIRED, 'v', "verbose" ) ); 128 jsap.registerParameter(new FlaggedOption("infiniteactivity", ssp, "notrace", JSAP.NOT_REQUIRED, 'i', "infiniteactivity")); 129 jsap.registerParameter(new FlaggedOption("file", ssp, "", JSAP.NOT_REQUIRED, 'f', "file" ) ); 130 131 jsap.registerParameter(new FlaggedOption("totalmem", isp, "60", JSAP.NOT_REQUIRED, 't', "totalmem" ) ); 132 jsap.registerParameter(new FlaggedOption("cachesize", isp, "48", JSAP.NOT_REQUIRED, 's', "cachesize" ) ); 133 134 UnflaggedOption parameters = new UnflaggedOption("protocolsetc", ssp, "", true, true); 135 136 jsap.registerParameter(parameters); 137 138 res = jsap.parse(args); 139 140 if (!res.success()) 141 return null; 142 143 } catch (Exception e) { 144 return null; 145 } 146 147 String _action = res.getString("action"); 148 149 if (_action.equals("test")) 150 action = ACTIONTESTCOMPLIANCE; 151 else if (_action.equals("testconsent")) 152 action = ACTIONTESTCONSENT; 153 else if (_action.equals("visualizedot")) { 156 action = ACTIONVISUALIZE; 157 visualizationtype = DOTVISUALIZATION; 158 } 159 else 160 return null; 161 162 163 if (res.getBoolean("disablemultinodes")) 164 multinodes = false; 165 166 if (res.getBoolean("disableexplicit")) 167 explicit = false; 168 169 if (res.getBoolean("disableforwardcut")) 170 forwardcutting = false; 171 172 if (res.getBoolean("disablebadactivity")) 173 badactivity = false; 174 175 if (res.getBoolean("disablenoactivity")) 176 noactivity = false; 177 178 String ia = res.getString("infiniteactivity"); 179 180 if (ia.equals("yes")) 181 infiniteactivity = IAYES; 182 else if (ia.equals("no")) 183 infiniteactivity = IANO; 184 else if (ia.equals("notrace")) 185 infiniteactivity = IANOTRACE; 186 else 187 return null; 188 189 String verbose = res.getString("verbose"); 190 191 if (verbose.equals("0")) 192 Debug.setLevel(0); 193 else if (verbose.equals("1")) 194 Debug.setLevel(2); 195 else if (verbose.equals("2")) 196 Debug.setLevel(3); 197 else 198 return null; 199 200 totalmemory = res.getInt("totalmem"); 201 statememory = res.getInt("cachesize"); 202 203 Options.inputfile = res.getString("file"); 204 205 return res.getStringArray("protocolsetc"); 206 } 207 } 208 | Popular Tags |