00001 package edu.ksu.cis.bandera.specification.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 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
00060
00061 public TemporalLogicProperty(String name) {
00062 this.name = name;
00063 }
00064
00065
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
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
00089
00090 public Vector getExceptions() {
00091 return exceptions;
00092 }
00093
00094
00095
00096
00097 public java.lang.String getName() {
00098 return name;
00099 }
00100
00101
00102
00103
00104 public edu.ksu.cis.bandera.specification.node.Node getNode() {
00105 return node;
00106 }
00107
00108
00109
00110
00111 public java.lang.String getPatternName() {
00112 return patternName;
00113 }
00114
00115
00116
00117
00118 public java.lang.String getPatternScope() {
00119 return patternScope;
00120 }
00121
00122
00123
00124
00125 public Hashtable getPredicateQuantifierTable() {
00126 return pqTable;
00127 }
00128
00129
00130
00131
00132 public Hashtable getPredicatesTable() {
00133 return tlPredicates;
00134 }
00135
00136
00137
00138
00139
00140 public String getProposition(String propName) {
00141 return (String) propTable.get(propName);
00142 }
00143
00144
00145
00146
00147 public java.util.Vector getQuantifiedVariables() {
00148 return quantifiedVariables;
00149 }
00150
00151
00152
00153
00154 public java.lang.String getQuantifier() {
00155 return quantifier;
00156 }
00157
00158
00159
00160
00161 public Hashtable getQuantifiersTable() {
00162 return tlQuantifiers;
00163 }
00164
00165
00166
00167
00168 public String getStringRepresentation() {
00169 return name + ": " + expand();
00170 }
00171
00172
00173
00174
00175
00176 public void putProposition(String propName, String exp) {
00177 propTable.put(propName, exp);
00178 }
00179
00180
00181
00182
00183 public void setName(java.lang.String newName) {
00184 name = newName;
00185 }
00186
00187
00188
00189
00190 public void setNode(edu.ksu.cis.bandera.specification.node.Node newNode) {
00191 node = newNode;
00192 }
00193
00194
00195
00196
00197 public void setPatternName(java.lang.String newPatternName) {
00198 patternName = newPatternName;
00199 }
00200
00201
00202
00203
00204 public void setPatternScope(java.lang.String newPatternScope) {
00205 patternScope = newPatternScope;
00206 }
00207
00208
00209
00210
00211 public void setQuantifier(java.lang.String newQuantifier) {
00212 quantifier = newQuantifier;
00213 }
00214
00215
00216
00217
00218
00219
00220
00221
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 }