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

BSLReport.java

00001 package edu.ksu.cis.bandera.report;
00002 
00003 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
00004  * Bandera, a Java(TM) analysis and transformation toolkit           *
00005  * Copyright (C) 2001   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 ca.mcgill.sable.soot.jimple.*;
00038 import edu.ksu.cis.bandera.specification.assertion.datastructure.*;
00039 import edu.ksu.cis.bandera.specification.predicate.datastructure.*;
00040 
00041 public class BSLReport implements Report {
00042     private static String filename = "bsl.report";
00043 
00044     private TreeSet predicates = new TreeSet();
00045     private TreeSet assertions = new TreeSet();
00046     private TreeSet compiledPredicates = new TreeSet();
00047     private Hashtable compiledTable = new Hashtable();
00048     //private Hashtable ltlPredicateTable = new Hashtable();
00049     //private TreeSet ltlPredicates = new TreeSet();
00050 
00051     //private String ltl = "???";
00052 /**
00053  * 
00054  */
00055 public void addAssertionsAndPredicates() {
00056     for (Enumeration e = AssertionSet.getAssertionSetTable().elements(); e.hasMoreElements();) {
00057         for (Enumeration e2 = ((AssertionSet) e.nextElement()).getAssertionTable().elements(); e2.hasMoreElements();) {
00058             assertions.add((Assertion) e2.nextElement());
00059         }
00060     }
00061     for (Enumeration e = PredicateSet.getPredicateSetTable().elements(); e.hasMoreElements();) {
00062         for (Enumeration e2 = ((PredicateSet) e.nextElement()).getPredicateTable().elements(); e2.hasMoreElements();) {
00063             predicates.add((Predicate) e2.nextElement());
00064         }
00065     }
00066 }
00067 /**
00068  * 
00069  * @param p edu.ksu.cis.bandera.specification.predicate.datastructure.Predicate
00070  * @param v ca.mcgill.sable.soot.jimple.Value
00071  */
00072 public void addCompiledPredicate(Predicate p, Value v) {
00073     compiledPredicates.add(p);
00074     compiledTable.put(p, v);
00075 }
00076 /**
00077  * 
00078  * @return java.lang.String
00079  */
00080 public String getFilename() {
00081     return filename;
00082 }
00083 /**
00084  * getTextRepresentation method comment.
00085  */
00086 public String getTextRepresentation() {
00087     StringWriter sw = new StringWriter();
00088     PrintWriter pw = new PrintWriter(sw);
00089 
00090     pw.println("BSL Report");
00091     pw.println("==========");
00092     pw.println("");
00093     pw.println("");
00094     pw.println("");
00095 
00096     pw.println("Assertions");
00097     pw.println("----------");
00098 
00099     for (Iterator i = assertions.iterator(); i.hasNext();) {
00100         Assertion a = (Assertion) i.next();
00101         Vector exceptions = a.getExceptions();
00102         if (exceptions.size() > 0) {
00103             pw.println("* " + a.getName() + " didn't pass type checking");
00104             pw.println("  + constraint: " + a.getConstraint());
00105             pw.println("  + description: " + a.getDescription());
00106             pw.println("  + annotation: " + a.getAnnotation());
00107             pw.println("  + type checking message(s):");
00108             for (Iterator j = exceptions.iterator(); j.hasNext();) {
00109                 pw.println("    - " + ((Exception) exceptions.iterator()).getMessage());
00110             }
00111         } else {
00112             pw.println("* " + a.getName() + " passed type checking");
00113             pw.println("  + constraint: " + a.getConstraint());
00114             pw.println("  + description: " + a.getDescription());
00115             pw.println("  + annotation: " + a.getAnnotation());
00116         }
00117     }
00118     
00119     pw.println("");
00120     pw.println("");
00121 
00122     pw.println("Predicates");
00123     pw.println("----------");
00124 
00125     for (Iterator i = predicates.iterator(); i.hasNext();) {
00126         Predicate p = (Predicate) i.next();
00127         Vector exceptions = p.getExceptions();
00128         if (exceptions.size() > 0) {
00129             pw.println("* " + p.getName() + " didn't pass type checking");
00130             pw.println("  + static: " + p.isStatic());
00131             pw.println("  + use private field: " + p.isUsePrivate());
00132             pw.println("  + parameters: " + p.getParams());
00133             pw.println("  + parameter types: " + p.getParamTypes());
00134             pw.println("  + constraint: " + p.getConstraint());
00135             pw.println("  + description: " + p.getDescription());
00136             pw.println("  + annotation: " + p.getAnnotation());
00137             pw.println("  + type checking message(s):");
00138             for (Iterator j = exceptions.iterator(); j.hasNext();) {
00139                 pw.println("    - " + ((Exception) j.next()).getMessage());
00140             }
00141         } else {
00142             pw.println("* " + p.getName() + " passed type checking");
00143             pw.println("  + static: " + p.isStatic());
00144             pw.println("  + use private field: " + p.isUsePrivate());
00145             pw.println("  + parameters: " + p.getParams());
00146             pw.println("  + parameter types: " + p.getParamTypes());
00147             pw.println("  + constraint: " + p.getConstraint());
00148             pw.println("  + description: " + p.getDescription());
00149             pw.println("  + annotation: " + p.getAnnotation());
00150         }
00151     }
00152 
00153     pw.println("");
00154     pw.println("");
00155 
00156     pw.println("Compiled Predicates");
00157     pw.println("-------------------");
00158 
00159     for (Iterator i = compiledPredicates.iterator(); i.hasNext();) {
00160         Predicate p = (Predicate) i.next();
00161         Value v = (Value) compiledTable.get(p);
00162         pw.println("* " + p.getName() + " = " + v);
00163     }
00164     
00165     pw.println("");
00166     pw.println("");
00167 /*
00168     pw.println("LTL Predicates");
00169     pw.println("---------------");
00170 
00171     for (Iterator i = ltlPredicates.iterator(); i.hasNext();) {
00172         String name = (String) i.next();
00173         Value v = (Value) ltlPredicateTable.get(name);
00174         pw.println("* " + name + " = " + v);
00175     }
00176 
00177     pw.println("");
00178     pw.println("");
00179 
00180     pw.println("LTL Never Claim");
00181     pw.println("---------------");
00182     pw.println(ltl);
00183 */  
00184     return sw.toString();
00185 }
00186 }

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