📄 downloadeventnotifierimpl.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: DownloadEventNotifierImpl.java
package org.gudy.azureus2.pluginsimpl.local.download;
import java.util.*;
import org.gudy.azureus2.core3.util.AEMonitor;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.plugins.download.*;
import org.gudy.azureus2.plugins.peers.PeerManager;
import org.gudy.azureus2.plugins.torrent.TorrentAttribute;
public class DownloadEventNotifierImpl
implements DownloadEventNotifier
{
private abstract class BaseDownloadListener
implements DownloadManagerListener
{
protected ArrayList listeners;
private AEMonitor this_mon;
final DownloadEventNotifierImpl this$0;
void addListener(Object o)
{
boolean register_with_downloads = false;
this_mon.enter();
register_with_downloads = listeners.isEmpty();
ArrayList new_listeners = new ArrayList(listeners);
new_listeners.add(o);
listeners = new_listeners;
this_mon.exit();
break MISSING_BLOCK_LABEL_62;
Exception exception;
exception;
this_mon.exit();
throw exception;
if (register_with_downloads)
dm.addListener(this, true);
return;
}
void removeListener(Object o)
{
boolean unregister_from_downloads = false;
this_mon.enter();
ArrayList new_listeners = new ArrayList(listeners);
new_listeners.remove(o);
listeners = new_listeners;
unregister_from_downloads = listeners.isEmpty();
this_mon.exit();
break MISSING_BLOCK_LABEL_62;
Exception exception;
exception;
this_mon.exit();
throw exception;
if (unregister_from_downloads)
dm.removeListener(this, true);
return;
}
private BaseDownloadListener()
{
this$0 = DownloadEventNotifierImpl.this;
super();
listeners = new ArrayList();
this_mon = new AEMonitor(getClass().getName());
}
}
public class DownloadActivationNotifier extends BaseDownloadListener
implements DownloadActivationListener
{
final DownloadEventNotifierImpl this$0;
public void downloadAdded(Download download)
{
download.addActivationListener(this);
}
public void downloadRemoved(Download download)
{
download.removeActivationListener(this);
}
public boolean activationRequested(DownloadActivationEvent event)
{
Iterator itr = listeners.iterator();
_L2:
if (!itr.hasNext())
break; /* Loop/switch isn't completed */
if (((DownloadActivationListener)itr.next()).activationRequested(event))
return true;
continue; /* Loop/switch isn't completed */
Throwable t;
t;
Debug.printStackTrace(t);
if (true) goto _L2; else goto _L1
_L1:
return false;
}
public DownloadActivationNotifier()
{
this$0 = DownloadEventNotifierImpl.this;
super();
}
}
public class DownloadAttributeNotifier extends BaseDownloadListener
implements DownloadAttributeListener
{
private TorrentAttribute ta;
private int event_type;
final DownloadEventNotifierImpl this$0;
public void downloadAdded(Download d)
{
d.addAttributeListener(this, ta, event_type);
}
public void downloadRemoved(Download d)
{
d.removeAttributeListener(this, ta, event_type);
}
public void attributeEventOccurred(Download d, TorrentAttribute ta, int event_type)
{
for (Iterator itr = listeners.iterator(); itr.hasNext();)
try
{
((DownloadAttributeListener)itr.next()).attributeEventOccurred(d, ta, event_type);
}
catch (Throwable t)
{
Debug.printStackTrace(t);
}
}
public DownloadAttributeNotifier(TorrentAttribute ta, int event_type)
{
this$0 = DownloadEventNotifierImpl.this;
super();
this.ta = ta;
this.event_type = event_type;
}
}
public class DownloadCompletionNotifier extends BaseDownloadListener
implements DownloadCompletionListener
{
final DownloadEventNotifierImpl this$0;
public void downloadAdded(Download download)
{
download.addCompletionListener(this);
}
public void downloadRemoved(Download download)
{
download.removeCompletionListener(this);
}
public void onCompletion(Download download)
{
for (Iterator itr = listeners.iterator(); itr.hasNext();)
try
{
((DownloadCompletionListener)itr.next()).onCompletion(download);
}
catch (Throwable t)
{
Debug.printStackTrace(t);
}
}
public DownloadCompletionNotifier()
{
this$0 = DownloadEventNotifierImpl.this;
super();
}
}
public class DownloadNotifier extends BaseDownloadListener
implements DownloadListener
{
final DownloadEventNotifierImpl this$0;
public void downloadAdded(Download download)
{
download.addListener(this);
}
public void downloadRemoved(Download download)
{
download.removeListener(this);
}
public void stateChanged(Download download, int old_state, int new_state)
{
for (Iterator itr = listeners.iterator(); itr.hasNext();)
try
{
((DownloadListener)itr.next()).stateChanged(download, old_state, new_state);
}
catch (Throwable t)
{
Debug.printStackTrace(t);
}
}
public void positionChanged(Download download, int old_position, int new_position)
{
for (Iterator itr = listeners.iterator(); itr.hasNext();)
try
{
((DownloadListener)itr.next()).positionChanged(download, old_position, new_position);
}
catch (Throwable t)
{
Debug.printStackTrace(t);
}
}
public DownloadNotifier()
{
this$0 = DownloadEventNotifierImpl.this;
super();
}
}
public class DownloadPeerNotifier extends BaseDownloadListener
implements DownloadPeerListener
{
final DownloadEventNotifierImpl this$0;
public void downloadAdded(Download download)
{
download.addPeerListener(this);
}
public void downloadRemoved(Download download)
{
download.removePeerListener(this);
}
public void peerManagerAdded(Download download, PeerManager peer_manager)
{
for (Iterator itr = listeners.iterator(); itr.hasNext();)
try
{
((DownloadPeerListener)itr.next()).peerManagerAdded(download, peer_manager);
}
catch (Throwable t)
{
Debug.printStackTrace(t);
}
}
public void peerManagerRemoved(Download download, PeerManager peer_manager)
{
for (Iterator itr = listeners.iterator(); itr.hasNext();)
try
{
((DownloadPeerListener)itr.next()).peerManagerRemoved(download, peer_manager);
}
catch (Throwable t)
{
Debug.printStackTrace(t);
}
}
public DownloadPeerNotifier()
{
this$0 = DownloadEventNotifierImpl.this;
super();
}
}
public class DownloadPropertyNotifier extends BaseDownloadListener
implements DownloadPropertyListener
{
final DownloadEventNotifierImpl this$0;
public void downloadAdded(Download download)
{
download.addPropertyListener(this);
}
public void downloadRemoved(Download download)
{
download.removePropertyListener(this);
}
public void propertyChanged(Download download, DownloadPropertyEvent event)
{
for (Iterator itr = listeners.iterator(); itr.hasNext();)
try
{
((DownloadPropertyListener)itr.next()).propertyChanged(download, event);
}
catch (Throwable t)
{
Debug.printStackTrace(t);
}
}
public DownloadPropertyNotifier()
{
this$0 = DownloadEventNotifierImpl.this;
super();
}
}
public class DownloadTrackerNotifier extends BaseDownloadListener
implements DownloadTrackerListener
{
private boolean instant_notify;
final DownloadEventNotifierImpl this$0;
public void downloadAdded(Download download)
{
download.addTrackerListener(this, instant_notify);
}
public void downloadRemoved(Download download)
{
download.removeTrackerListener(this);
}
public void scrapeResult(DownloadScrapeResult result)
{
for (Iterator itr = listeners.iterator(); itr.hasNext();)
try
{
((DownloadTrackerListener)itr.next()).scrapeResult(result);
}
catch (Throwable t)
{
Debug.printStackTrace(t);
}
}
public void announceResult(DownloadAnnounceResult result)
{
for (Iterator itr = listeners.iterator(); itr.hasNext();)
try
{
((DownloadTrackerListener)itr.next()).announceResult(result);
}
catch (Throwable t)
{
Debug.printStackTrace(t);
}
}
public DownloadTrackerNotifier(boolean instant_notify)
{
this$0 = DownloadEventNotifierImpl.this;
super();
this.instant_notify = instant_notify;
}
}
public class DownloadWillBeRemovedNotifier extends BaseDownloadListener
implements DownloadWillBeRemovedListener
{
final DownloadEventNotifierImpl this$0;
public void downloadAdded(Download download)
{
download.addDownloadWillBeRemovedListener(this);
}
public void downloadRemoved(Download download)
{
download.removeDownloadWillBeRemovedListener(this);
}
public void downloadWillBeRemoved(Download download)
throws DownloadRemovalVetoException
{
for (Iterator itr = listeners.iterator(); itr.hasNext();)
try
{
((DownloadWillBeRemovedListener)itr.next()).downloadWillBeRemoved(download);
}
catch (DownloadRemovalVetoException e)
{
throw e;
}
catch (Throwable t)
{
Debug.printStackTrace(t);
}
}
public DownloadWillBeRemovedNotifier()
{
this$0 = DownloadEventNotifierImpl.this;
super();
}
}
private DownloadActivationNotifier download_activation_notifier;
private DownloadNotifier download_notifier;
private DownloadPeerNotifier download_peer_notifier;
private DownloadPropertyNotifier download_property_notifier;
private DownloadTrackerNotifier download_tracker_notifier;
private DownloadTrackerNotifier download_tracker_notifier_instant;
private DownloadWillBeRemovedNotifier download_will_be_removed_notifier;
private DownloadCompletionNotifier download_completion_notifier;
private DownloadManager dm;
private HashMap read_attribute_listeners;
private HashMap write_attribute_listeners;
public DownloadEventNotifierImpl(DownloadManager dm)
{
this.dm = dm;
download_activation_notifier = new DownloadActivationNotifier();
download_notifier = new DownloadNotifier();
download_peer_notifier = new DownloadPeerNotifier();
download_property_notifier = new DownloadPropertyNotifier();
download_tracker_notifier = new DownloadTrackerNotifier(false);
download_tracker_notifier_instant = new DownloadTrackerNotifier(true);
download_will_be_removed_notifier = new DownloadWillBeRemovedNotifier();
download_completion_notifier = new DownloadCompletionNotifier();
read_attribute_listeners = new HashMap();
write_attribute_listeners = new HashMap();
}
public void addActivationListener(DownloadActivationListener l)
{
download_activation_notifier.addListener(l);
}
public void addCompletionListener(DownloadCompletionListener l)
{
download_completion_notifier.addListener(l);
}
public void addDownloadWillBeRemovedListener(DownloadWillBeRemovedListener l)
{
download_will_be_removed_notifier.addListener(l);
}
public void addListener(DownloadListener l)
{
download_notifier.addListener(l);
}
public void addPeerListener(DownloadPeerListener l)
{
download_peer_notifier.addListener(l);
}
public void addPropertyListener(DownloadPropertyListener l)
{
download_property_notifier.addListener(l);
}
public void addTrackerListener(DownloadTrackerListener l)
{
download_tracker_notifier.addListener(l);
}
public void addTrackerListener(DownloadTrackerListener l, boolean immediateTrigger)
{
(immediateTrigger ? download_tracker_notifier_instant : download_tracker_notifier).addListener(l);
}
public void removeActivationListener(DownloadActivationListener l)
{
download_activation_notifier.removeListener(l);
}
public void removeCompletionListener(DownloadCompletionListener l)
{
download_completion_notifier.removeListener(l);
}
public void removeDownloadWillBeRemovedListener(DownloadWillBeRemovedListener l)
{
download_will_be_removed_notifier.removeListener(l);
}
public void removeListener(DownloadListener l)
{
download_notifier.removeListener(l);
}
public void removePeerListener(DownloadPeerListener l)
{
download_peer_notifier.removeListener(l);
}
public void removePropertyListener(DownloadPropertyListener l)
{
download_property_notifier.removeListener(l);
}
public void removeTrackerListener(DownloadTrackerListener l)
{
download_tracker_notifier.removeListener(l);
download_tracker_notifier_instant.removeListener(l);
}
public void addAttributeListener(DownloadAttributeListener listener, TorrentAttribute ta, int event_type)
{
Map attr_map = getAttributeListenerMap(event_type);
DownloadAttributeNotifier l = (DownloadAttributeNotifier)attr_map.get(ta);
if (l == null)
{
l = new DownloadAttributeNotifier(ta, event_type);
attr_map.put(ta, l);
}
l.addListener(listener);
}
public void removeAttributeListener(DownloadAttributeListener listener, TorrentAttribute ta, int event_type)
{
Map attr_map = getAttributeListenerMap(event_type);
DownloadAttributeNotifier l = (DownloadAttributeNotifier)attr_map.get(ta);
if (l == null)
{
return;
} else
{
l.removeListener(listener);
return;
}
}
private Map getAttributeListenerMap(int event_type)
{
if (event_type == 1)
return write_attribute_listeners;
if (event_type == 2)
return read_attribute_listeners;
else
throw new IllegalArgumentException((new StringBuilder()).append("invalid event type ").append(event_type).toString());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -