00001 package gov.nasa.arc.ase.jpf.expr;
00002
00003
00004 class And implements SubExpr {
00005 private int length;
00006 private SubExpr[] terms;
00007
00008 And(int l) {
00009 length = l;
00010 terms = new SubExpr[l];
00011 }
00012 public void backtrack() {
00013 throw new RuntimeException("Expression is not executable");
00014 }
00015 public boolean evaluate() {
00016 boolean result = true;
00017
00018 for(int i = 0; result && i < length; i++)
00019 result &= terms[i].evaluate();
00020
00021 return result;
00022 }
00023 public void execute() {
00024 throw new RuntimeException("Expression is not executable");
00025 }
00026 void set(int index, SubExpr t) {
00027 terms[index] = t;
00028 }
00029 public String toString() {
00030 StringBuffer sb = new StringBuffer();
00031
00032 for(int i = 0; i < length; i++) {
00033 if(i != 0) sb.append(" & ");
00034 sb.append(terms[i]);
00035 }
00036
00037 return sb.toString();
00038 }
00039 }