org.gudy.azureus2.core3.torrentdownloader.impl
Class TorrentDownloaderImpl

java.lang.Object
  extended by java.lang.Thread
      extended by org.gudy.azureus2.core3.util.AEThread
          extended by org.gudy.azureus2.core3.torrentdownloader.impl.TorrentDownloaderImpl
All Implemented Interfaces:
Runnable, TorrentDownloader
Direct Known Subclasses:
TorrentDownloaderLoggedImpl

public class TorrentDownloaderImpl
extends AEThread
implements TorrentDownloader

Author:
Tobias Minich

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Fields inherited from interface org.gudy.azureus2.core3.torrentdownloader.TorrentDownloader
STATE_CANCELLED, STATE_DOWNLOADING, STATE_DUPLICATE, STATE_ERROR, STATE_FINISHED, STATE_INIT, STATE_NON_INIT, STATE_START
 
Constructor Summary
TorrentDownloaderImpl()
           
 
Method Summary
 void cancel()
          Cancels the download.
protected  void closeConnection()
           
 boolean equals(Object obj)
           
 boolean getDeleteFileOnCancel()
           
 int getDownloadState()
          Gets the state of the TorrentDownloader.
 String getError()
          Returns the error string if one occured, "Ok" otherwise.
 int getErrorCode()
           
 File getFile()
          Returns the File the TorrentDownloader downloads to.
 byte[] getLastReadBytes()
           
 int getLastReadCount()
           
 int getPercentDone()
          Returns the amount downloaded in per cent.
 String getStatus()
           
 int getTotalRead()
          Returns the amount downloaded in bytes.
 String getURL()
          Returns the URL downloaded from.
 int hashCode()
           
 void init(TorrentDownloaderCallBackInterface _iface, String _url, Proxy _proxy, String _referrer, Map _request_properties, String _file)
           
 boolean isIgnoreReponseCode()
           
 void notifyListener()
           
 void runSupport()
           
 void setDeleteFileOnCancel(boolean deleteFileOnCancel)
           
 void setDownloadPath(String path, String file)
          Changes the path and filename to download to.
 void setDownloadState(int state)
           
 void setError(int errCode, String err)
           
 void setIgnoreReponseCode(boolean ignoreReponseCode)
           
protected  void setStatus(String str)
           
 
Methods inherited from class org.gudy.azureus2.core3.util.AEThread
isOurThread, run, setOurThread, setOurThread
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.gudy.azureus2.core3.torrentdownloader.TorrentDownloader
start
 

Constructor Detail

TorrentDownloaderImpl

public TorrentDownloaderImpl()
Method Detail

init

public void init(TorrentDownloaderCallBackInterface _iface,
                 String _url,
                 Proxy _proxy,
                 String _referrer,
                 Map _request_properties,
                 String _file)

notifyListener

public void notifyListener()

runSupport

public void runSupport()
Specified by:
runSupport in class AEThread

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getError

public String getError()
Description copied from interface: TorrentDownloader
Returns the error string if one occured, "Ok" otherwise.

Specified by:
getError in interface TorrentDownloader

setError

public void setError(int errCode,
                     String err)

getErrorCode

public int getErrorCode()

setStatus

protected void setStatus(String str)

getStatus

public String getStatus()
Specified by:
getStatus in interface TorrentDownloader

getFile

public File getFile()
Description copied from interface: TorrentDownloader
Returns the File the TorrentDownloader downloads to.

Specified by:
getFile in interface TorrentDownloader

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 interface TorrentDownloader

getDownloadState

public int getDownloadState()
Description copied from interface: TorrentDownloader
Gets the state of the TorrentDownloader.

Specified by:
getDownloadState in interface TorrentDownloader

setDownloadState

public void setDownloadState(int state)

getURL

public String getURL()
Description copied from interface: TorrentDownloader
Returns the URL downloaded from.

Specified by:
getURL in interface TorrentDownloader

cancel

public void cancel()
Description copied from interface: TorrentDownloader
Cancels the download.

Specified by:
cancel in interface TorrentDownloader

closeConnection

protected void closeConnection()

setDownloadPath

public void setDownloadPath(String path,
                            String file)
Description copied from interface: TorrentDownloader
Changes the path and filename to download to. You can give null for either to leave it as is. (These are initialized to either the path/filename given via TorrentDownloaderFactory.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 interface TorrentDownloader
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 interface TorrentDownloader

getLastReadBytes

public byte[] getLastReadBytes()
Specified by:
getLastReadBytes in interface TorrentDownloader
Returns:

getLastReadCount

public int getLastReadCount()
Specified by:
getLastReadCount in interface TorrentDownloader
Returns:

setDeleteFileOnCancel

public void setDeleteFileOnCancel(boolean deleteFileOnCancel)
Specified by:
setDeleteFileOnCancel in interface TorrentDownloader

getDeleteFileOnCancel

public boolean getDeleteFileOnCancel()
Specified by:
getDeleteFileOnCancel in interface TorrentDownloader
Returns:

isIgnoreReponseCode

public boolean isIgnoreReponseCode()
Specified by:
isIgnoreReponseCode in interface TorrentDownloader
Returns:

setIgnoreReponseCode

public void setIgnoreReponseCode(boolean ignoreReponseCode)
Specified by:
setIgnoreReponseCode in interface TorrentDownloader