Class StatCollectorCond

  extended by
      extended by
All Implemented Interfaces:, java.lang.Comparable, Conditional, DataPoint, HasName

public abstract class StatCollectorCond
extends StatCollector
implements Conditional

Collects and stores aggregate statistics on some data source for every specified measurement type of that source, and for each succesive measurement of that source, while that source meets some condition. See StatCollector documentation for a discussion of how to use stat collectors. Conditional stat collectors allow you to specifiy a condition that must be met for a statistic to be measured for an object. In Ascape, they are useful in cases where you want to collect statistics automatically, but you want to restrict the statistic to some subpopulation of a scape. The following example creates an anonymous class that gathers age statistics for agents with wealth over 50,000, and adds it to the parent scape so it can be collected.

 scape.addStatCollector(new StatCollectorCSA("Age") {
    public boolean meetsCondition(Object object) {
         return ((AnObjectWithWealth) object).getWealth() >= 50000;
    public double getValue(Object object) {
         return ((AnObjectWithAge) object).getAge();

Miles Parker
See Also:
StatCollector, Serialized Form

Field Summary
Fields inherited from class
allMeasureNames, allMeasureNamesShort, autoCollect, COLLECTING, count, name, NOT_COLLECTING, SET_BY_DATAGROUP
Constructor Summary
          Constructs a new StatCollectorCond.
StatCollectorCond(java.lang.String name)
          Constructs a new StatCollectorCond.
StatCollectorCond(java.lang.String name, boolean autoCollect)
          Constructs a new StatCollectorCond.
Method Summary
 void addValueFor(java.lang.Object object)
          Add value to stat calculation for this object if condition met.
Methods inherited from class
addValue, calculateCollection, calculateIterator, calculateValue, clear, compareTo, createDataSeries, getAllDataSeries, getAllMeasureNames, getAllMeasureNamesShort, getCollectingLongitudinalDataMode, getCount, getDataGroup, getDataSeries, getName, getValue, isAutoCollect, isCalculated, isCollectingLongitudinalData, isPhase2, setAutoCollect, setCollectingLongitudinalDataMode, setDataGroup, setName, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.ascape.util.Conditional

Constructor Detail


public StatCollectorCond()
Constructs a new StatCollectorCond.


public StatCollectorCond(java.lang.String name,
                         boolean autoCollect)
Constructs a new StatCollectorCond.

name - the name of the stat collector.
autoCollect - should the stat be collected automatically?


public StatCollectorCond(java.lang.String name)
Constructs a new StatCollectorCond. (Automatic by default.)

name - the name of the stat collector.
Method Detail


public void addValueFor(java.lang.Object object)
Add value to stat calculation for this object if condition met.

addValueFor in class StatCollector

Copyright © 1998-2008 The Brookings Institution, NuTech Solutions, Metascape, LLC All Rights Reserved.