avrora.util.profiling
Class Proportion

java.lang.Object
  extended byavrora.util.profiling.DataItem
      extended byavrora.util.profiling.Proportion

public class Proportion
extends DataItem

This class represents the proportion of different items with respect to one another. For example, the proportion of cars, trucks, vans, etc on the highway.


Nested Class Summary
 class Proportion.Share
          Internal class that encapsulates both a counter and the fraction of the total that this named Share represents.
 
Field Summary
protected  java.util.Vector shares
           
protected  int total
           
 
Fields inherited from class avrora.util.profiling.DataItem
name
 
Constructor Summary
Proportion(java.lang.String newname)
          Public constructor that takes a string name.
 
Method Summary
 Proportion.Share createShare(java.lang.String name)
          Register a counter object with this proportion.
 float getFractionForName(java.lang.String name)
          Search for the counter with the specified name and report its proportion.
 Proportion.Share getShareForName(java.lang.String name)
          Search for the counter with the specified string name and return it if it is registered.
 boolean hasData()
          Return true if this proportion has any information available.
 void processData()
          Do the computations and compute the proportions of each.
 Proportion.Share registerCount(java.lang.String str, int count)
          Register an integer count with this proportion object and return a Counter object.
 void textReport()
          Generate a text report of the shares.
 
Methods inherited from class avrora.util.profiling.DataItem
getName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

shares

protected java.util.Vector shares

total

protected int total
Constructor Detail

Proportion

public Proportion(java.lang.String newname)
Public constructor that takes a string name.

Method Detail

textReport

public void textReport()
Generate a text report of the shares.

Specified by:
textReport in class DataItem

createShare

public Proportion.Share createShare(java.lang.String name)
Register a counter object with this proportion.


registerCount

public Proportion.Share registerCount(java.lang.String str,
                                      int count)
Register an integer count with this proportion object and return a Counter object.


getShareForName

public Proportion.Share getShareForName(java.lang.String name)
Search for the counter with the specified string name and return it if it is registered.


getFractionForName

public float getFractionForName(java.lang.String name)
Search for the counter with the specified name and report its proportion. Return -1 if not found.


processData

public void processData()
Do the computations and compute the proportions of each.

Specified by:
processData in class DataItem

hasData

public boolean hasData()
Return true if this proportion has any information available.

Specified by:
hasData in class DataItem