01: package abbot.util;
02:
03: public class Properties {
04:
05: /** Load an integer system property, keeping it within the given valid
06: range. */
07: public static int getProperty(String name, int defValue, int min,
08: int max) {
09: try {
10: int value = Integer.getInteger(name, defValue).intValue();
11: return Math.max(min, Math.min(max, value));
12: } catch (NumberFormatException e) {
13: return defValue;
14: }
15: }
16:
17: /** Load a long system property, keeping it within the given valid
18: range. */
19: public static long getProperty(String name, long min, long max,
20: long defValue) {
21: try {
22: long value = Long.getLong(name, defValue).longValue();
23: return Math.max(min, Math.min(max, value));
24: } catch (NumberFormatException e) {
25: return defValue;
26: }
27: }
28: }
|