jfreerails.world.top
Class ItemsTransactionAggregator

java.lang.Object
  extended by jfreerails.world.top.TransactionAggregator
      extended by jfreerails.world.top.ItemsTransactionAggregator

public class ItemsTransactionAggregator
extends TransactionAggregator

Adds up the number of assets.

Author:
Luke

Nested Class Summary
static class ItemsTransactionAggregator.QuantitiesAndValues
          Stores the quantities and monetary values of a series of items.
 
Field Summary
static int ANY_VALUE
           
private  Transaction.Category category
           
private  int[] quantities
           
private  int quantityRunningTotal
           
private  int type
           
 
Fields inherited from class jfreerails.world.top.TransactionAggregator
monetaryTotals, principal, runningTotal, w
 
Constructor Summary
ItemsTransactionAggregator(ReadOnlyWorld w, FreerailsPrincipal principal)
           
 
Method Summary
 ItemsTransactionAggregator.QuantitiesAndValues calculateQuantitiesAndValues()
           
 int calculateQuantity()
           
protected  boolean condition(int transactionID)
          Returns true if the transaction with the specified ID has an acceptable type and category.
 Transaction.Category getCategory()
           
 int getType()
           
protected  void incrementRunningTotal(int transactionID)
           
 void setCategory(Transaction.Category category)
           
protected  void setTotalsArrayLength(int length)
          Creates a new array with the specified length to store monetary totals and sets the running total to zero.
 void setType(int type)
           
protected  void storeRunningTotal(int timeIndex)
          Stores the current running total in the totals array at the specified position.
 
Methods inherited from class jfreerails.world.top.TransactionAggregator
calculateValue, calculateValues, getTimes, setTimes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANY_VALUE

public static final int ANY_VALUE
See Also:
Constant Field Values

type

private int type

category

private Transaction.Category category

quantities

private int[] quantities

quantityRunningTotal

private int quantityRunningTotal
Constructor Detail

ItemsTransactionAggregator

public ItemsTransactionAggregator(ReadOnlyWorld w,
                                  FreerailsPrincipal principal)
Method Detail

condition

protected boolean condition(int transactionID)
Returns true if the transaction with the specified ID has an acceptable type and category.

Specified by:
condition in class TransactionAggregator

calculateQuantity

public int calculateQuantity()

calculateQuantitiesAndValues

public ItemsTransactionAggregator.QuantitiesAndValues calculateQuantitiesAndValues()

incrementRunningTotal

protected void incrementRunningTotal(int transactionID)
Overrides:
incrementRunningTotal in class TransactionAggregator

setTotalsArrayLength

protected void setTotalsArrayLength(int length)
Description copied from class: TransactionAggregator
Creates a new array with the specified length to store monetary totals and sets the running total to zero. Subclasses that aggregate other quantities should override this method and create the appropriate arrays.

Overrides:
setTotalsArrayLength in class TransactionAggregator

storeRunningTotal

protected void storeRunningTotal(int timeIndex)
Description copied from class: TransactionAggregator
Stores the current running total in the totals array at the specified position.

Overrides:
storeRunningTotal in class TransactionAggregator

getCategory

public Transaction.Category getCategory()

setCategory

public void setCategory(Transaction.Category category)

getType

public int getType()

setType

public void setType(int type)