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

📄 resourcedownloaderretryimpl.java

📁 java 文件下载器。可自定义
💻 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:   ResourceDownloaderRetryImpl.java

package org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader;

import java.io.InputStream;
import org.gudy.azureus2.core3.util.AEMonitor;
import org.gudy.azureus2.core3.util.AESemaphore;
import org.gudy.azureus2.plugins.utils.resourcedownloader.*;

// Referenced classes of package org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader:
//			ResourceDownloaderBaseImpl

public class ResourceDownloaderRetryImpl extends ResourceDownloaderBaseImpl
	implements ResourceDownloaderListener
{

	protected ResourceDownloaderBaseImpl delegate;
	protected int retry_count;
	protected boolean cancelled;
	protected ResourceDownloader current_downloader;
	protected int done_count;
	protected Object result;
	protected AESemaphore done_sem;
	protected long size;

	public ResourceDownloaderRetryImpl(ResourceDownloaderBaseImpl _parent, ResourceDownloader _delegate, int _retry_count)
	{
		super(_parent);
		done_sem = new AESemaphore("RDRretry");
		size = -2L;
		delegate = (ResourceDownloaderBaseImpl)_delegate;
		delegate.setParent(this);
		retry_count = _retry_count;
	}

	public String getName()
	{
		return (new StringBuilder()).append(delegate.getName()).append(", retry=").append(retry_count).toString();
	}

	public long getSize()
		throws ResourceDownloaderException
	{
		if (size != -2L)
			return size;
		int i = 0;
_L1:
		if (i >= retry_count)
			break MISSING_BLOCK_LABEL_105;
		long l;
		ResourceDownloaderBaseImpl c = delegate.getClone(this);
		addReportListener(c);
		size = c.getSize();
		setProperties(c);
		l = size;
		if (size == -2L)
			size = -1L;
		setSize(size);
		return l;
		ResourceDownloaderException e;
		e;
		if (i == retry_count - 1)
			throw e;
		i++;
		  goto _L1
		if (size == -2L)
			size = -1L;
		setSize(size);
		break MISSING_BLOCK_LABEL_165;
		Exception exception;
		exception;
		if (size == -2L)
			size = -1L;
		setSize(size);
		throw exception;
		return size;
	}

	protected void setSize(long l)
	{
		size = l;
		if (size >= 0L)
			delegate.setSize(size);
	}

	public void setProperty(String name, Object value)
		throws ResourceDownloaderException
	{
		setPropertySupport(name, value);
		delegate.setProperty(name, value);
	}

	public ResourceDownloaderBaseImpl getClone(ResourceDownloaderBaseImpl parent)
	{
		ResourceDownloaderRetryImpl c = new ResourceDownloaderRetryImpl(parent, delegate.getClone(this), retry_count);
		c.setSize(size);
		c.setProperties(this);
		return c;
	}

	public InputStream download()
		throws ResourceDownloaderException
	{
		asyncDownload();
		done_sem.reserve();
		if (result instanceof InputStream)
			return (InputStream)result;
		else
			throw (ResourceDownloaderException)result;
	}

	public void asyncDownload()
	{
		this_mon.enter();
		if (done_count == retry_count || cancelled)
		{
			done_sem.release();
			informFailed((ResourceDownloaderException)result);
		} else
		{
			done_count++;
			if (done_count > 1)
				informActivity((new StringBuilder()).append(getLogIndent()).append("  attempt ").append(done_count).append(" of ").append(retry_count).toString());
			current_downloader = delegate.getClone(this);
			current_downloader.addListener(this);
			current_downloader.asyncDownload();
		}
		this_mon.exit();
		break MISSING_BLOCK_LABEL_160;
		Exception exception;
		exception;
		this_mon.exit();
		throw exception;
	}

	public void cancel()
	{
		setCancelled();
		this_mon.enter();
		result = new ResourceDownloaderCancelledException();
		cancelled = true;
		informFailed((ResourceDownloaderException)result);
		done_sem.release();
		if (current_downloader != null)
			current_downloader.cancel();
		this_mon.exit();
		break MISSING_BLOCK_LABEL_81;
		Exception exception;
		exception;
		this_mon.exit();
		throw exception;
	}

	public boolean completed(ResourceDownloader downloader, InputStream data)
	{
		if (informComplete(data))
		{
			result = data;
			done_sem.release();
			return true;
		} else
		{
			return false;
		}
	}

	public void failed(ResourceDownloader downloader, ResourceDownloaderException e)
	{
		result = e;
		asyncDownload();
	}
}

⌨️ 快捷键说明

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