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=022326248c39bacdf395e484f06de8220410893a;hp=385af993847c9d2b44393cdbc92386c19c0c18aa;hb=bb1507f2eaee879439d355bf6b052e16d0df1bff;hpb=12468c2b3d87f61123d6429a7329d80316009fe6 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..022326248 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 @@ -189,7 +189,8 @@ public class CellValueVisitor implements AstValueVisitor { String rightString = (rightResult.toString()).toLowerCase(); if("<".equals(astRelation.op.trim())) return leftString.compareTo(rightString) < 0; else if(">".equals(astRelation.op.trim())) return leftString.compareTo(rightString) > 0; - else if("=".equals(astRelation.op.trim())) return leftString.compareTo(rightString) == 0; + // empty string should equal zero (TODO: this is a hack, the proper fix should be somewhere earlier so other cases would work as well) + else if("=".equals(astRelation.op.trim())) return leftString.compareTo(rightString) == 0 || emptyAndZero(leftString, rightString) || emptyAndZero(rightString, leftString); else if("<>".equals(astRelation.op.trim())) return leftString.compareTo(rightString) != 0 ; else if("<=".equals(astRelation.op.trim())) return leftString.compareTo(rightString) <= 0 ; else if(">=".equals(astRelation.op.trim())) return leftString.compareTo(rightString) >= 0 ; @@ -207,6 +208,15 @@ public class CellValueVisitor implements AstValueVisitor { } } + private static boolean emptyAndZero(String a, String b) { + try { + return a.isEmpty() && (Double.parseDouble(b) == 0); + } + catch (NumberFormatException e) { + return false; + } + } + Object leftValueWithPrefix(Object result, AstValue value, String prefix, boolean forceNumber) { if(result == null) { Object obj = value.accept(this);