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 implementation of the Aggregator interface that sums the profile values.
20: * In the case of either of the profile values not valid integers, the
21: * default value is picked up.
22: *
23: *
24: * @author Karan Vahi
25: * @version $Revision: 50 $
26: */
27: public class Sum extends Abstract {
28:
29: /**
30: * Sums up the values.
31: *
32: * @param oldValue the existing value for the profile.
33: * @param newValue the new value being added to the profile.
34: * @param dflt the default value to be used in case the values
35: * are not of the correct type.
36: *
37: * @return the computed value as a String.
38: */
39: public String compute(String oldValue, String newValue, String dflt) {
40: return Integer.toString(parseInt(oldValue, dflt)
41: + parseInt(newValue, dflt));
42: }
43:
44: }
|