diff options
author | wizard23 <wizard23@cb376a5e-1013-0410-a455-b6b1f9ac8223> | 2009-05-13 08:12:03 +0000 |
---|---|---|
committer | wizard23 <wizard23@cb376a5e-1013-0410-a455-b6b1f9ac8223> | 2009-05-13 08:12:03 +0000 |
commit | b9edc279ade1f311b07f9a8d2aff96c64d5f82fb (patch) | |
tree | 8da2e56945a1db47b84204cb54437762847ab991 | |
parent | ba6379a023527e30f9baa33741c8dc81ebdc45be (diff) | |
download | reprap-backup-b9edc279ade1f311b07f9a8d2aff96c64d5f82fb.tar.gz reprap-backup-b9edc279ade1f311b07f9a8d2aff96c64d5f82fb.zip |
added boolean expression evaluation
git-svn-id: https://reprap.svn.sourceforge.net/svnroot/reprap@2977 cb376a5e-1013-0410-a455-b6b1f9ac8223
-rw-r--r-- | trunk/reprap/miscellaneous/AoI/plugins/CSGEvaluator/src/org/reprap/artofillusion/MetaCADContext.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/trunk/reprap/miscellaneous/AoI/plugins/CSGEvaluator/src/org/reprap/artofillusion/MetaCADContext.java b/trunk/reprap/miscellaneous/AoI/plugins/CSGEvaluator/src/org/reprap/artofillusion/MetaCADContext.java index a8b23102..5ca1e820 100644 --- a/trunk/reprap/miscellaneous/AoI/plugins/CSGEvaluator/src/org/reprap/artofillusion/MetaCADContext.java +++ b/trunk/reprap/miscellaneous/AoI/plugins/CSGEvaluator/src/org/reprap/artofillusion/MetaCADContext.java @@ -46,5 +46,21 @@ public class MetaCADContext { throw (ex); } } + + public boolean evaluateBoolean(String expr) throws Exception { + try { + return this.evaluateExpression(expr) != 0; + } + catch (Exception ex) { + // test special cases + String lc = expr.toLowerCase(); + if (lc.equals("true") || lc.equals("yes") || lc.equals("on")) + return true; + if (lc.equals("false") || lc.equals("no") || lc.equals("off")) + return false; + // no special cases then well have to throw an exception + throw (ex); + } + } } |