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

TemporalLogicProperty.java

00001 package edu.ksu.cis.bandera.specification.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 edu.ksu.cis.bandera.specification.ast.*;
00036 import java.io.*;
00037 import edu.ksu.cis.bandera.specification.lexer.*;
00038 import edu.ksu.cis.bandera.specification.parser.*;
00039 import edu.ksu.cis.bandera.specification.node.*;
00040 import edu.ksu.cis.bandera.specification.pattern.*;
00041 import edu.ksu.cis.bandera.specification.pattern.datastructure.*;
00042 import java.util.*;
00043 
00044 public class TemporalLogicProperty implements Comparable {
00045     private String name;
00046     private String quantifier = "";
00047     private String patternName;
00048     private String patternScope;
00049     private Hashtable propTable = new Hashtable();
00050     private Vector exceptions = new Vector();
00051     private Hashtable tlPredicates;
00052     private Hashtable tlQuantifiers;
00053     private Hashtable pqTable;
00054     private Hashtable tlQuantifierConstraints;
00055     private Node node;
00056     private Vector quantifiedVariables;
00057 /**
00058  * 
00059  * @param name java.lang.String
00060  */
00061 public TemporalLogicProperty(String name) {
00062     this.name = name;
00063 }
00064 /**
00065  * compareTo method comment.
00066  */
00067 public int compareTo(Object o) {
00068     if (o instanceof TemporalLogicProperty) {
00069         return name.compareTo(((TemporalLogicProperty) o).name);
00070     } else {
00071         return -1;
00072     }
00073 }
00074 /**
00075  * 
00076  * @return java.lang.String
00077  */
00078 public String expand() {
00079     Pattern p = PatternSaverLoader.getPattern(patternName, patternScope);
00080     if (p == null) return null;
00081     
00082     StringBuffer buffer = new StringBuffer(quantifier);
00083     buffer.append(p.expandFormat(propTable) + ";");
00084     return buffer.toString();
00085 }
00086 /**
00087  * 
00088  * @return java.util.Vector
00089  */
00090 public Vector getExceptions() {
00091     return exceptions;
00092 }
00093 /**
00094  * 
00095  * @return java.lang.String
00096  */
00097 public java.lang.String getName() {
00098     return name;
00099 }
00100 /**
00101  * 
00102  * @return edu.ksu.cis.bandera.specification.node.Node
00103  */
00104 public edu.ksu.cis.bandera.specification.node.Node getNode() {
00105     return node;
00106 }
00107 /**
00108  * 
00109  * @return java.lang.String
00110  */
00111 public java.lang.String getPatternName() {
00112     return patternName;
00113 }
00114 /**
00115  * 
00116  * @return java.lang.String
00117  */
00118 public java.lang.String getPatternScope() {
00119     return patternScope;
00120 }
00121 /**
00122  * 
00123  * @return java.util.Hashtable
00124  */
00125 public Hashtable getPredicateQuantifierTable() {
00126     return pqTable;
00127 }
00128 /**
00129  * 
00130  * @return java.util.Hashtable
00131  */
00132 public Hashtable getPredicatesTable() {
00133     return tlPredicates;
00134 }
00135 /**
00136  * 
00137  * @return java.lang.String
00138  * @param propName java.lang.String
00139  */
00140 public String getProposition(String propName) {
00141     return (String) propTable.get(propName);
00142 }
00143 /**
00144  * 
00145  * @return java.util.Vector
00146  */
00147 public java.util.Vector getQuantifiedVariables() {
00148     return quantifiedVariables;
00149 }
00150 /**
00151  * 
00152  * @return java.lang.String
00153  */
00154 public java.lang.String getQuantifier() {
00155     return quantifier;
00156 }
00157 /**
00158  * 
00159  * @return java.util.Hashtable
00160  */
00161 public Hashtable getQuantifiersTable() {
00162     return tlQuantifiers;
00163 }
00164 /**
00165  * 
00166  * @return java.lang.String
00167  */
00168 public String getStringRepresentation() {
00169     return name + ": " + expand();
00170 }
00171 /**
00172  * 
00173  * @param propName java.lang.String
00174  * @param exp java.lang.String
00175  */
00176 public void putProposition(String propName, String exp) {
00177     propTable.put(propName, exp);
00178 }
00179 /**
00180  * 
00181  * @param newName java.lang.String
00182  */
00183 public void setName(java.lang.String newName) {
00184     name = newName;
00185 }
00186 /**
00187  * 
00188  * @param newNode edu.ksu.cis.bandera.specification.node.Node
00189  */
00190 public void setNode(edu.ksu.cis.bandera.specification.node.Node newNode) {
00191     node = newNode;
00192 }
00193 /**
00194  * 
00195  * @param newPatternName java.lang.String
00196  */
00197 public void setPatternName(java.lang.String newPatternName) {
00198     patternName = newPatternName;
00199 }
00200 /**
00201  * 
00202  * @param newPatternScope java.lang.String
00203  */
00204 public void setPatternScope(java.lang.String newPatternScope) {
00205     patternScope = newPatternScope;
00206 }
00207 /**
00208  * 
00209  * @param newQuantifier java.lang.String
00210  */
00211 public void setQuantifier(java.lang.String newQuantifier) {
00212     quantifier = newQuantifier;
00213 }
00214 /**
00215  * 
00216  * @param importedType java.util.Set
00217  * @param importedPackage java.util.Set
00218  * @param importedAssertion java.util.Set
00219  * @param importedAssertionSet java.util.Set
00220  * @param importedPredicate java.util.Set
00221  * @param importedPredicateSet java.util.Set
00222  */
00223 public void validate(Set importedType, Set importedPackage, Set importedAssertion, Set importedAssertionSet, Set importedPredicate, Set importedPredicateSet) {
00224     exceptions = new Vector();
00225     
00226     String text = name + ":" + expand();
00227     try {
00228         node = new Parser(new Lexer(new PushbackReader(new StringReader(text)))).parse();
00229         node.apply(new Simplifier());
00230         Checker checker = new Checker(importedType, importedPackage, importedAssertion, importedAssertionSet, importedPredicate, importedPredicateSet);
00231         node.apply(checker);
00232         exceptions.addAll(checker.getExceptions());
00233         tlPredicates = (Hashtable) checker.getTLPredicatesTable().get(name);
00234         tlQuantifiers = (Hashtable) checker.getTLQuantifiersTable().get(name);
00235         pqTable = checker.getPredicateQuantifierTable();
00236         quantifiedVariables = (Vector) checker.getTLQuantifiedVariables().get(name);
00237     } catch (Exception e) {
00238         exceptions.addElement(e);
00239     }
00240 }
00241 }

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