From 5ea5ca37682bd82ddf4c8499288256684d0f6f1f Mon Sep 17 00:00:00 2001 From: jprocter Date: Wed, 9 Nov 2011 14:19:53 +0000 Subject: [PATCH] (JAL-986) getter for integer user preference properties --- src/jalview/bin/Cache.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index ba1d0a8..aa1a022 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -802,4 +802,24 @@ public class Cache } return null; } + + /** + * get and parse a property as an integer. send any parsing problems to System.err + * @param property + * @return null or Integer + */ + public static Integer getIntegerProperty(String property) + { + String val=getProperty(property); + if (val!=null && (val=val.trim()).length()>0) + { + try { + return Integer.valueOf(val); + } catch (NumberFormatException x) + { + System.err.println("Invalid integer in property '"+property+"' (value was '"+val+"')"); + } + } + return null; + } } -- 1.7.10.2