Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.ascape.util.data
Class StatCollectorCond

    java.lang.Object
      org.ascape.util.data.StatCollector
          org.ascape.util.data.StatCollectorCond

All Implemented Interfaces:
  java.io.Serializable, 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();
        }
     }

Since:
  1.0
Version:
  1.2
Author:
  Miles Parker
See Also:
  `StatCollector`, Serialized Form

Field Summary

Fields inherited from class org.ascape.util.data.StatCollector
`allMeasureNames, allMeasureNamesShort, autoCollect, COLLECTING, count, name, NOT_COLLECTING, SET_BY_DATAGROUP`

Constructor Summary
`StatCollectorCond()` 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 org.ascape.util.data.StatCollector
`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
`meetsCondition`

Constructor Detail

### StatCollectorCond

    public StatCollectorCond()

  Constructs a new StatCollectorCond.

### StatCollectorCond

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

  Constructs a new StatCollectorCond.

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

### StatCollectorCond

    public StatCollectorCond(java.lang.String name)

  Constructs a new StatCollectorCond. (Automatic by default.)

  Parameters:
    `name` - the name of the stat collector.

Method Detail

### addValueFor

    public void addValueFor(java.lang.Object object)

  Add value to stat calculation for this object if condition met.

  Overrides:
    `addValueFor` in class `StatCollector`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD