Class ResourceDownloaderURLImpl
- java.lang.Object
-
- com.biglybt.pifimpl.local.utils.resourcedownloader.ResourceDownloaderBaseImpl
-
- com.biglybt.pifimpl.local.utils.resourcedownloader.ResourceDownloaderURLImpl
-
- All Implemented Interfaces:
SEPasswordListener
,ResourceDownloader
public class ResourceDownloaderURLImpl extends ResourceDownloaderBaseImpl implements SEPasswordListener
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
auth_supplied
private boolean
auto_plugin_proxy
private static int
BUFFER_SIZE
private boolean
cancel_download
private boolean
download_initiated
private boolean
force_no_proxy
private java.net.Proxy
force_proxy
private java.io.InputStream
input_stream
private static int
MAX_IN_MEM_READ_SIZE
private java.net.URL
original_url
private java.lang.String
password
private byte[]
post_data
private long
size
private java.lang.String
user_name
-
Fields inherited from class com.biglybt.pifimpl.local.utils.resourcedownloader.ResourceDownloaderBaseImpl
this_mon
-
Fields inherited from interface com.biglybt.pif.utils.resourcedownloader.ResourceDownloader
PR_BOOLEAN_ANONYMOUS, PR_STRING_CONTENT_TYPE
-
-
Constructor Summary
Constructors Constructor Description ResourceDownloaderURLImpl(ResourceDownloaderBaseImpl _parent, java.net.URL _url)
ResourceDownloaderURLImpl(ResourceDownloaderBaseImpl _parent, java.net.URL _url, boolean _auth_supplied, java.lang.String _user_name, java.lang.String _password)
ResourceDownloaderURLImpl(ResourceDownloaderBaseImpl _parent, java.net.URL _url, byte[] _data, boolean _auth_supplied, java.lang.String _user_name, java.lang.String _password)
ResourceDownloaderURLImpl(ResourceDownloaderBaseImpl _parent, java.net.URL _url, java.lang.String _user_name, java.lang.String _password)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
asyncDownload()
Asynchronously download.void
cancel()
Cancel the download.void
clearPasswords()
java.io.InputStream
download()
Synchronously download.java.net.PasswordAuthentication
getAuthentication(java.lang.String realm, java.net.URL tracker)
ResourceDownloaderBaseImpl
getClone(ResourceDownloaderBaseImpl parent)
java.lang.String
getName()
Get a sensible name for the download based on its details (e.g.protected void
getRequestProperties(java.net.URLConnection con)
long
getSize()
Attempts to get the size of the download.protected long
getSizeSupport()
protected java.net.URL
getURL()
private java.net.URLConnection
openConnection(java.net.Proxy proxy, java.net.URL url)
void
setAuthenticationOutcome(java.lang.String realm, java.net.URL tracker, boolean success)
protected void
setAutoPluginProxy()
protected void
setForceNoProxy(boolean force_no_proxy)
protected void
setForceProxy(java.net.Proxy proxy)
void
setProperty(java.lang.String name, java.lang.Object value)
protected void
setRequestProperties(java.net.URLConnection con, boolean use_compression)
protected void
setSize(long l)
protected java.lang.String
trimForDisplay(java.net.URL url)
-
Methods inherited from class com.biglybt.pifimpl.local.utils.resourcedownloader.ResourceDownloaderBaseImpl
addChild, addListener, addReportListener, getBooleanProperty, getBooleanProperty, getChildren, getClone, getLCKeyProperties, getLogIndent, getLongProperty, getParent, getProperty, getProperty, getPropertySupport, getStringProperty, getStringPropertySupport, informActivity, informAmountComplete, informComplete, informFailed, informPercentDone, isAnonymous, isCancelled, removeChild, removeListener, reportActivity, reportActivity, reportAmountComplete, reportPercentComplete, setCancelled, setParent, setProperties, setPropertiesSet, setPropertyRecursive, setPropertySupport
-
-
-
-
Field Detail
-
BUFFER_SIZE
private static final int BUFFER_SIZE
- See Also:
- Constant Field Values
-
MAX_IN_MEM_READ_SIZE
private static final int MAX_IN_MEM_READ_SIZE
- See Also:
- Constant Field Values
-
original_url
private java.net.URL original_url
-
auth_supplied
private boolean auth_supplied
-
user_name
private java.lang.String user_name
-
password
private java.lang.String password
-
input_stream
private java.io.InputStream input_stream
-
cancel_download
private boolean cancel_download
-
download_initiated
private boolean download_initiated
-
size
private long size
-
force_no_proxy
private boolean force_no_proxy
-
force_proxy
private java.net.Proxy force_proxy
-
auto_plugin_proxy
private boolean auto_plugin_proxy
-
post_data
private final byte[] post_data
-
-
Constructor Detail
-
ResourceDownloaderURLImpl
public ResourceDownloaderURLImpl(ResourceDownloaderBaseImpl _parent, java.net.URL _url)
-
ResourceDownloaderURLImpl
public ResourceDownloaderURLImpl(ResourceDownloaderBaseImpl _parent, java.net.URL _url, java.lang.String _user_name, java.lang.String _password)
-
ResourceDownloaderURLImpl
public ResourceDownloaderURLImpl(ResourceDownloaderBaseImpl _parent, java.net.URL _url, boolean _auth_supplied, java.lang.String _user_name, java.lang.String _password)
-
ResourceDownloaderURLImpl
public ResourceDownloaderURLImpl(ResourceDownloaderBaseImpl _parent, java.net.URL _url, byte[] _data, boolean _auth_supplied, java.lang.String _user_name, java.lang.String _password)
- Parameters:
_parent
-_url
-_data
- if null, GET will be used, otherwise POST will be used with the data supplied_auth_supplied
-_user_name
-_password
-
-
-
Method Detail
-
setForceNoProxy
protected void setForceNoProxy(boolean force_no_proxy)
-
setForceProxy
protected void setForceProxy(java.net.Proxy proxy)
-
setAutoPluginProxy
protected void setAutoPluginProxy()
-
getURL
protected java.net.URL getURL()
-
getName
public java.lang.String getName()
Description copied from interface:ResourceDownloader
Get a sensible name for the download based on its details (e.g. URL)- Specified by:
getName
in interfaceResourceDownloader
- Returns:
-
getSize
public long getSize() throws ResourceDownloaderException
Description copied from interface:ResourceDownloader
Attempts to get the size of the download. Returns -1 if the size can't be determined.Note: You must not call this method from the reportActivity callback method.
- Specified by:
getSize
in interfaceResourceDownloader
- Throws:
ResourceDownloaderException
-
setSize
protected void setSize(long l)
- Specified by:
setSize
in classResourceDownloaderBaseImpl
-
setProperty
public void setProperty(java.lang.String name, java.lang.Object value) throws ResourceDownloaderException
- Specified by:
setProperty
in interfaceResourceDownloader
- Throws:
ResourceDownloaderException
-
getSizeSupport
protected long getSizeSupport() throws ResourceDownloaderException
- Throws:
ResourceDownloaderException
-
getClone
public ResourceDownloaderBaseImpl getClone(ResourceDownloaderBaseImpl parent)
- Specified by:
getClone
in classResourceDownloaderBaseImpl
-
asyncDownload
public void asyncDownload()
Description copied from interface:ResourceDownloader
Asynchronously download.- Specified by:
asyncDownload
in interfaceResourceDownloader
-
download
public java.io.InputStream download() throws ResourceDownloaderException
Description copied from interface:ResourceDownloader
Synchronously download. Events are still reported to listeners- Specified by:
download
in interfaceResourceDownloader
- Returns:
- Throws:
ResourceDownloaderException
-
cancel
public void cancel()
Description copied from interface:ResourceDownloader
Cancel the download.- Specified by:
cancel
in interfaceResourceDownloader
-
setRequestProperties
protected void setRequestProperties(java.net.URLConnection con, boolean use_compression)
-
getRequestProperties
protected void getRequestProperties(java.net.URLConnection con)
-
getAuthentication
public java.net.PasswordAuthentication getAuthentication(java.lang.String realm, java.net.URL tracker)
- Specified by:
getAuthentication
in interfaceSEPasswordListener
-
setAuthenticationOutcome
public void setAuthenticationOutcome(java.lang.String realm, java.net.URL tracker, boolean success)
- Specified by:
setAuthenticationOutcome
in interfaceSEPasswordListener
-
clearPasswords
public void clearPasswords()
- Specified by:
clearPasswords
in interfaceSEPasswordListener
-
openConnection
private java.net.URLConnection openConnection(java.net.Proxy proxy, java.net.URL url) throws java.io.IOException
- Throws:
java.io.IOException
-
trimForDisplay
protected java.lang.String trimForDisplay(java.net.URL url)
-
-