]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.spreadsheet.graph/src/org/simantics/spreadsheet/graph/CellValueVisitor.java
Sync git svn branch with SVN repository r33219.
[simantics/platform.git] / bundles / org.simantics.spreadsheet.graph / src / org / simantics / spreadsheet / graph / CellValueVisitor.java
index 385af993847c9d2b44393cdbc92386c19c0c18aa..022326248c39bacdf395e484f06de8220410893a 100644 (file)
@@ -189,7 +189,8 @@ public class CellValueVisitor implements AstValueVisitor<Object> {
                        String rightString = (rightResult.toString()).toLowerCase();\r
                        if("<".equals(astRelation.op.trim())) return leftString.compareTo(rightString) < 0;\r
                        else if(">".equals(astRelation.op.trim())) return leftString.compareTo(rightString) > 0;\r
-                       else if("=".equals(astRelation.op.trim())) return leftString.compareTo(rightString) == 0;\r
+                       // empty string should equal zero (TODO: this is a hack, the proper fix should be somewhere earlier so other cases would work as well)\r
+                       else if("=".equals(astRelation.op.trim())) return leftString.compareTo(rightString) == 0 || emptyAndZero(leftString, rightString) || emptyAndZero(rightString, leftString);\r
                        else if("<>".equals(astRelation.op.trim())) return leftString.compareTo(rightString) != 0 ;\r
                        else if("<=".equals(astRelation.op.trim())) return leftString.compareTo(rightString) <= 0 ;\r
                        else if(">=".equals(astRelation.op.trim())) return leftString.compareTo(rightString) >= 0 ;\r
@@ -207,6 +208,15 @@ public class CellValueVisitor implements AstValueVisitor<Object> {
                }\r
        }\r
        \r
+       private static boolean emptyAndZero(String a, String b) {\r
+           try {\r
+               return a.isEmpty() && (Double.parseDouble(b) == 0);\r
+           }\r
+           catch (NumberFormatException e) {\r
+               return false;\r
+           }\r
+       }\r
+       \r
        Object leftValueWithPrefix(Object result, AstValue value, String prefix, boolean forceNumber) {\r
                if(result == null) {\r
                        Object obj = value.accept(this);\r