Package jadex.commons.future
Class CollectionResultListener<E>
- java.lang.Object
- 
- jadex.commons.future.CollectionResultListener<E>
 
- 
- All Implemented Interfaces:
- IFunctionalExceptionListener,- IFunctionalResultListener<E>,- IResultListener<E>,- IUndoneResultListener<E>
 
 public class CollectionResultListener<E> extends java.lang.Object implements IResultListener<E>, IUndoneResultListener<E> Collection result listener collects a number of results and return a collection.
- 
- 
Field SummaryFields Modifier and Type Field Description protected IResultListener<java.util.Collection<E>>delegateThe delegate result listener.protected booleanignorefailuresFlag to indicate that failures should be ignored and only valid results returned.protected booleannotifiedFlag to indicate that the delegate already has been notified.protected static java.lang.ObjectNULLNull object.protected intnumThe number of sub listeners to wait for.protected java.util.Collection<E>resultsThe original result collection.protected booleanundoneThe undone flag.
 - 
Constructor SummaryConstructors Constructor Description CollectionResultListener(boolean ignorefailures, IResultListener<java.util.Collection<E>> delegate)Create a new collection listener.CollectionResultListener(int num, boolean ignorefailures, IResultListener<java.util.Collection<E>> delegate)Create a new collection listener.CollectionResultListener(int num, IResultListener<java.util.Collection<E>> delegate)Create a new collection listener that stops on failures.CollectionResultListener(IResultListener<java.util.Collection<E>> delegate)Create a new collection listener that stops on failures.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancheckNotify(E result, java.lang.Exception ex)Check if the delegate should be notified.voidexceptionOccurred(java.lang.Exception exception)Called when an exception occurred.voidexceptionOccurredIfUndone(java.lang.Exception exception)Called when an exception occurred.intgetResultCount()Get the result count.booleanisUndone()Get the undone.protected voidnotifyDelegate(java.lang.Exception exception)Notify the delegate.voidresultAvailable(E result)Called when some result is available.voidresultAvailableIfUndone(E result)Called when the result is available.voidsetNumber(int num)Set the expected number of results.
 
- 
- 
- 
Field Detail- 
numprotected int num The number of sub listeners to wait for.
 - 
resultsprotected java.util.Collection<E> results The original result collection.
 - 
delegateprotected IResultListener<java.util.Collection<E>> delegate The delegate result listener.
 - 
notifiedprotected boolean notified Flag to indicate that the delegate already has been notified.
 - 
ignorefailuresprotected boolean ignorefailures Flag to indicate that failures should be ignored and only valid results returned.
 - 
undoneprotected boolean undone The undone flag.
 - 
NULLprotected static final java.lang.Object NULL Null object.
 
- 
 - 
Constructor Detail- 
CollectionResultListenerpublic CollectionResultListener(IResultListener<java.util.Collection<E>> delegate) Create a new collection listener that stops on failures.- Parameters:
- num- The expected number of results.
- delegate- The delegate result listener.
 
 - 
CollectionResultListenerpublic CollectionResultListener(boolean ignorefailures, IResultListener<java.util.Collection<E>> delegate)Create a new collection listener.- Parameters:
- num- The expected number of results.
- ignorefailures- When set to true failures will be tolerated and just not be added to the result collection.
- delegate- The delegate result listener.
 
 - 
CollectionResultListenerpublic CollectionResultListener(int num, IResultListener<java.util.Collection<E>> delegate)Create a new collection listener that stops on failures.- Parameters:
- num- The expected number of results.
- delegate- The delegate result listener.
 
 - 
CollectionResultListenerpublic CollectionResultListener(int num, boolean ignorefailures, IResultListener<java.util.Collection<E>> delegate)Create a new collection listener.- Parameters:
- num- The expected number of results.
- ignorefailures- When set to true failures will be tolerated and just not be added to the result collection.
- delegate- The delegate result listener.
 
 
- 
 - 
Method Detail- 
resultAvailablepublic void resultAvailable(E result) Called when some 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.
 
 - 
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.
 
 - 
getResultCountpublic int getResultCount() Get the result count.- Returns:
- The result count.
 
 - 
setNumberpublic void setNumber(int num) Set the expected number of results.- Parameters:
- num- The expected number of results to set.
 
 - 
checkNotifyprotected boolean checkNotify(E result, java.lang.Exception ex) Check if the delegate should be notified.
 - 
notifyDelegateprotected void notifyDelegate(java.lang.Exception exception) Notify the delegate.
 
- 
 
-