From c3defdb1af7f42800a49c7833c8d37a81af833a4 Mon Sep 17 00:00:00 2001 From: benfry Date: Mon, 22 Jul 2002 05:19:44 +0000 Subject: [PATCH] problem in number parsing was keeping apps from running (getInteger inside PdeBase) --- processing/app/PdeBase.java | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/processing/app/PdeBase.java b/processing/app/PdeBase.java index 2b707a169..ca4aad8f2 100644 --- a/processing/app/PdeBase.java +++ b/processing/app/PdeBase.java @@ -390,12 +390,35 @@ public class PdeBase implements ActionListener { String value = get(attribute, null); return (value == null) ? defaultValue : (new Boolean(value)).booleanValue(); + + /* + supposedly not needed, because anything besides 'true' + (ignoring case) will just be false.. so if malformed -> false + if (value == null) return defaultValue; + + try { + return (new Boolean(value)).booleanValue(); + } catch (NumberFormatException e) { + System.err.println("expecting an integer: " + attribute + " = " + value); + } + return defaultValue; + */ } static public int getInteger(String attribute, int defaultValue) { String value = get(attribute, null); - return (value == null) ? defaultValue : - Integer.parseInt(value); + if (value == null) return defaultValue; + + try { + return Integer.parseInt(value); + } catch (NumberFormatException e) { + // ignored will just fall through to returning the default + System.err.println("expecting an integer: " + attribute + " = " + value); + } + return defaultValue; + //if (value == null) return defaultValue; + //return (value == null) ? defaultValue : + //Integer.parseInt(value); } static public Color getColor(String name, Color otherwise) {