de.unikassel.android.sdcframework.util.facade
Interface EventCollector<T extends ObservableEvent>

Package class diagram package EventCollector
Type Parameters:
T - the collected event type extending ObservableEvent
All Superinterfaces:
ObservableEventSource<EventError>, ObserverRegistration<EventError>
All Known Implementing Classes:
EventCollectorImpl

public interface EventCollector<T extends ObservableEvent>
extends ObservableEventSource<EventError>

Interface for event collectors.

An event collector does collect observable event types by storing the events in a thread safe queue. It does provide access methods for a event dispatcher to dequeue the stored events.
The internal EventObserver instance can be registered to any instance of an ObservableEventSource, valid for the collected event type.
Errors during event collection can be observed.


Method Summary
 void clearCollectedEvents()
          Does clear the collected event queue
 T dequeue()
          Method to dequeue an event.
 int dequeue(Collection<? super T> collection, int maxElements)
          Method to dequeue more than one element event.
 boolean enqueue(T event)
          Method to enqueue an event
 int getEventCount()
          Getter for the count collected and stored events
 EventObserver<T> getEventObserver()
          Getter for the event observer
 
Methods inherited from interface de.unikassel.android.sdcframework.util.facade.ObservableEventSource
hasObservers, notify
 
Methods inherited from interface de.unikassel.android.sdcframework.util.facade.ObserverRegistration
registerEventObserver, removeAllObservers, unregisterEventObserver
 

Method Detail

enqueue

boolean enqueue(T event)
Method to enqueue an event

Parameters:
event - the event to enqueue
Returns:
true if successful, false otherwise

dequeue

T dequeue()
                                  throws InterruptedException
Method to dequeue an event. Will block the caller if queue is empty!

Returns:
the event
Throws:
InterruptedException - is thrown if a calling thread is interrupted while blocking at the internal queue

dequeue

int dequeue(Collection<? super T> collection,
            int maxElements)
Method to dequeue more than one element event.

Parameters:
collection - the collection to dequeue elements into
maxElements - the maximum element count to dequeue
Returns:
the number of elements dequeued

getEventCount

int getEventCount()
Getter for the count collected and stored events

Returns:
the count of collected and stored events

clearCollectedEvents

void clearCollectedEvents()
Does clear the collected event queue


getEventObserver

EventObserver<T> getEventObserver()
Getter for the event observer

Returns:
the event observer