Class TorrentDownloaderImpl
java.lang.Object
java.lang.Thread
com.biglybt.core.util.AEThread
com.biglybt.core.torrentdownloader.impl.TorrentDownloaderImpl
- All Implemented Interfaces:
TorrentDownloader
,Runnable
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]
private int
private boolean
private URLConnection
private boolean
private String
private int
private String
private File
private String
private String
private boolean
private String
private int
private Proxy
private int
private String
private Map
private int
private String
(package private) final AEMonitor
private static final AtomicLong
private URL
private String
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Fields inherited from interface com.biglybt.core.torrentdownloader.TorrentDownloader
STATE_CANCELLED, STATE_DOWNLOADING, STATE_DUPLICATE, STATE_ERROR, STATE_FINISHED, STATE_INIT, STATE_NON_INIT, STATE_START
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel()
Cancels the download.private void
protected void
boolean
private void
boolean
int
Gets the state of the TorrentDownloader.getError()
Returns the error string if one occured, "Ok" otherwise.int
getFile()
Returns theFile
the TorrentDownloader downloads to.byte[]
int
int
Returns the amount downloaded in per cent.int
Returns the amount downloaded in bytes.getURL()
Returns the URL downloaded from.int
hashCode()
void
init
(TorrentDownloaderCallBackInterface _iface, String _url, Proxy _proxy, String _referrer, Map _request_properties, String _file) boolean
void
void
void
setDeleteFileOnCancel
(boolean deleteFileOnCancel) void
setDownloadPath
(String path, String file) Changes the path and filename to download to.void
setDownloadState
(int state) void
void
setIgnoreReponseCode
(boolean ignoreReponseCode) protected void
Methods inherited from class com.biglybt.core.util.AEThread
isOurThread, run, setOurThread, setOurThread
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, start, startVirtualThread, stop, suspend, threadId, toString, yield
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.biglybt.core.torrentdownloader.TorrentDownloader
start
-
Field Details
-
uid
-
original_url
-
url_str
-
proxy
-
referrer
-
request_properties
-
file_str
-
url
-
con
-
error
-
status
-
iface
-
state
private int state -
percentDone
private int percentDone -
readTotal
private int readTotal -
cancel
private boolean cancel -
filename
-
directoryname
-
file
-
buf
private final byte[] buf -
bufBytes
private int bufBytes -
deleteFileOnCancel
private boolean deleteFileOnCancel -
ignoreReponseCode
private boolean ignoreReponseCode -
this_mon
-
errCode
private int errCode
-
-
Constructor Details
-
TorrentDownloaderImpl
public TorrentDownloaderImpl()
-
-
Method Details
-
init
-
notifyListener
public void notifyListener() -
cleanUpFile
private void cleanUpFile() -
error
-
runSupport
public void runSupport()- Specified by:
runSupport
in classAEThread
-
equals
-
hashCode
public int hashCode() -
getError
Description copied from interface:TorrentDownloader
Returns the error string if one occured, "Ok" otherwise.- Specified by:
getError
in interfaceTorrentDownloader
-
setError
-
getErrorCode
public int getErrorCode() -
setStatus
-
getStatus
- Specified by:
getStatus
in interfaceTorrentDownloader
-
getFile
Description copied from interface:TorrentDownloader
Returns theFile
the TorrentDownloader downloads to.- Specified by:
getFile
in interfaceTorrentDownloader
-
getPercentDone
public int getPercentDone()Description copied from interface:TorrentDownloader
Returns the amount downloaded in per cent. Gives -1 if total size is not available.- Specified by:
getPercentDone
in interfaceTorrentDownloader
-
getDownloadState
public int getDownloadState()Description copied from interface:TorrentDownloader
Gets the state of the TorrentDownloader.- Specified by:
getDownloadState
in interfaceTorrentDownloader
-
setDownloadState
public void setDownloadState(int state) -
getURL
Description copied from interface:TorrentDownloader
Returns the URL downloaded from.- Specified by:
getURL
in interfaceTorrentDownloader
-
cancel
public void cancel()Description copied from interface:TorrentDownloader
Cancels the download.- Specified by:
cancel
in interfaceTorrentDownloader
-
closeConnection
protected void closeConnection() -
setDownloadPath
Description copied from interface:TorrentDownloader
Changes the path and filename to download to. You can givenull
for either to leave it as is. (These are initialized to either the path/filename given viaTorrentDownloaderFactory.download(Managed)
or to the default torrent save directory (path) and the filename the server proposes (file). This function does nothing after the download has been started.- Specified by:
setDownloadPath
in interfaceTorrentDownloader
- Parameters:
path
- The path for download.file
- The file name for download.
-
getTotalRead
public int getTotalRead()Description copied from interface:TorrentDownloader
Returns the amount downloaded in bytes.- Specified by:
getTotalRead
in interfaceTorrentDownloader
-
getLastReadBytes
public byte[] getLastReadBytes()- Specified by:
getLastReadBytes
in interfaceTorrentDownloader
- Returns:
-
getLastReadCount
public int getLastReadCount()- Specified by:
getLastReadCount
in interfaceTorrentDownloader
- Returns:
-
setDeleteFileOnCancel
public void setDeleteFileOnCancel(boolean deleteFileOnCancel) - Specified by:
setDeleteFileOnCancel
in interfaceTorrentDownloader
- Parameters:
deleteFileOnCancel
-
-
getDeleteFileOnCancel
public boolean getDeleteFileOnCancel()- Specified by:
getDeleteFileOnCancel
in interfaceTorrentDownloader
- Returns:
-
isIgnoreReponseCode
public boolean isIgnoreReponseCode()- Specified by:
isIgnoreReponseCode
in interfaceTorrentDownloader
- Returns:
-
setIgnoreReponseCode
public void setIgnoreReponseCode(boolean ignoreReponseCode) - Specified by:
setIgnoreReponseCode
in interfaceTorrentDownloader
- Parameters:
ignoreReponseCode
-
-