01: /*
02: * This file or a portion of this file is licensed under the terms of
03: * the Globus Toolkit Public License, found in file GTPL, or at
04: * http://www.globus.org/toolkit/download/license.html. This notice must
05: * appear in redistributions of this file, with or without modification.
06: *
07: * Redistributions of this Software, with or without modification, must
08: * reproduce the GTPL in: (1) the Software, or (2) the Documentation or
09: * some other similar material which is provided with the Software (if
10: * any).
11: *
12: * Copyright 1999-2004 University of Chicago and The University of
13: * Southern California. All rights reserved.
14: */
15:
16: package org.griphyn.cPlanner.namespace.aggregator;
17:
18: /**
19: * An abstract implementation of the Profile Aggregators.
20: *
21: * @author Karan Vahi
22: * @version $Revision: 50 $
23: */
24: public abstract class Abstract implements Aggregator {
25:
26: /**
27: * Formats the String value as an integer. If the String is NaN then the
28: * default value is assigned.
29: *
30: * @param value the value to be converted to integer.
31: * @param dflt the default value to be used in case value is NaN or null.
32: *
33: * @return the integer value
34: *
35: * @throws NumberFormatException in the case when default value cannot be
36: * converted to an int.
37: */
38: protected int parseInt(String value, String dflt)
39: throws NumberFormatException {
40: int val = Integer.parseInt(dflt);
41:
42: //check for null and apply default
43: if (value == null)
44: return val;
45:
46: //try to parse the value
47: try {
48: val = Integer.parseInt(value);
49: } catch (Exception e) { /*ignore for now*/
50: }
51:
52: return val;
53: }
54:
55: }
|