It's an ObserverList! It's a ResultListener! It multiplexes results to many

ResultListeners and still has time to keep your code clean!


git-svn-id: https://samskivert.googlecode.com/svn/trunk@1487 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
ray
2004-08-14 03:18:17 +00:00
parent 47257c70d6
commit a06c6e26d5
@@ -0,0 +1,55 @@
//
// $Id$
package com.samskivert.util;
/**
* Multiplexes ResultListener responses to multiple ResultListeners.
*/
public class ResultListenerList extends ObserverList
implements ResultListener
{
/**
* Create a ResultListenerList with the FAST_UNSAFE_NOTIFY policy.
*/
public ResultListenerList ()
{
super(FAST_UNSAFE_NOTIFY);
}
/**
* Create a ResultListenerList with your own notifyPolicy.
*/
public ResultListenerList (int notifyPolicy)
{
super(notifyPolicy);
}
/**
* Multiplex a requestCompleted response to all the ResultListeners in
* this list.
*/
public void requestCompleted (final Object result)
{
apply(new ObserverOp() {
public boolean apply (Object observer) {
((ResultListener) observer).requestCompleted(result);
return true;
}
});
}
/**
* Multiplex a requestFailed response to all the ResultListeners in
* this list.
*/
public void requestFailed (final Exception cause)
{
apply(new ObserverOp() {
public boolean apply (Object observer) {
((ResultListener) observer).requestFailed(cause);
return true;
}
});
}
}