Package sos.util.string2bool

Examples of sos.util.string2bool.SOSBooleanExpression


   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;
View Full Code Here

TOP

Related Classes of sos.util.string2bool.SOSBooleanExpression

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.