net.fortytwo.flow
Class HistorySink<T>

java.lang.Object
  extended by net.fortytwo.flow.HistorySink<T>
Type Parameters:
T - the type of data being passed
All Implemented Interfaces:
Sink<T>

public class HistorySink<T>
extends Object
implements Sink<T>

A Sink which maintains a history of items received during any given interval between calls to its advance method. It has a limited capacity, remembering only the latest k intervals.

Author:
Joshua Shinavier (http://fortytwo.net)

Constructor Summary
HistorySink(int capacity)
          Constructs a new history sink with a given capacity
 
Method Summary
 void advance()
          Advances to the next step in the history
 Source<T> get(int index)
          Retrieves a data source for a given step in the history.
 void put(T t)
          Receives the next data item passed in.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HistorySink

public HistorySink(int capacity)
Constructs a new history sink with a given capacity

Parameters:
capacity - the number of items this history sink may hold
Method Detail

advance

public void advance()
Advances to the next step in the history


put

public void put(T t)
         throws RippleException
Receives the next data item passed in. The item goes into the current step in the history.

Specified by:
put in interface Sink<T>
Parameters:
t - the data item being passed
Throws:
RippleException - if a data handling error occurs

get

public Source<T> get(int index)
Retrieves a data source for a given step in the history.

Parameters:
index - the index of the desired step in the history. The current step has an index of 0, while the previous step has an index of 1, etc.
Returns:
a data source producing all data items collected in the given step


Copyright © 2007-2014. All Rights Reserved.