uchicago.src.sim.analysis
Class AverageDataSource

java.lang.Object
  extended by uchicago.src.sim.analysis.AverageDataSource
All Implemented Interfaces:
DataSource

public class AverageDataSource
extends java.lang.Object
implements DataSource

Dynamically computes the average of a list of values. The values are are the result of calling a specified method on a specified list. For example, given a list of agents all of whom have an age value, the average age can be calculated by calling a method such as getAge() on each of the agents and averaging the this list of age values.

Version:
$Revision: 1.5 $ $Date: 2004/11/03 19:51:00 $
Author:
Nick Collier

Constructor Summary
AverageDataSource(java.lang.String name, java.util.ArrayList list, java.lang.String methodName)
          Constructs this AverageDataSource using the specified list and method name.
 
Method Summary
 java.lang.Object execute()
          Computes the average.
 java.lang.String getName()
          Gets the name of this datasource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AverageDataSource

public AverageDataSource(java.lang.String name,
                         java.util.ArrayList list,
                         java.lang.String methodName)
Constructs this AverageDataSource using the specified list and method name. Each object in the list should respond to the method named by method name. This method must return some subclass of Number.

Parameters:
list - the list of objects on which to call the method
methodName - the name of the method to call. This method must return some subclass of java.Number.
See Also:
Number
Method Detail

execute

public java.lang.Object execute()
Computes the average.

Specified by:
execute in interface DataSource
Returns:
the average as a Double. Needs to be cast from the Object type.
See Also:
Double

getName

public java.lang.String getName()
Gets the name of this datasource

Returns:
the name of the data source