⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 downloadmanagerimpl.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
			return singleton.getDownload(dm);
		else
			throw new DownloadException("DownloadManager not initialised");
	}

	public Download getDownload(DiskManager dm)
		throws DownloadException
	{
		List dls = global_manager.getDownloadManagers();
		for (int i = 0; i < dls.size(); i++)
		{
			DownloadManager man = (DownloadManager)dls.get(i);
			if (man.getDiskManager() == dm)
				return getDownload(man.getTorrent());
		}

		return null;
	}

	protected Download getDownload(TOTorrent torrent)
		throws DownloadException
	{
		if (torrent != null)
		{
			for (int i = 0; i < downloads.size(); i++)
			{
				Download dl = (Download)downloads.get(i);
				TorrentImpl t = (TorrentImpl)dl.getTorrent();
				if (t != null && t.getTorrent().hasSameHashAs(torrent))
					return dl;
			}

		}
		throw new DownloadException("DownloadManager::getDownload: download not found");
	}

	public static Download getDownloadStatic(TOTorrent torrent)
		throws DownloadException
	{
		if (singleton != null)
			return singleton.getDownload(torrent);
		else
			throw new DownloadException("DownloadManager not initialised");
	}

	public Download getDownload(Torrent _torrent)
	{
		TorrentImpl torrent = (TorrentImpl)_torrent;
		return getDownload(torrent.getTorrent());
		DownloadException e;
		e;
		return null;
	}

	public Download getDownload(byte hash[])
	{
		List dls;
		int i;
		dls = global_manager.getDownloadManagers();
		i = 0;
_L3:
		if (i >= dls.size()) goto _L2; else goto _L1
_L1:
		TOTorrent torrent;
		DownloadManager man = (DownloadManager)dls.get(i);
		torrent = man.getTorrent();
		if (torrent == null)
			continue; /* Loop/switch isn't completed */
		if (Arrays.equals(torrent.getHash(), hash))
			return getDownload(torrent);
		continue; /* Loop/switch isn't completed */
		DownloadException e;
		e;
		continue; /* Loop/switch isn't completed */
		e;
		Debug.printStackTrace(e);
		i++;
		  goto _L3
_L2:
		return null;
	}

	public Download[] getDownloads()
	{
		Set res_l;
		List dms;
		res_l = new LinkedHashSet();
		dms = global_manager.getDownloadManagers();
		listeners_mon.enter();
		for (int i = 0; i < dms.size(); i++)
		{
			Object dl = download_map.get(dms.get(i));
			if (dl != null)
				res_l.add(dl);
		}

		if (res_l.size() < downloads.size())
		{
			for (int i = 0; i < downloads.size(); i++)
			{
				Download download = (Download)downloads.get(i);
				if (!res_l.contains(download))
					res_l.add(download);
			}

		}
		listeners_mon.exit();
		break MISSING_BLOCK_LABEL_171;
		Exception exception;
		exception;
		listeners_mon.exit();
		throw exception;
		Download res[] = new Download[res_l.size()];
		res_l.toArray(res);
		return res;
	}

	public Download[] getDownloads(boolean bSorted)
	{
		if (bSorted)
			return getDownloads();
		Download adownload[];
		listeners_mon.enter();
		Download res[] = new Download[downloads.size()];
		downloads.toArray(res);
		adownload = res;
		listeners_mon.exit();
		return adownload;
		Exception exception;
		exception;
		listeners_mon.exit();
		throw exception;
	}

	public void pauseDownloads()
	{
		global_manager.pauseDownloads();
	}

	public boolean canPauseDownloads()
	{
		return global_manager.canPauseDownloads();
	}

	public void resumeDownloads()
	{
		global_manager.resumeDownloads();
	}

	public boolean canResumeDownloads()
	{
		return global_manager.canResumeDownloads();
	}

	public void startAllDownloads()
	{
		global_manager.startAllDownloads();
	}

	public void stopAllDownloads()
	{
		global_manager.stopAllDownloads();
	}

	public DownloadManagerStats getStats()
	{
		return stats;
	}

	public boolean isSeedingOnly()
	{
		return global_manager.isSeedingOnly();
	}

	public void addListener(DownloadManagerListener l)
	{
		addListener(l, true);
	}

	public void addListener(DownloadManagerListener l, boolean notify_of_current_downloads)
	{
		List downloads_copy = null;
		listeners_mon.enter();
		List new_listeners = new ArrayList(listeners);
		new_listeners.add(l);
		listeners = new_listeners;
		if (notify_of_current_downloads)
			downloads_copy = new ArrayList(downloads);
		listeners_mon.exit();
		break MISSING_BLOCK_LABEL_75;
		Exception exception;
		exception;
		listeners_mon.exit();
		throw exception;
		if (downloads_copy != null)
		{
			for (int i = 0; i < downloads_copy.size(); i++)
				try
				{
					l.downloadAdded((Download)downloads_copy.get(i));
				}
				catch (Throwable e)
				{
					Debug.printStackTrace(e);
				}

		}
		return;
	}

	public void removeListener(DownloadManagerListener l)
	{
		removeListener(l, false);
	}

	public void removeListener(DownloadManagerListener l, boolean notify_of_current_downloads)
	{
		List downloads_copy = null;
		listeners_mon.enter();
		List new_listeners = new ArrayList(listeners);
		new_listeners.remove(l);
		listeners = new_listeners;
		if (notify_of_current_downloads)
			downloads_copy = new ArrayList(downloads);
		listeners_mon.exit();
		break MISSING_BLOCK_LABEL_75;
		Exception exception;
		exception;
		listeners_mon.exit();
		throw exception;
		if (downloads_copy != null)
		{
			for (int i = 0; i < downloads_copy.size(); i++)
				try
				{
					l.downloadRemoved((Download)downloads_copy.get(i));
				}
				catch (Throwable e)
				{
					Debug.printStackTrace(e);
				}

		}
		return;
	}

	public void initialised(DownloadManager manager)
	{
		DownloadImpl dl;
		listeners_mon.enter();
		dl = new DownloadImpl(manager);
		pending_dls.put(manager, dl);
		listeners_mon.exit();
		break MISSING_BLOCK_LABEL_48;
		Exception exception;
		exception;
		listeners_mon.exit();
		throw exception;
		for (Iterator it = dwba_listeners.iterator(); it.hasNext();)
			try
			{
				((DownloadWillBeAddedListener)it.next()).initialised(dl);
			}
			catch (Throwable e)
			{
				Debug.printStackTrace(e);
			}

		return;
	}

	public void addDownloadWillBeAddedListener(DownloadWillBeAddedListener listener)
	{
		listeners_mon.enter();
		dwba_listeners.add(listener);
		if (dwba_listeners.size() == 1)
			global_manager.addDownloadManagerInitialisationAdapter(this);
		listeners_mon.exit();
		break MISSING_BLOCK_LABEL_56;
		Exception exception;
		exception;
		listeners_mon.exit();
		throw exception;
	}

	public void removeDownloadWillBeAddedListener(DownloadWillBeAddedListener listener)
	{
		listeners_mon.enter();
		dwba_listeners.remove(listener);
		if (dwba_listeners.size() == 0)
			global_manager.removeDownloadManagerInitialisationAdapter(this);
		listeners_mon.exit();
		break MISSING_BLOCK_LABEL_56;
		Exception exception;
		exception;
		listeners_mon.exit();
		throw exception;
	}

	public void addExternalDownload(Download download)
	{
		List listeners_ref = null;
		listeners_mon.enter();
		if (downloads.contains(download))
		{
			listeners_mon.exit();
			return;
		}
		downloads.add(download);
		listeners_ref = listeners;
		listeners_mon.exit();
		break MISSING_BLOCK_LABEL_66;
		Exception exception;
		exception;
		listeners_mon.exit();
		throw exception;
		for (int i = 0; i < listeners_ref.size(); i++)
			try
			{
				((DownloadManagerListener)listeners_ref.get(i)).downloadAdded(download);
			}
			catch (Throwable e)
			{
				Debug.printStackTrace(e);
			}

		return;
	}

	public void removeExternalDownload(Download download)
	{
		List listeners_ref = null;
		listeners_mon.enter();
		if (!downloads.contains(download))
		{
			listeners_mon.exit();
			return;
		}
		downloads.remove(download);
		listeners_ref = listeners;
		listeners_mon.exit();
		break MISSING_BLOCK_LABEL_66;
		Exception exception;
		exception;
		listeners_mon.exit();
		throw exception;
		for (int i = 0; i < listeners_ref.size(); i++)
			try
			{
				((DownloadManagerListener)listeners_ref.get(i)).downloadRemoved(download);
			}
			catch (Throwable e)
			{
				Debug.printStackTrace(e);
			}

		return;
	}

	public DownloadEventNotifier getGlobalDownloadEventNotifier()
	{
		return global_dl_notifier;
	}

	public void setSaveLocationManager(SaveLocationManager manager)
	{
		if (manager == null)
			manager = getDefaultSaveLocationManager();
		DownloadManagerMoveHandler.CURRENT_HANDLER = manager;
	}

	public SaveLocationManager getSaveLocationManager()
	{
		return DownloadManagerMoveHandler.CURRENT_HANDLER;
	}

	public DefaultSaveLocationManager getDefaultSaveLocationManager()
	{
		return DownloadManagerDefaultPaths.DEFAULT_HANDLER;
	}






}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -