📄 resourcedownloaderfactoryimpl.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: ResourceDownloaderFactoryImpl.java
package org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader;
import java.io.File;
import java.net.*;
import java.util.List;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.plugins.utils.resourcedownloader.*;
// Referenced classes of package org.gudy.azureus2.pluginsimpl.local.utils.resourcedownloader:
// ResourceDownloaderAlternateImpl, ResourceDownloaderBaseImpl, ResourceDownloaderDelayedImpl, ResourceDownloaderFileImpl,
// ResourceDownloaderMetaRefreshImpl, ResourceDownloaderRetryImpl, ResourceDownloaderTimeoutImpl, ResourceDownloaderTorrentImpl,
// ResourceDownloaderURLImpl
public class ResourceDownloaderFactoryImpl
implements ResourceDownloaderFactory
{
private static final LogIDs LOGID;
protected static ResourceDownloaderFactoryImpl singleton = new ResourceDownloaderFactoryImpl();
private static final String SF_MIRRORS[] = {
"jaist", "nchc", "keihanna", "optusnet", "peterhost", "ovh", "puzzle", "switch", "mesh", "kent",
"surfnet", "heanet", "citkit", "internap", "cogent", "umn", "easynews", "ufpr"
};
public ResourceDownloaderFactoryImpl()
{
}
public static ResourceDownloaderFactory getSingleton()
{
return singleton;
}
public ResourceDownloader create(File file)
{
return new ResourceDownloaderFileImpl(null, file);
}
public ResourceDownloader create(URL url)
{
if (!url.getProtocol().equalsIgnoreCase("file"))
break MISSING_BLOCK_LABEL_50;
return new ResourceDownloaderFileImpl(null, new File(new URI(url.toString())));
Throwable e;
e;
return new ResourceDownloaderURLImpl(null, url);
return new ResourceDownloaderURLImpl(null, url);
}
public ResourceDownloader create(URL url, boolean force_no_proxy)
{
ResourceDownloader rd = create(url);
if (force_no_proxy && (rd instanceof ResourceDownloaderURLImpl))
((ResourceDownloaderURLImpl)rd).setForceNoProxy(force_no_proxy);
return rd;
}
public ResourceDownloader create(URL url, String postData)
{
return new ResourceDownloaderURLImpl(null, url, postData, false, null, null);
}
public ResourceDownloader create(URL url, String user_name, String password)
{
return new ResourceDownloaderURLImpl(null, url, user_name, password);
}
public ResourceDownloader create(ResourceDownloaderDelayedFactory factory)
{
return new ResourceDownloaderDelayedImpl(null, factory);
}
public ResourceDownloader getRetryDownloader(ResourceDownloader downloader, int retry_count)
{
ResourceDownloader res = new ResourceDownloaderRetryImpl(null, downloader, retry_count);
return res;
}
public ResourceDownloader getTimeoutDownloader(ResourceDownloader downloader, int timeout_millis)
{
ResourceDownloader res = new ResourceDownloaderTimeoutImpl(null, downloader, timeout_millis);
return res;
}
public ResourceDownloader getAlternateDownloader(ResourceDownloader downloaders[])
{
return getAlternateDownloader(downloaders, -1, false);
}
public ResourceDownloader getAlternateDownloader(ResourceDownloader downloaders[], int max_to_try)
{
return getAlternateDownloader(downloaders, max_to_try, false);
}
public ResourceDownloader getRandomDownloader(ResourceDownloader downloaders[])
{
return getAlternateDownloader(downloaders, -1, true);
}
public ResourceDownloader getRandomDownloader(ResourceDownloader downloaders[], int max_to_try)
{
return getAlternateDownloader(downloaders, max_to_try, true);
}
protected ResourceDownloader getAlternateDownloader(ResourceDownloader downloaders[], int max_to_try, boolean random)
{
ResourceDownloader res = new ResourceDownloaderAlternateImpl(null, downloaders, max_to_try, random);
return res;
}
public ResourceDownloader getMetaRefreshDownloader(ResourceDownloader downloader)
{
ResourceDownloader res = new ResourceDownloaderMetaRefreshImpl(null, downloader);
return res;
}
public ResourceDownloader getTorrentDownloader(ResourceDownloader downloader, boolean persistent)
{
return getTorrentDownloader(downloader, persistent, null);
}
public ResourceDownloader getTorrentDownloader(ResourceDownloader downloader, boolean persistent, File download_directory)
{
return new ResourceDownloaderTorrentImpl(null, downloader, persistent, download_directory);
}
public ResourceDownloader getSuffixBasedDownloader(ResourceDownloader _downloader)
{
ResourceDownloaderBaseImpl dl = (ResourceDownloaderBaseImpl)_downloader;
URL target = null;
do
{
List kids = dl.getChildren();
if (kids.size() == 0)
{
target = ((ResourceDownloaderURLImpl)dl).getURL();
break;
}
dl = (ResourceDownloaderBaseImpl)kids.get(0);
} while (true);
if (target == null)
{
if (Logger.isEnabled())
Logger.log(new LogEvent(LOGID, "ResourceDownloader: suffix based downloader failed to find leaf"));
return _downloader;
}
if (target.getPath().toLowerCase().endsWith(".torrent"))
return getTorrentDownloader(_downloader, true);
else
return _downloader;
}
public ResourceDownloader[] getSourceforgeDownloaders(String project_name, String filename)
{
String template = (new StringBuilder()).append("http://%s.dl.sourceforge.net/sourceforge/").append(project_name).append("/").append(filename).toString();
ResourceDownloader result[] = new ResourceDownloader[SF_MIRRORS.length];
for (int i = 0; i < result.length; i++)
{
String url = template.replaceFirst("%s", SF_MIRRORS[i]);
try
{
result[i] = create(new URL(url));
}
catch (MalformedURLException me)
{
throw new RuntimeException(me);
}
}
return result;
}
public ResourceDownloader getSourceforgeDownloader(String project_name, String filename)
{
return getRandomDownloader(getSourceforgeDownloaders(project_name, filename));
}
static
{
LOGID = LogIDs.CORE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -