private List <SQLCondition> conditionList = new ArrayList <SQLCondition>(); @Override 
public SQLResult execute(Map <String, SQLParameter> params, Connection conn, 
Statement stmt) throws Exception { 
boolean isResult = true; for (SQLCondition condition : conditionList) { 
String type = condition.getType(); 
String param1 = condition.getParam1(); 
String param2 = condition.getParam2(); String param1Value = params.get(param1).getValue(); 
String param2Value = params.get(param2).getValue(); // Exception occur when cann't convert params to Double. 
try { 
          if (isResult) { 
if (type.equals(Constants.EQUALS)) { 
isResult &= param1Value.equals(param1Value); 
} else if (type.equals(Constants.MORE)) { 
    isResult &= Double.compare(Double.valueOf(param1Value), 
    Double.valueOf(param2Value)) > 0 ? true : false; 
} else if (type.equals(Constants.MOREOREQUALS)) { 
isResult &= Double.compare(Double.valueOf(param1Value), 
Double.valueOf(param2Value)) >= 0 ? true: false; 

} else { 
break; 

} catch (NumberFormatException e) { 
isResult = false; 

} SQLResult sqlResult = new SQLResult(); 
sqlResult.setResultType(SQLResult.RESULT_BOOLEAN); 
sqlResult.setResult(isResult); 
return sqlResult; 

解决方案 »

  1.   


    private List<SQLCondition> conditionList = new ArrayList<SQLCondition>(); @Override
    public SQLResult execute(Map<String, SQLParameter> params, Connection conn,
    Statement stmt) throws Exception {
    boolean isResult = true; for (SQLCondition condition : conditionList) {
    String type = condition.getType();
    String param1 = condition.getParam1();
    String param2 = condition.getParam2(); String param1Value = params.get(param1).getValue();
    String param2Value = params.get(param2).getValue(); // Exception occur when cann't convert params to Double.
    try {
    if (isResult) {
    if (type.equals(Constants.EQUALS)) {
    isResult &= param1Value.equals(param1Value);
    } else if (type.equals(Constants.MORE)) {
    isResult &= Double.compare(Double.valueOf(param1Value),
    Double.valueOf(param2Value)) > 0 ? true : false;
    } else if (type.equals(Constants.MOREOREQUALS)) {
    isResult &= Double.compare(Double.valueOf(param1Value),
    Double.valueOf(param2Value)) >= 0 ? true
    : false;
    }
    } else {
    break;
    }
    } catch (NumberFormatException e) {
    isResult = false;
    }
    } SQLResult sqlResult = new SQLResult();
    sqlResult.setResultType(SQLResult.RESULT_BOOLEAN);
    sqlResult.setResult(isResult);
    return sqlResult;
    }
    帮忙整理一下.