00001 package edu.ksu.cis.bandera.bui.session.datastructure;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 import java.io.*;
00036 import java.util.*;
00037 import edu.ksu.cis.bandera.jjjc.util.*;
00038 import edu.ksu.cis.bandera.bui.BUI;
00039 import edu.ksu.cis.bandera.bui.JPFOption;
00040 import edu.ksu.cis.bandera.util.DefaultValues;
00041
00042 public class Session implements Comparable {
00043 private String name;
00044 private String description = "none";
00045 private String filename;
00046 private String classpath = ".";
00047 private String[] includedPackagesOrTypes = new String[0];
00048 private String outputName = "default";
00049 private String workingDirectory = System.getProperty("user.dir");
00050 private boolean doSlicer = false;
00051 private boolean doSLABS = false;
00052 private boolean doChecker = false;
00053 private String specFilename;
00054 private String activeTemporal;
00055 private HashSet activeAssertions = new HashSet();
00056 private String absFilename;
00057 private String bircOption;
00058 private Hashtable resources = new Hashtable();
00059 private boolean useJPF = false;
00060 private String jpfOptions;
00061 private boolean useSPIN = false;
00062 private String spinOptions;
00063 private boolean useSMV = false;
00064 private String smvOptions;
00065 private boolean useDSPIN = false;
00066 private String dspinOptions;
00067 private int birMinIntRange = DefaultValues.birMinIntRange;
00068 private int birMaxIntRange = DefaultValues.birMaxIntRange;
00069 private int birMaxArrayLen = DefaultValues.birMaxArrayLen;
00070 private int birMaxInstances = DefaultValues.birMaxInstances;
00071
00072
00073
00074
00075 public Session(String name) {
00076 setName(name);
00077 }
00078
00079
00080
00081
00082 public void addActiveAssertion(String name) {
00083 activeAssertions.add(name);
00084 }
00085
00086
00087
00088
00089
00090 public int compareTo(Object object) {
00091 return name.compareTo(((Session) object).getName());
00092 }
00093
00094
00095
00096
00097 public java.lang.String getAbsFilename() {
00098 return absFilename;
00099 }
00100
00101
00102
00103
00104 public java.util.HashSet getActiveAssertions() {
00105 return activeAssertions;
00106 }
00107
00108
00109
00110
00111 public java.lang.String getActiveTemporal() {
00112 return activeTemporal;
00113 }
00114
00115
00116
00117
00118 public java.lang.String getBIRCOption() {
00119 return bircOption;
00120 }
00121
00122
00123
00124
00125 public int getBirMaxArrayLen() {
00126 return birMaxArrayLen;
00127 }
00128
00129
00130
00131
00132 public int getBirMaxInstances() {
00133 return birMaxInstances;
00134 }
00135
00136
00137
00138
00139 public int getBirMaxIntRange() {
00140 return birMaxIntRange;
00141 }
00142
00143
00144
00145
00146 public int getBirMinIntRange() {
00147 return birMinIntRange;
00148 }
00149
00150
00151
00152
00153 public java.lang.String getClasspath() {
00154 return classpath;
00155 }
00156
00157
00158
00159
00160 public java.lang.String getDescription() {
00161 return description;
00162 }
00163
00164
00165
00166
00167 public java.lang.String getDspinOptions() {
00168 return dspinOptions;
00169 }
00170
00171
00172
00173
00174 public java.lang.String getFilename() {
00175 return filename;
00176 }
00177
00178
00179
00180
00181 public java.lang.String[] getIncludedPackagesOrTypes() {
00182 return includedPackagesOrTypes;
00183 }
00184
00185
00186
00187
00188 public String getInfo() {
00189 StringBuffer buffer = new StringBuffer();
00190 buffer.append("Session name: " + name + "\n\n");
00191 buffer.append("Description: " + description + "\n\n");
00192 buffer.append("Java main source code: " + (filename == null ? "none" : filename) + "\n");
00193 buffer.append("Classpath: " + classpath + "\n");
00194 buffer.append("Included package or type: ");
00195 buffer.append((includedPackagesOrTypes.length == 0) ? "none\n" : "\n");
00196 for (int i = 0; i < includedPackagesOrTypes.length; i++) {
00197 buffer.append(" - " + includedPackagesOrTypes[i] + "\n");
00198 }
00199 buffer.append("Enabled components: ");
00200 String text = doSlicer ? "Slicer, " : "";
00201 text = doSLABS ? text + "SLABS, " : text;
00202 text = doChecker ? text + "Checker, " : text;
00203 if ("".equals(text)) {
00204 buffer.append("none\n");
00205 } else {
00206 buffer.append(text.substring(0, text.length() - 2) + "\n");
00207 }
00208 buffer.append("Specification file: " + (specFilename == null ? "none" : specFilename) + "\n");
00209 buffer.append("Temporal property specification: " + (activeTemporal == null ? "none" : activeTemporal) + "\n");
00210 if (activeAssertions.size() == 0) {
00211 buffer.append("Assertion property specification: none\n");
00212 } else {
00213 Iterator i = activeAssertions.iterator();
00214 buffer.append("Assertion property specification: " + i.next());
00215 while (i.hasNext()) {
00216 buffer.append("," + i.next());
00217 }
00218 buffer.append("\n");
00219 }
00220 buffer.append("Abstraction file: " + (absFilename == null ? "none" : absFilename) +"\n");
00221 buffer.append("\nOutput name: " + outputName + "\n");
00222 buffer.append("\nWorking directory: " + workingDirectory + "\n");
00223 return buffer.toString();
00224 }
00225
00226
00227
00228
00229 public java.lang.String getJpfOptions() {
00230 return jpfOptions;
00231 }
00232
00233
00234
00235
00236 public java.lang.String getName() {
00237 return name;
00238 }
00239
00240
00241
00242
00243 public java.lang.String getOutputName() {
00244 return outputName;
00245 }
00246
00247
00248
00249
00250
00251 private String getPath(String filename) {
00252 boolean f = false;
00253 try {
00254 File f1 = new File(filename).getParentFile();
00255 File f2 = new File(".".equals(workingDirectory) ? System.getProperty("user.dir") : workingDirectory);
00256 f = f1.getCanonicalPath().equals(f2.getCanonicalPath());
00257 } catch (Exception e) {
00258 }
00259 if (f)
00260 return Util.encodeString(new File(filename).getName());
00261 else
00262 return Util.encodeString(filename == null ? "" : filename);
00263 }
00264
00265
00266
00267
00268 public java.lang.String getSmvOptions() {
00269 return smvOptions;
00270 }
00271
00272
00273
00274
00275 public java.lang.String getSpecFilename() {
00276 return specFilename;
00277 }
00278
00279
00280
00281
00282 public java.lang.String getSpinOptions() {
00283 return spinOptions;
00284 }
00285
00286
00287
00288
00289 public String getStringRepresentation() {
00290 String line = System.getProperty("line.separator");
00291 StringBuffer buffer = new StringBuffer("session " + name + " {" + line);
00292 buffer.append(" source = \"" + getPath(filename) + "\"" + line);
00293 buffer.append(" classpath = \"" + Util.encodeString(classpath.replace(File.pathSeparatorChar, '+')) + "\"" + line);
00294 buffer.append(" included = \"");
00295 int length = includedPackagesOrTypes.length;
00296 for (int i = 0; i < length - 1; i++) {
00297 buffer.append(Util.encodeString(includedPackagesOrTypes[i]) + "+");
00298 }
00299 if (length > 0)
00300 buffer.append(Util.encodeString(includedPackagesOrTypes[length - 1]));
00301 buffer.append("\"" + line);
00302 buffer.append(" output = \"" + Util.encodeString(outputName) + "\"" + line);
00303 buffer.append(" directory = \"" + Util.encodeString(workingDirectory) + "\"" + line);
00304 buffer.append(" description = \"" + Util.encodeString(description) + "\"" + line);
00305 buffer.append(" components = \"");
00306 String text = doSlicer ? "Slicer+" : "";
00307 text = doSLABS ? text + "SLABS+" : text;
00308 text = doChecker ? text + "Checker+" : text;
00309 if ("".equals(text)) {
00310 buffer.append("\"" + line);
00311 } else {
00312 buffer.append(text.substring(0, text.length() - 1) + "\"" + line);
00313 }
00314 buffer.append(" specification = \"" + getPath(specFilename) + "\"" + line);
00315 buffer.append(" temporal = \"" + ((activeTemporal == null) ? "" : activeTemporal) + "\"" + line);
00316 if (activeAssertions.size() == 0) {
00317 buffer.append(" assertion = \"\"" + line);
00318 } else {
00319 Iterator i = activeAssertions.iterator();
00320 buffer.append(" assertion = \"" + i.next());
00321 while (i.hasNext()) {
00322 buffer.append("+" + i.next());
00323 }
00324 buffer.append("\"" + line);
00325 }
00326
00327 buffer.append(" abstraction = \"" + getPath(absFilename) + "\"" + line);
00328
00329 buffer.append(" birc = \"" + ((bircOption == null) ? "" : bircOption) + "\"" + line);
00330 if (useSPIN) {
00331 buffer.append(" spin = \"" + spinOptions + "\"" + line);
00332 }
00333 if (useJPF) {
00334 buffer.append(" jpf = \"" + jpfOptions + "\"" + line);
00335 }
00336 if (useDSPIN) {
00337 buffer.append(" dspin = \"" + dspinOptions + "\"" + line);
00338 }
00339 if (useSMV) {
00340 buffer.append(" smv = \"" + smvOptions + "\"" + line);
00341 }
00342 for (Enumeration e = resources.keys(); e.hasMoreElements();) {
00343 String key = (String) e.nextElement();
00344 String value = (String) resources.get(key);
00345 buffer.append(" " + key + " = \"" + Util.encodeString(value) + "\"" + line);
00346 }
00347 buffer.append("}" + line);
00348 return buffer.toString();
00349 }
00350
00351
00352
00353
00354 public java.lang.String getWorkingDirectory() {
00355 return workingDirectory;
00356 }
00357
00358
00359
00360
00361 public boolean isDoChecker() {
00362 return doChecker;
00363 }
00364
00365
00366
00367
00368 public boolean isDoSLABS() {
00369 return doSLABS;
00370 }
00371
00372
00373
00374
00375 public boolean isDoSlicer() {
00376 return doSlicer;
00377 }
00378
00379
00380
00381
00382 public boolean isUseDSPIN() {
00383 return useDSPIN;
00384 }
00385
00386
00387
00388
00389 public boolean isUseJPF() {
00390 return useJPF;
00391 }
00392
00393
00394
00395
00396 public boolean isUseSMV() {
00397 return useSMV;
00398 }
00399
00400
00401
00402
00403 public boolean isUseSPIN() {
00404 return useSPIN;
00405 }
00406
00407
00408
00409
00410
00411 public void putResource(String key, String value) {
00412 resources.put(key, value);
00413 }
00414
00415
00416
00417
00418 public void removeActiveAssertion(String name) {
00419 activeAssertions.remove(name);
00420 }
00421
00422
00423
00424 public void saveOptions() {
00425 spinOptions = BUI.bui.spinOption.spinOptions.compileOptions()
00426 + "+" + BUI.bui.spinOption.spinOptions.panOptions();
00427 jpfOptions = JPFOption.getOptions();
00428 if (BUI.typeGUI.getFile() != null) {
00429 absFilename = BUI.typeGUI.getFile().getAbsolutePath();
00430 }
00431 }
00432
00433
00434
00435
00436 public void setAbsFilename(java.lang.String newAbsFilename) {
00437 absFilename = newAbsFilename;
00438 }
00439
00440
00441
00442
00443 public void setActiveAssertions(java.util.HashSet newActiveAssertions) {
00444 activeAssertions = newActiveAssertions;
00445 }
00446
00447
00448
00449
00450 public void setActiveTemporal(java.lang.String newActiveTemporal) {
00451 activeTemporal = newActiveTemporal;
00452 }
00453
00454
00455
00456
00457 public void setBIRCOption(java.lang.String newBircOption) {
00458 bircOption = newBircOption;
00459 }
00460
00461
00462
00463
00464 public void setBirMaxArrayLen(int newBirMaxArrayLen) {
00465 birMaxArrayLen = newBirMaxArrayLen;
00466 }
00467
00468
00469
00470
00471 public void setBirMaxInstances(int newBirMaxInstances) {
00472 birMaxInstances = newBirMaxInstances;
00473 }
00474
00475
00476
00477
00478 public void setBirMaxIntRange(int newBirMaxIntRange) {
00479 birMaxIntRange = newBirMaxIntRange;
00480 }
00481
00482
00483
00484
00485 public void setBirMinIntRange(int newBirMinIntRange) {
00486 birMinIntRange = newBirMinIntRange;
00487 }
00488
00489
00490
00491
00492 public void setClasspath(java.lang.String newClasspath) {
00493 classpath = newClasspath;
00494 }
00495
00496
00497
00498
00499 public void setDescription(java.lang.String newDescription) {
00500 description = newDescription;
00501 }
00502
00503
00504
00505
00506 public void setDoChecker(boolean newDoChecker) {
00507 doChecker = newDoChecker;
00508 }
00509
00510
00511
00512
00513 public void setDoSLABS(boolean newDoSLABS) {
00514 doSLABS = newDoSLABS;
00515 }
00516
00517
00518
00519
00520 public void setDoSlicer(boolean newDoSlicer) {
00521 doSlicer = newDoSlicer;
00522 }
00523
00524
00525
00526
00527 public void setDspinOptions(java.lang.String newDspinOptions) {
00528 dspinOptions = newDspinOptions;
00529 }
00530
00531
00532
00533
00534 public void setFilename(java.lang.String newFilename) {
00535 filename = newFilename;
00536 }
00537
00538
00539
00540
00541 public void setIncludedPackagesOrTypes(java.lang.String[] newIncludedPackagesOrTypes) {
00542 includedPackagesOrTypes = newIncludedPackagesOrTypes;
00543 }
00544
00545
00546
00547
00548 public void setJpfOptions(java.lang.String newJpfOptions) {
00549 jpfOptions = newJpfOptions;
00550 }
00551
00552
00553
00554
00555 public void setName(java.lang.String newName) {
00556 name = newName;
00557 }
00558
00559
00560
00561
00562 public void setOutputName(java.lang.String newOutputName) {
00563 outputName = newOutputName;
00564 }
00565
00566
00567
00568
00569 public void setSmvOptions(java.lang.String newSmvOptions) {
00570 smvOptions = newSmvOptions;
00571 }
00572
00573
00574
00575
00576 public void setSpecFilename(java.lang.String newSpecFilename) {
00577 specFilename = newSpecFilename;
00578 }
00579
00580
00581
00582
00583 public void setSpinOptions(java.lang.String newSpinOptions) {
00584 spinOptions = newSpinOptions;
00585 }
00586
00587
00588
00589
00590 public void setUseDSPIN(boolean newUseDSPIN) {
00591 useDSPIN = newUseDSPIN;
00592 }
00593
00594
00595
00596
00597 public void setUseJPF(boolean newUseJPF) {
00598 useJPF = newUseJPF;
00599 }
00600
00601
00602
00603
00604 public void setUseSMV(boolean newUseSMV) {
00605 useSMV = newUseSMV;
00606 }
00607
00608
00609
00610
00611 public void setUseSPIN(boolean newUseSPIN) {
00612 useSPIN = newUseSPIN;
00613 }
00614
00615
00616
00617
00618 public void setWorkingDirectory(java.lang.String newWorkingDirectory) {
00619 workingDirectory = newWorkingDirectory;
00620 }
00621
00622
00623
00624
00625 public String toString() {
00626 return name;
00627 }
00628 }