Main Page   Packages   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

Session.java

00001 package edu.ksu.cis.bandera.bui.session.datastructure;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 2000   Robby (robby@cis.ksu.edu)                    *
00006  * All rights reserved.                                              *
00007  *                                                                   *
00008  * This work was done as a project in the SAnToS Laboratory,         *
00009  * Department of Computing and Information Sciences, Kansas State    *
00010  * University, USA (http://www.cis.ksu.edu/santos).                  *
00011  * It is understood that any modification not identified as such is  *
00012  * not covered by the preceding statement.                           *
00013  *                                                                   *
00014  * This work is free software; you can redistribute it and/or        *
00015  * modify it under the terms of the GNU Library General Public       *
00016  * License as published by the Free Software Foundation; either      *
00017  * version 2 of the License, or (at your option) any later version.  *
00018  *                                                                   *
00019  * This work is distributed in the hope that it will be useful,      *
00020  * but WITHOUT ANY WARRANTY; without even the implied warranty of    *
00021  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *
00022  * Library General Public License for more details.                  *
00023  *                                                                   *
00024  * You should have received a copy of the GNU Library General Public *
00025  * License along with this toolkit; if not, write to the             *
00026  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,      *
00027  * Boston, MA  02111-1307, USA.                                      *
00028  *                                                                   *
00029  * Java is a trademark of Sun Microsystems, Inc.                     *
00030  *                                                                   *
00031  * To submit a bug report, send a comment, or get the latest news on *
00032  * this project and other SAnToS projects, please visit the web-site *
00033  *                http://www.cis.ksu.edu/santos                      *
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  * @param name java.lang.String
00074  */
00075 public Session(String name) {
00076     setName(name);
00077 }
00078 /**
00079  * 
00080  * @param name java.lang.String
00081  */
00082 public void addActiveAssertion(String name) {
00083     activeAssertions.add(name);
00084 }
00085 /**
00086  * 
00087  * @return int
00088  * @param object java.lang.Object
00089  */
00090 public int compareTo(Object object) {
00091     return name.compareTo(((Session) object).getName());
00092 }
00093 /**
00094  * 
00095  * @return java.lang.String
00096  */
00097 public java.lang.String getAbsFilename() {
00098     return absFilename;
00099 }
00100 /**
00101  * 
00102  * @return java.util.HashSet
00103  */
00104 public java.util.HashSet getActiveAssertions() {
00105     return activeAssertions;
00106 }
00107 /**
00108  * 
00109  * @return java.lang.String
00110  */
00111 public java.lang.String getActiveTemporal() {
00112     return activeTemporal;
00113 }
00114 /**
00115  * 
00116  * @return java.lang.String
00117  */
00118 public java.lang.String getBIRCOption() {
00119     return bircOption;
00120 }
00121 /**
00122  * 
00123  * @return int
00124  */
00125 public int getBirMaxArrayLen() {
00126     return birMaxArrayLen;
00127 }
00128 /**
00129  * 
00130  * @return int
00131  */
00132 public int getBirMaxInstances() {
00133     return birMaxInstances;
00134 }
00135 /**
00136  * 
00137  * @return int
00138  */
00139 public int getBirMaxIntRange() {
00140     return birMaxIntRange;
00141 }
00142 /**
00143  * 
00144  * @return int
00145  */
00146 public int getBirMinIntRange() {
00147     return birMinIntRange;
00148 }
00149 /**
00150  * 
00151  * @return java.lang.String
00152  */
00153 public java.lang.String getClasspath() {
00154     return classpath;
00155 }
00156 /**
00157  * 
00158  * @return java.lang.String
00159  */
00160 public java.lang.String getDescription() {
00161     return description;
00162 }
00163 /**
00164  * 
00165  * @return java.lang.String
00166  */
00167 public java.lang.String getDspinOptions() {
00168     return dspinOptions;
00169 }
00170 /**
00171  * 
00172  * @return java.lang.String
00173  */
00174 public java.lang.String getFilename() {
00175     return filename;
00176 }
00177 /**
00178  * 
00179  * @return java.lang.String[]
00180  */
00181 public java.lang.String[] getIncludedPackagesOrTypes() {
00182     return includedPackagesOrTypes;
00183 }
00184 /**
00185  * 
00186  * @return java.lang.String
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  * @return java.lang.String
00228  */
00229 public java.lang.String getJpfOptions() {
00230     return jpfOptions;
00231 }
00232 /**
00233  * 
00234  * @return java.lang.String
00235  */
00236 public java.lang.String getName() {
00237     return name;
00238 }
00239 /**
00240  * 
00241  * @return java.lang.String
00242  */
00243 public java.lang.String getOutputName() {
00244     return outputName;
00245 }
00246 /**
00247  * 
00248  * @return java.lang.String
00249  * @param filename java.lang.String
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  * @return java.lang.String
00267  */
00268 public java.lang.String getSmvOptions() {
00269     return smvOptions;
00270 }
00271 /**
00272  * 
00273  * @return java.lang.String
00274  */
00275 public java.lang.String getSpecFilename() {
00276     return specFilename;
00277 }
00278 /**
00279  * 
00280  * @return java.lang.String
00281  */
00282 public java.lang.String getSpinOptions() {
00283     return spinOptions;
00284 }
00285 /**
00286  * 
00287  * @return java.lang.String
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   //saveOptions();
00327     buffer.append("  abstraction = \"" + getPath(absFilename) + "\"" + line);
00328     //buffer.append("  slabs = \"" + ((abpsOption == null) ? "" : abpsOption) + "\"" + line);
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  * @return java.lang.String
00353  */
00354 public java.lang.String getWorkingDirectory() {
00355     return workingDirectory;
00356 }
00357 /**
00358  * 
00359  * @return boolean
00360  */
00361 public boolean isDoChecker() {
00362     return doChecker;
00363 }
00364 /**
00365  * 
00366  * @return boolean
00367  */
00368 public boolean isDoSLABS() {
00369     return doSLABS;
00370 }
00371 /**
00372  * 
00373  * @return boolean
00374  */
00375 public boolean isDoSlicer() {
00376     return doSlicer;
00377 }
00378 /**
00379  * 
00380  * @return boolean
00381  */
00382 public boolean isUseDSPIN() {
00383     return useDSPIN;
00384 }
00385 /**
00386  * 
00387  * @return boolean
00388  */
00389 public boolean isUseJPF() {
00390     return useJPF;
00391 }
00392 /**
00393  * 
00394  * @return boolean
00395  */
00396 public boolean isUseSMV() {
00397     return useSMV;
00398 }
00399 /**
00400  * 
00401  * @return boolean
00402  */
00403 public boolean isUseSPIN() {
00404     return useSPIN;
00405 }
00406 /**
00407  * 
00408  * @param key java.lang.String
00409  * @param value java.lang.String
00410  */
00411 public void putResource(String key, String value) {
00412     resources.put(key, value);
00413 }
00414 /**
00415  * 
00416  * @param name java.lang.String
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  * @param newAbsFilename java.lang.String
00435  */
00436 public void setAbsFilename(java.lang.String newAbsFilename) {
00437     absFilename = newAbsFilename;
00438 }
00439 /**
00440  * 
00441  * @param newActiveAssertions java.util.HashSet
00442  */
00443 public void setActiveAssertions(java.util.HashSet newActiveAssertions) {
00444     activeAssertions = newActiveAssertions;
00445 }
00446 /**
00447  * 
00448  * @param newActiveTemporal java.lang.String
00449  */
00450 public void setActiveTemporal(java.lang.String newActiveTemporal) {
00451     activeTemporal = newActiveTemporal;
00452 }
00453 /**
00454  * 
00455  * @param newBircOption java.lang.String
00456  */
00457 public void setBIRCOption(java.lang.String newBircOption) {
00458     bircOption = newBircOption;
00459 }
00460 /**
00461  * 
00462  * @param newBirMaxArrayLen int
00463  */
00464 public void setBirMaxArrayLen(int newBirMaxArrayLen) {
00465     birMaxArrayLen = newBirMaxArrayLen;
00466 }
00467 /**
00468  * 
00469  * @param newBirMaxInstances int
00470  */
00471 public void setBirMaxInstances(int newBirMaxInstances) {
00472     birMaxInstances = newBirMaxInstances;
00473 }
00474 /**
00475  * 
00476  * @param newBirMaxIntRange int
00477  */
00478 public void setBirMaxIntRange(int newBirMaxIntRange) {
00479     birMaxIntRange = newBirMaxIntRange;
00480 }
00481 /**
00482  * 
00483  * @param newBirMinIntRange int
00484  */
00485 public void setBirMinIntRange(int newBirMinIntRange) {
00486     birMinIntRange = newBirMinIntRange;
00487 }
00488 /**
00489  * 
00490  * @param newClasspath java.lang.String
00491  */
00492 public void setClasspath(java.lang.String newClasspath) {
00493     classpath = newClasspath;
00494 }
00495 /**
00496  * 
00497  * @param newDescription java.lang.String
00498  */
00499 public void setDescription(java.lang.String newDescription) {
00500     description = newDescription;
00501 }
00502 /**
00503  * 
00504  * @param newDoChecker boolean
00505  */
00506 public void setDoChecker(boolean newDoChecker) {
00507     doChecker = newDoChecker;
00508 }
00509 /**
00510  * 
00511  * @param newDoBABS boolean
00512  */
00513 public void setDoSLABS(boolean newDoSLABS) {
00514     doSLABS = newDoSLABS;
00515 }
00516 /**
00517  * 
00518  * @param newDoSlicer boolean
00519  */
00520 public void setDoSlicer(boolean newDoSlicer) {
00521     doSlicer = newDoSlicer;
00522 }
00523 /**
00524  * 
00525  * @param newDspinOptions java.lang.String
00526  */
00527 public void setDspinOptions(java.lang.String newDspinOptions) {
00528     dspinOptions = newDspinOptions;
00529 }
00530 /**
00531  * 
00532  * @param newFilename java.lang.String
00533  */
00534 public void setFilename(java.lang.String newFilename) {
00535     filename = newFilename;
00536 }
00537 /**
00538  * 
00539  * @param newIncludedPackagesOrTypes java.lang.String[]
00540  */
00541 public void setIncludedPackagesOrTypes(java.lang.String[] newIncludedPackagesOrTypes) {
00542     includedPackagesOrTypes = newIncludedPackagesOrTypes;
00543 }
00544 /**
00545  * 
00546  * @param newJpfOptions java.lang.String
00547  */
00548 public void setJpfOptions(java.lang.String newJpfOptions) {
00549     jpfOptions = newJpfOptions;
00550 }
00551 /**
00552  * 
00553  * @param newName java.lang.String
00554  */
00555 public void setName(java.lang.String newName) {
00556     name = newName;
00557 }
00558 /**
00559  * 
00560  * @param newOutputName java.lang.String
00561  */
00562 public void setOutputName(java.lang.String newOutputName) {
00563     outputName = newOutputName;
00564 }
00565 /**
00566  * 
00567  * @param newSmvOptions java.lang.String
00568  */
00569 public void setSmvOptions(java.lang.String newSmvOptions) {
00570     smvOptions = newSmvOptions;
00571 }
00572 /**
00573  * 
00574  * @param newSpecFilename java.lang.String
00575  */
00576 public void setSpecFilename(java.lang.String newSpecFilename) {
00577     specFilename = newSpecFilename;
00578 }
00579 /**
00580  * 
00581  * @param newSpinOptions java.lang.String
00582  */
00583 public void setSpinOptions(java.lang.String newSpinOptions) {
00584     spinOptions = newSpinOptions;
00585 }
00586 /**
00587  * 
00588  * @param newUseDSPIN boolean
00589  */
00590 public void setUseDSPIN(boolean newUseDSPIN) {
00591     useDSPIN = newUseDSPIN;
00592 }
00593 /**
00594  * 
00595  * @param newUseJPF boolean
00596  */
00597 public void setUseJPF(boolean newUseJPF) {
00598     useJPF = newUseJPF;
00599 }
00600 /**
00601  * 
00602  * @param newUseSMV boolean
00603  */
00604 public void setUseSMV(boolean newUseSMV) {
00605     useSMV = newUseSMV;
00606 }
00607 /**
00608  * 
00609  * @param newUseSPIN boolean
00610  */
00611 public void setUseSPIN(boolean newUseSPIN) {
00612     useSPIN = newUseSPIN;
00613 }
00614 /**
00615  * 
00616  * @param newWorkingDirectory java.lang.String
00617  */
00618 public void setWorkingDirectory(java.lang.String newWorkingDirectory) {
00619     workingDirectory = newWorkingDirectory;
00620 }
00621 /**
00622  * 
00623  * @return java.lang.String
00624  */
00625 public String toString() {
00626     return name;
00627 }
00628 }

Generated at Thu Feb 7 06:54:33 2002 for Bandera by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001