X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.spreadsheet.graph%2Fsrc%2Forg%2Fsimantics%2Fspreadsheet%2Fgraph%2FCellValueVisitor.java;h=0fa6ce0a599e65ec0132077c77d716502cd84c8a;hp=385af993847c9d2b44393cdbc92386c19c0c18aa;hb=55ca14c4198659b908aeffc8d16e240b35a75e66;hpb=25b6c25959c1fb3c60bb41cd0e1f0808e7fc3769 diff --git a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/CellValueVisitor.java b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/CellValueVisitor.java index 385af9938..0fa6ce0a5 100644 --- a/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/CellValueVisitor.java +++ b/bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/CellValueVisitor.java @@ -183,8 +183,7 @@ public class CellValueVisitor implements AstValueVisitor { if(rightVal==null) rightResult = rightTemp.toString(); else rightResult = rightVal; } - - if ((leftResult instanceof String) || (rightResult instanceof String)) { + if ((leftResult instanceof String) && (rightResult instanceof String)) { String leftString = (leftResult.toString()).toLowerCase(); String rightString = (rightResult.toString()).toLowerCase(); if("<".equals(astRelation.op.trim())) return leftString.compareTo(rightString) < 0; @@ -195,8 +194,9 @@ public class CellValueVisitor implements AstValueVisitor { else if(">=".equals(astRelation.op.trim())) return leftString.compareTo(rightString) >= 0 ; else throw new IllegalStateException(); } else { - Number leftNumber = SpreadsheetGraphUtils.asNumber(leftResult); - Number rightNumber = SpreadsheetGraphUtils.asNumber(rightResult); + Number leftNumber = SpreadsheetGraphUtils.asDoubleWhereEmptyStringIsZero(leftResult); + Number rightNumber = SpreadsheetGraphUtils.asDoubleWhereEmptyStringIsZero(rightResult); + if(leftNumber==null || rightNumber==null) return false; if("<".equals(astRelation.op.trim())) return leftNumber.doubleValue() < rightNumber.doubleValue(); else if(">".equals(astRelation.op.trim())) return leftNumber.doubleValue() > rightNumber.doubleValue(); else if("=".equals(astRelation.op.trim())) return leftNumber.doubleValue() == rightNumber.doubleValue();