public boolean evaluate(StringBuffer reasoning) { double realVal = warehouse.getExternalAttribute(colName); return test(realVal, val, reasoning); }
protected Expression findMathOp(String source) { int opIndex = 1, locIndex = -1; Expression exp = null; // Need to make sure that the finding one op doesn't obscure another, // i.e. finding = but missing <=. while (opIndex < 7) { locIndex = source.indexOf(ops[opIndex]); if (locIndex >= 0) { if (opIndex == 1 || opIndex == 3 || opIndex == 4) { if (source.contains("<=") || source.contains(">=")) { opIndex++; continue; } else { break; } } else { break; } } opIndex++; } if (locIndex != -1) { // Check out right side. If string, then create CompareExpression. If // number, ValueExpression String rightSide = source.substring(locIndex + ops[opIndex].length()); String leftSide = null; if (locIndex > 0) { leftSide = source.substring(0, locIndex); } if (logger.isLoggable(Level.FINER)) { logger.finer( "got left side: " + leftSide + " op: " + ops[opIndex] + " and right side: " + rightSide); } /** * So here, We need to make a determination of whether the the left side is a column name from * the data, as specified in the FCI, or if it's a ECDIS check. If the right side is a * numerical value, we're just looking to test attribute data against hard numbers. We're * going to push this decision into the ValueExpression, let it figure out what it should do. */ try { Double val = Double.parseDouble(rightSide); /** * We need to check the length of this String to see if it's 4, which means it's an ECDIS * variable, set by the user. On the left side it's just a straight number value comparison * that will be provided for the right side. */ if (leftSide != null && leftSide.length() == 4) { exp = new ECDISExpression(leftSide, val, opIndex, warehouse); } else { exp = new ValueExpression(leftSide, val, opIndex); } } catch (NumberFormatException nfe) { /** * This expression gets set up here for when a table value is compared against an ECDIS * value. * * <p>Turns out, there's never a need for the ColumnExpression because any time right side * is text, it's actually referring to the value of the ECDIS External Attribute Name, which * can be looked up and set as a variable. * * <p>exp = new ColumnExpression(leftSide, rightSide, opIndex); */ // TODO Need to handle UNK and NULL! double val = warehouse.getExternalAttribute(rightSide); if (val < 0) { // try to handle some string arguments if (rightSide.equalsIgnoreCase("NULL")) { exp = new StringExpression(leftSide, null, opIndex); } else { exp = new StringExpression(leftSide, rightSide, opIndex); } } else { exp = new ValueExpression(leftSide, val, opIndex); } } } return exp; }