net.sf.jagg
Class ModeAggregator

java.lang.Object
  extended by net.sf.jagg.Aggregator
      extended by net.sf.jagg.ModeAggregator

public class ModeAggregator
extends Aggregator

This class represents the "mode" aggregator over Comparable values.

Since:
0.6.0
Author:
Randy Gettman

Field Summary
 
Fields inherited from class net.sf.jagg.Aggregator
PROP_SELF
 
Constructor Summary
ModeAggregator(java.lang.String property)
          Constructs a ModeAggregator that operates on the specified property.
 
Method Summary
 void init()
          Initialize an internal list to empty.
 void iterate(java.lang.Object value)
          Make sure the second property's value is not null, then add the entire Object to an internal list.
 void merge(Aggregator agg)
          Merge the given Aggregator into this one by adding the contents of the given Aggregator's internal list into this Aggregator's internal list.
 ModeAggregator replicate()
          Returns an uninitialized copy of this Aggregator object, with the same property(ies) to analyze.
 java.lang.Comparable terminate()
          Return the value among the values in the specified property that occurs most often (the statistical mode), or any of the modes if there is more than one, with the following algorithm: Sort the internal list with respect to all values, using Collections.sort.
 
Methods inherited from class net.sf.jagg.Aggregator
equals, getAggregator, getAggregator, getProperty, getValueFromProperty, hashCode, isInUse, setInUse, setProperty, terminateDoubleDouble, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModeAggregator

public ModeAggregator(java.lang.String property)
Constructs a ModeAggregator that operates on the specified property.

Parameters:
property - Determine the statistical mode of this property's values.
Method Detail

replicate

public ModeAggregator replicate()
Returns an uninitialized copy of this Aggregator object, with the same property(ies) to analyze.

Specified by:
replicate in class Aggregator
Returns:
An uninitialized copy of this Aggregator object.

init

public void init()
Initialize an internal list to empty.

Specified by:
init in class Aggregator

iterate

public void iterate(java.lang.Object value)
Make sure the second property's value is not null, then add the entire Object to an internal list.

Specified by:
iterate in class Aggregator
Parameters:
value - The value to aggregate.
See Also:
Aggregator.getValueFromProperty(java.lang.Object, java.lang.String)

merge

public void merge(Aggregator agg)
Merge the given Aggregator into this one by adding the contents of the given Aggregator's internal list into this Aggregator's internal list.

Specified by:
merge in class Aggregator
Parameters:
agg - The Aggregator to merge into this one.

terminate

public java.lang.Comparable terminate()
Return the value among the values in the specified property that occurs most often (the statistical mode), or any of the modes if there is more than one, with the following algorithm:
  1. Sort the internal list with respect to all values, using Collections.sort.
  2. Walk through the list of values, keeping track of the current value and the current value's frequency.
  3. Return the mode.

Specified by:
terminate in class Aggregator
Returns:
The statistical mode.
See Also:
Collections.sort(java.util.List), ComparableComparator


Copyright © 2010-2013 jAgg Team. All Rights Reserved.