Package jadex.commons.future
Class CounterResultListener<E>
- java.lang.Object
- 
- jadex.commons.future.CounterResultListener<E>
 
- 
- All Implemented Interfaces:
- IFunctionalExceptionListener,- IFunctionalResultListener<E>,- IResultListener<E>,- IUndoneResultListener<E>
 
 public class CounterResultListener<E> extends java.lang.Object implements IResultListener<E>, IUndoneResultListener<E> Counter result listener for counting a specified number of resultAvailable calls.
- 
- 
Field SummaryFields Modifier and Type Field Description protected intcntThe number of received callbacks.protected IResultListener<java.lang.Void>delegateThe delegate result listener.protected booleanignorefailuresThe ignore failure flag.protected IFunctionalResultListener<E>intermediateResultListenerListener that is called on intermediate results.protected booleannotifiedFlag to indicate that the delegate already has been notified.protected intnumThe number of sub listeners to wait for.protected booleanundoneThe undone flag.
 - 
Constructor SummaryConstructors Constructor Description CounterResultListener(int num, boolean ignorefailures, IResultListener<java.lang.Void> delegate)Create a new counter listener.CounterResultListener(int num, IResultListener<java.lang.Void> delegate)Create a new counter listener.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexceptionOccurred(java.lang.Exception exception)Called when an exception occurred.voidexceptionOccurredIfUndone(java.lang.Exception exception)Called when an exception occurred.intgetCnt()Get the current number of received results.intgetNumber()Get the number of results this Listener is waiting for.booleanintermediateExceptionOccurred(java.lang.Exception exception)Method that can be overridden to do sth.voidintermediateResultAvailable(E result)Method that can be overridden to do sth.booleanisUndone()Get the undone.voidresultAvailable(E result)Called when the result is available.voidresultAvailableIfUndone(E result)Called when the result is available.voidsetNumber(int num)Set the number.
 
- 
- 
- 
Field Detail- 
numprotected int num The number of sub listeners to wait for.
 - 
cntprotected int cnt The number of received callbacks.
 - 
delegateprotected IResultListener<java.lang.Void> delegate The delegate result listener.
 - 
notifiedprotected boolean notified Flag to indicate that the delegate already has been notified.
 - 
ignorefailuresprotected boolean ignorefailures The ignore failure flag.
 - 
undoneprotected boolean undone The undone flag.
 - 
intermediateResultListenerprotected IFunctionalResultListener<E> intermediateResultListener Listener that is called on intermediate results.
 
- 
 - 
Constructor Detail- 
CounterResultListenerpublic CounterResultListener(int num, IResultListener<java.lang.Void> delegate)Create a new counter listener.- Parameters:
- num- The number of sub callbacks.
 
 - 
CounterResultListenerpublic CounterResultListener(int num, boolean ignorefailures, IResultListener<java.lang.Void> delegate)Create a new counter listener.- Parameters:
- num- The number of sub callbacks.
 
 
- 
 - 
Method Detail- 
resultAvailablepublic void resultAvailable(E result) Called when the result is available.- Specified by:
- resultAvailablein interface- IFunctionalResultListener<E>
- Parameters:
- result- The result.
 
 - 
exceptionOccurredpublic void exceptionOccurred(java.lang.Exception exception) Called when an exception occurred.- Specified by:
- exceptionOccurredin interface- IFunctionalExceptionListener
- Parameters:
- exception- The exception.
 
 - 
intermediateResultAvailablepublic void intermediateResultAvailable(E result) Method that can be overridden to do sth. on each result available call.
 - 
intermediateExceptionOccurredpublic boolean intermediateExceptionOccurred(java.lang.Exception exception) Method that can be overridden to do sth. on each exception that occurs.- Returns:
- True, for retry the task (cnt is not increased);
 
 - 
getNumberpublic int getNumber() Get the number of results this Listener is waiting for.- Returns:
- The expected number of results.
 
 - 
setNumberpublic void setNumber(int num) Set the number.- Parameters:
- num- The number.
 
 - 
getCntpublic int getCnt() Get the current number of received results.- Returns:
- Number of results.
 
 - 
resultAvailableIfUndonepublic void resultAvailableIfUndone(E result) Called when the result is available.- Specified by:
- resultAvailableIfUndonein interface- IUndoneResultListener<E>
- Parameters:
- result- The result.
 
 - 
exceptionOccurredIfUndonepublic void exceptionOccurredIfUndone(java.lang.Exception exception) Called when an exception occurred.- Specified by:
- exceptionOccurredIfUndonein interface- IUndoneResultListener<E>
- Parameters:
- exception- The exception.
 
 - 
isUndonepublic boolean isUndone() Get the undone.- Returns:
- The undone.
 
 
- 
 
-