Class ServiceRankingResultListener<S>
- java.lang.Object
-
- jadex.bridge.nonfunctional.search.ServiceRankingResultListener<S>
-
- All Implemented Interfaces:
IFunctionalExceptionListener,IFunctionalIntermediateFinishedListener<S>,IFunctionalIntermediateResultCountListener,IFunctionalIntermediateResultListener<S>,IFunctionalResultListener<java.util.Collection<S>>,IIntermediateResultListener<S>,IResultListener<java.util.Collection<S>>
public class ServiceRankingResultListener<S> extends java.lang.Object implements IIntermediateResultListener<S>
Listener that ranks results.
-
-
Field Summary
Fields Modifier and Type Field Description protected IRankingSearchTerminationDecider<S>deciderThe termination decider.protected booleanfinishedThe listener state.protected IResultListener<java.util.Collection<S>>listenerThe delegate listener.protected IServiceRanker<S>rankerThe ranker.protected java.util.List<S>resultsThe saved results.protected IResultListener<java.util.Collection<Tuple2<S,java.lang.Double>>>scorelistenerThe delegate listener.
-
Constructor Summary
Constructors Constructor Description ServiceRankingResultListener(IServiceRanker<S> ranker, IRankingSearchTerminationDecider<S> decider, IResultListener<java.util.Collection<S>> listener)Create a new ranker.ServiceRankingResultListener(IResultListener<java.util.Collection<Tuple2<S,java.lang.Double>>> scorelistener, IServiceRanker<S> ranker, IRankingSearchTerminationDecider<S> decider)Create a new ranker.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidexceptionOccurred(java.lang.Exception exception)Called when exception occurs.voidfinished()Declare that the future is finished.voidintermediateResultAvailable(S result)Process intermediate results for ranking.booleanisFinished()Get the finished.voidmaxResultCountAvailable(int max)Declare that the future result count is available.protected voidnotifyException(java.lang.Exception exception)protected voidnotifyResults(java.util.List<Tuple2<S,java.lang.Double>> results)protected voidrankResults()Rank the results and announce themvoidresultAvailable(java.util.Collection<S> result)Called when result is available.
-
-
-
Field Detail
-
results
protected java.util.List<S> results
The saved results.
-
finished
protected boolean finished
The listener state.
-
ranker
protected IServiceRanker<S> ranker
The ranker.
-
decider
protected IRankingSearchTerminationDecider<S> decider
The termination decider.
-
listener
protected IResultListener<java.util.Collection<S>> listener
The delegate listener.
-
scorelistener
protected IResultListener<java.util.Collection<Tuple2<S,java.lang.Double>>> scorelistener
The delegate listener.
-
-
Constructor Detail
-
ServiceRankingResultListener
public ServiceRankingResultListener(IServiceRanker<S> ranker, IRankingSearchTerminationDecider<S> decider, IResultListener<java.util.Collection<S>> listener)
Create a new ranker.
-
ServiceRankingResultListener
public ServiceRankingResultListener(IResultListener<java.util.Collection<Tuple2<S,java.lang.Double>>> scorelistener, IServiceRanker<S> ranker, IRankingSearchTerminationDecider<S> decider)
Create a new ranker.
-
-
Method Detail
-
intermediateResultAvailable
public void intermediateResultAvailable(S result)
Process intermediate results for ranking.- Specified by:
intermediateResultAvailablein interfaceIFunctionalIntermediateResultListener<S>- Specified by:
intermediateResultAvailablein interfaceIIntermediateResultListener<S>- Parameters:
result- The result.
-
resultAvailable
public void resultAvailable(java.util.Collection<S> result)
Called when result is available.- Specified by:
resultAvailablein interfaceIFunctionalResultListener<S>- Parameters:
result- The result.
-
exceptionOccurred
public void exceptionOccurred(java.lang.Exception exception)
Called when exception occurs.- Specified by:
exceptionOccurredin interfaceIFunctionalExceptionListener- Parameters:
exception- The exception.
-
finished
public void finished()
Description copied from interface:IIntermediateResultListenerDeclare that the future is finished. This method is only called for intermediate futures, i.e. when this method is called it is guaranteed that the intermediateResultAvailable method was called for all intermediate results before.- Specified by:
finishedin interfaceIFunctionalIntermediateFinishedListener<S>- Specified by:
finishedin interfaceIIntermediateResultListener<S>
-
maxResultCountAvailable
public void maxResultCountAvailable(int max)
Description copied from interface:IIntermediateResultListenerDeclare that the future result count is available. This method is only called for intermediate futures, i.e. when this method is called it is guaranteed that the intermediateResultAvailable method will be called as often as the result count indicates except an exception occurs.- Specified by:
maxResultCountAvailablein interfaceIFunctionalIntermediateResultCountListener- Specified by:
maxResultCountAvailablein interfaceIIntermediateResultListener<S>
-
isFinished
public boolean isFinished()
Get the finished.- Returns:
- The finished.
-
rankResults
protected void rankResults()
Rank the results and announce them
-
notifyException
protected void notifyException(java.lang.Exception exception)
-
-