001 // A dummy invariant used for testing purposes
002
003 package daikon.test.diff;
004
005 import daikon.*;
006 import daikon.inv.*;
007
008 /**
009 * A dummy invariant used for testing purposes.
010 **/
011 public class DiffDummyInvariant
012 extends Invariant
013 {
014 // We are Serializable, so we specify a version to allow changes to
015 // method signatures without breaking serialization. If you add or
016 // remove fields, you should change this number to the current date.
017 static final long serialVersionUID = 20020122L;
018
019 public String formula;
020 public double confidence;
021 public boolean interesting;
022 public boolean isWorthPrinting;
023
024 public DiffDummyInvariant(PptSlice ppt, String formula, boolean justified) {
025 this(ppt, formula, justified, true, true);
026 }
027
028 public DiffDummyInvariant(PptSlice ppt, String formula,
029 boolean justified, boolean interesting) {
030 this(ppt, formula, justified, interesting, true);
031 }
032
033 public DiffDummyInvariant(PptSlice ppt, String formula,
034 boolean justified, boolean interesting,
035 boolean isWorthPrinting) {
036 this(ppt, formula, (justified ? Invariant.CONFIDENCE_JUSTIFIED : Invariant.CONFIDENCE_UNJUSTIFIED), interesting, isWorthPrinting);
037 }
038
039 public DiffDummyInvariant(PptSlice ppt, String formula, double confidence) {
040 this(ppt, formula, confidence, true, true);
041 }
042
043 public DiffDummyInvariant(PptSlice ppt, String formula,
044 double confidence, boolean interesting) {
045 this(ppt, formula, confidence, interesting, true);
046 }
047
048 public DiffDummyInvariant(PptSlice ppt, String formula,
049 double confidence, boolean interesting,
050 boolean isWorthPrinting) {
051 super(ppt);
052 this.formula = formula;
053 this.confidence = confidence;
054 this.interesting = interesting;
055 this.isWorthPrinting = isWorthPrinting;
056 }
057
058 protected Invariant resurrect_done(int[] permutation) {
059 throw new UnsupportedOperationException();
060 }
061
062 public boolean isInteresting() {
063 return interesting;
064 }
065
066 public boolean isSameInvariant(Invariant other) {
067 return this.isSameFormula(other);
068 }
069
070 public boolean isSameFormula(Invariant other) {
071 if (other instanceof DiffDummyInvariant) {
072 DiffDummyInvariant o = (DiffDummyInvariant) other;
073 return this.formula.equals(o.formula);
074 } else {
075 return false;
076 }
077 }
078
079 public double computeConfidence() {
080 return confidence;
081 }
082
083 public String repr() {
084 return "DiffDummyInvariant(" + ppt.arity() + "," + formula + "," + confidence + ")";
085 }
086
087 public String format_using(OutputFormat format) {
088 return repr();
089 }
090
091 // IsWorthPrinting should not be overridden by subclasses.
092 // But this subclass is special: it's not really an invariant,
093 // but is only used for testing.
094 public boolean isWorthPrinting() {
095 return isWorthPrinting;
096 }
097
098 }