public void replace(String s1, String s2) {
boolExp = boolExp.replaceAll(s1, s2);
}
public boolean evaluateExpression () {
SOSBooleanExpression boolExpr = null;
HashMap allowedToken=new HashMap();
allowedToken.put("(","");
allowedToken.put(")","");
allowedToken.put("||","");
allowedToken.put("&&","");
allowedToken.put("!","");
allowedToken.put("!(","");
allowedToken.put(")!","");
allowedToken.put("(!)","");
allowedToken.put("true","");
allowedToken.put("false","");
allowedToken.put("(true","");
allowedToken.put("(false","");
allowedToken.put("(true)","");
allowedToken.put("(false)","");
allowedToken.put("true)","");
allowedToken.put("false)","");
try {
String normalizedBoolExpr = "";
StringTokenizer t = new StringTokenizer(boolExp," ");
while (t.hasMoreTokens()){
String s = t.nextToken();
if (allowedToken.get(s) != null) {
normalizedBoolExpr = normalizedBoolExpr + " " + s;
}else {
normalizedBoolExpr = normalizedBoolExpr + " false ";
}
}
if (normalizedBoolExpr.length() == 0) {
return true;
}else {
boolExpr = SOSBooleanExpression.readLeftToRight(normalizedBoolExpr);
return boolExpr.booleanValue();
}
} catch (SOSMalformedBooleanException e) {
System.out.println("--->"+boolExp);
e.printStackTrace();
return false;