com.aelitis.azureus.core.lws
Class LWSDownload

java.lang.Object
  extended by com.aelitis.azureus.core.lws.LWSDownload
All Implemented Interfaces:
Download, DownloadEventNotifier, DownloadStub, Taggable

public class LWSDownload
extends Object
implements Download


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.gudy.azureus2.plugins.download.DownloadStub
DownloadStub.DownloadStubEx, DownloadStub.DownloadStubFile
 
Field Summary
 
Fields inherited from interface org.gudy.azureus2.plugins.download.Download
FLAG_ALLOW_PERMITTED_PEER_SOURCE_CHANGES, FLAG_DISABLE_AUTO_FILE_MOVE, FLAG_DISABLE_IP_FILTER, FLAG_DO_NOT_DELETE_DATA_ON_REMOVE, FLAG_ERROR_REPORTED, FLAG_FORCE_DIRECT_DELETE, FLAG_INITIAL_NETWORKS_SET, FLAG_LIGHT_WEIGHT, FLAG_LOW_NOISE, FLAG_METADATA_DOWNLOAD, FLAG_MOVE_ON_COMPLETION_DONE, FLAG_ONLY_EVER_SEEDED, FLAG_SCAN_INCOMPLETE_PIECES, PR_HIGH_PRIORITY, PR_LOW_PRIORITY, ST_DOWNLOADING, ST_ERROR, ST_NAMES, ST_PREPARING, ST_QUEUED, ST_READY, ST_SEEDING, ST_STOPPED, ST_STOPPING, ST_WAITING
 
Constructor Summary
protected LWSDownload(LightWeightSeed _lws, TRTrackerAnnouncer _announcer)
           
 
Method Summary
 void addActivationListener(DownloadActivationListener l)
          Adds a listener that will be invoked when a request is made to activate a torrent.
 void addAttributeListener(DownloadAttributeListener l, TorrentAttribute attr, int event_type)
          Adds a listener that will be informed of when attributes on a download have been read / modified.
 void addCompletionListener(DownloadCompletionListener l)
          Adds a listener that will be informed when a download moves into a completed state.
 void addDownloadWillBeRemovedListener(DownloadWillBeRemovedListener l)
          Adds a listener that will be informed when a download is about to be removed.
 void addListener(DownloadListener l)
          Adds a listener that will be informed of changes to a download's state.
 void addPeerListener(DownloadPeerListener l)
          Adds a listener that will be informed of when peer managers have been added / removed for a download.
 void addPropertyListener(DownloadPropertyListener l)
          Adds a listener that will be informed of when properties on a download have been read / modified.
 void addRateLimiter(RateLimiter limiter, boolean is_upload)
           
 void addTrackerListener(DownloadTrackerListener l)
          Adds a listener that will be informed when the latest announce/scrape results change.
 void addTrackerListener(DownloadTrackerListener l, boolean immediateTrigger)
          Adds a listener that will be informed when the latest announce/scrape results change.
 SaveLocationChange calculateDefaultDownloadLocation()
          Returns a SaveLocationChange object describing the appropriate location for the download (and torrent file) to exist in, based on the download's completion state, the for-completion rules in place, and the SaveLocationManager object in use.
 File[] calculateDefaultPaths(boolean for_moving)
          Returns an array of size 2 indicating the appropriate locations for this download's data files and torrent file, based on Azureus's rules regarding default save paths, and move on completion rules.
 boolean canBeRemoved()
          Tests whether or not a download can be removed.
 boolean canMoveDataFiles()
          Returns true if Azureus will allow the data files for the torrent to be moved.
 boolean canStubbify()
           
 void changeLocation(SaveLocationChange slc)
          Apply the changes in the given SaveLocationChange object - this includes moving torrent and data file data.
 Download destubbify()
           
 DownloadActivationEvent getActivationState()
          Gives access to the current activation state.
 DownloadScrapeResult getAggregatedScrapeResult()
          Returns an aggregated scrape result of all good results, or if none the same as getLastScrapeResult
 String getAttribute(TorrentAttribute attribute)
          Gets an attribute of this download.
 boolean getBooleanAttribute(TorrentAttribute name)
          Gets the value of the given attribute from the download.
 String getCategoryName()
          Returns the name of the Category
 long getCreationTime()
          returns the time this download was created in milliseconds
 DiskManager getDiskManager()
          Return the disk manager, null if its not running
 int getDiskManagerFileCount()
          Return the number of DiskManagerFile objects
 DiskManagerFileInfo[] getDiskManagerFileInfo()
          Returns info about the torrent's files.
 DiskManagerFileInfo getDiskManagerFileInfo(int i)
          Returns file info for the given index.
 List<DistributedDatabase> getDistributedDatabases()
           
 byte[] getDownloadPeerId()
          Get the local peerID advertised to the download swarm.
 int getDownloadRateLimitBytesPerSecond()
          Get the max download rate allowed for this download.
 String getErrorStateDetails()
          When the download state is ERROR this method returns the error details
 boolean getFlag(long flag)
          Get the flag value
 long getFlags()
          get all the flags as a bitmap
 int getIndex()
          Index of download.
 int getIntAttribute(TorrentAttribute name)
          Gets the value of the given attribute from the download.
 DownloadAnnounceResult getLastAnnounceResult()
          Gives access to the last announce result received from the tracker for the download
 DownloadScrapeResult getLastScrapeResult()
          Gives access to the last scrape result received from the tracker for the download
 String[] getListAttribute(TorrentAttribute attribute)
           
 long getLongAttribute(TorrentAttribute name)
          Gets the value of the given attribute from the download.
 LightWeightSeed getLWS()
           
 Map getMapAttribute(TorrentAttribute attribute)
           
 int getMaximumDownloadKBPerSecond()
          Get the max download rate allowed for this download
 String getName()
          Returns the name of the torrent.
 PeerManager getPeerManager()
          return the current peer manager for the download.
 int getPosition()
          Returns the current position in the queue Completed and Incompleted downloads have seperate position sets.
 DiskManagerFileInfo getPrimaryFile()
          Returns the "Primary" file in the download.
 int getPriority()
          Downloads can either be low or high priority (see PR_ constants above)
 String getSavePath()
          This returns the full save path for the download.
 int getSeedingRank()
          The torrents with the highest rankings will be seeded first.
 int getState()
          get state from above ST_ set
 DownloadStats getStats()
          Gives access to the download's statistics
 DownloadStub.DownloadStubFile[] getStubFiles()
           
 int getSubState()
          For the STOPPING state this method gives the state that is being transited too (STOPPED, QUEUED or ERROR)
 List<Tag> getTags()
           
 Torrent getTorrent()
          Each download has a corresponding torrent
 String getTorrentFileName()
          Returns the full file path and name of the .torrent file
 byte[] getTorrentHash()
           
 long getTorrentSize()
           
 int getUploadRateLimitBytesPerSecond()
          Get the max upload rate allowed for this download.
 Object getUserData(Object key)
          get user-defined key/value
 boolean hasAttribute(TorrentAttribute name)
          Returns true if the download has an explicit value stored for the given attribute.
 void initialize()
          See lifecycle description above
 boolean isChecking()
          When a download is completed it is rechecked (if the option is enabled).
 boolean isComplete()
          Indicates if the download has completed or not, exluding any files marked as Do No Download
 boolean isComplete(boolean bIncludeDND)
          Indicates if the download has completed or not
 boolean isForceStart()
          Retrieves whether the download is force started
 boolean isInDefaultSaveDir()
          Returns true if the download is being saved to one of the default save directories.
 boolean isMessagingEnabled()
          Is advanced AZ messaging enabled for this download.
 boolean isMoving()
          Returns true if the download is currently in the process of having its datafiles moved
 boolean isPaused()
           
 boolean isPersistent()
          Downloads can be persistent (be remembered across Azureus sessions), or non-persistent.
 boolean isPriorityLocked()
          When a download's priority is locked this means that seeding rules should not change a downloads priority, it is under manual control
 boolean isRemoved()
           
 boolean isStartStopLocked()
          When a download is "start-stop locked" it means that seeding rules shouldn't start or stop the download as it is under manual control
 boolean isStub()
           
 void moveDataFiles(File new_parent_dir)
          Move a download's data files to a new location.
 void moveDataFiles(File new_parent_dir, String new_name)
          Move a download's data files to a new location, and rename the download at the same time.
 void moveDown()
          Moves the download down one position
 void moveTo(int position)
          Moves a download and re-orders the others appropriately.
 void moveTorrentFile(File new_parent_dir)
          Move a download's torrent file to a new location.
 void moveUp()
          Moves the download position up one
protected  void notSupported()
           
 void pause()
          Pause the download
 void recheckData()
          Performs a complete recheck of the downloaded data Download must be in stopped, queued or error state Action is performed asynchronously and will progress the download through states PREPARING back to the relevant state
 void remove()
          Removes a download.
 void remove(boolean delete_torrent, boolean delete_data)
          Same as "remove" but, if successful, deletes the torrent and/or data
 void removeActivationListener(DownloadActivationListener l)
          Removes a listener object added via the DownloadEventNotifier.addActivationListener(DownloadActivationListener) method.
 void removeAttributeListener(DownloadAttributeListener l, TorrentAttribute attr, int event_type)
          Removes a listener object added via the {@link #addAttributeListener(DownloadAttributeListener, TorrentAttribute, int) method.
 void removeCompletionListener(DownloadCompletionListener l)
          Removes a listener object removed via the DownloadEventNotifier.addCompletionListener(DownloadCompletionListener) method.
 void removeDownloadWillBeRemovedListener(DownloadWillBeRemovedListener l)
          Removes a listener object added via the DownloadEventNotifier.addDownloadWillBeRemovedListener(DownloadWillBeRemovedListener) method.
 void removeListener(DownloadListener l)
          Removes a listener object added via the #addDownloadListener(DownloadListener) method.
 void removePeerListener(DownloadPeerListener l)
          Removes a listener object added via the DownloadEventNotifier.addPeerListener(DownloadPeerListener) method.
 void removePropertyListener(DownloadPropertyListener l)
          Removes a listener object added via the DownloadEventNotifier.addPropertyListener(DownloadPropertyListener) method.
 void removeRateLimiter(RateLimiter limiter, boolean is_upload)
           
 void removeTrackerListener(DownloadTrackerListener l)
          Removes a listener object added via the DownloadEventNotifier.addTrackerListener(DownloadTrackerListener) or DownloadEventNotifier.addTrackerListener(DownloadTrackerListener, boolean) method.
 void renameDownload(String name)
          Renames the file (for a single file torrent) or directory (for a multi file torrent) where the download is being saved to.
 void requestTrackerAnnounce()
          request a tracker announce
 void requestTrackerAnnounce(boolean immediate)
          request a tracker announce
 void requestTrackerScrape(boolean immediate)
          request a tracker announce
 void restart()
          See lifecycle description above
 void resume()
          Resume the download if paused
 void setAnnounceResult(DownloadAnnounceResult result)
           
 void setAttribute(TorrentAttribute attribute, String value)
          Sets an attribute of this download.
 void setBooleanAttribute(TorrentAttribute name, boolean value)
          Sets a boolean attribute on this download.
 void setCategory(String sName)
          Sets the category for the download
 void setDownloadRateLimitBytesPerSecond(int max_rate_bps)
          Set the max download rate allowed for this download.
 void setFlag(long flag, boolean value)
          Set the flag value.
 void setForceStart(boolean forceStart)
          Set the forcestart state of the download
 void setIntAttribute(TorrentAttribute name, int value)
          Sets an integer attribute on this download.
 void setListAttribute(TorrentAttribute attribute, String[] value)
           
 void setLongAttribute(TorrentAttribute name, long value)
          Sets a long attribute on this download.
 void setMapAttribute(TorrentAttribute attribute, Map value)
           
 void setMaximumDownloadKBPerSecond(int kb)
          Sets the maximum download speed in bytes per second.
 void setMessagingEnabled(boolean enabled)
          Enable or disable advanced AZ messaging for this download.
 void setPosition(int newPosition)
          Sets the position in the queue Completed and Incompleted downloads have seperate position sets
 void setPriority(int priority)
          This method sets a download's priority
 void setScrapeResult(DownloadScrapeResult result)
           
 void setSeedingRank(int rank)
          The torrents with the highest rankings will be seeded first.
 void setUploadRateLimitBytesPerSecond(int max_rate_bps)
          Set the max upload rate allowed for this download.
 void setUserData(Object key, Object data)
          set user defined value.
 void start()
          See lifecycle description above
 void startDownload(boolean force)
          Simple method to start the download.
 void stop()
          See lifecycle description above
 void stopAndQueue()
          See lifecycle description above
 void stopDownload()
          Simple method to stop the download.
 DownloadStub stubbify()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LWSDownload

protected LWSDownload(LightWeightSeed _lws,
                      TRTrackerAnnouncer _announcer)
Method Detail

getLWS

public LightWeightSeed getLWS()

getState

public int getState()
Description copied from interface: Download
get state from above ST_ set

Specified by:
getState in interface Download
Returns:
ST_ constant

getSubState

public int getSubState()
Description copied from interface: Download
For the STOPPING state this method gives the state that is being transited too (STOPPED, QUEUED or ERROR)

Specified by:
getSubState in interface Download
Returns:

getErrorStateDetails

public String getErrorStateDetails()
Description copied from interface: Download
When the download state is ERROR this method returns the error details

Specified by:
getErrorStateDetails in interface Download
Returns:

setFlag

public void setFlag(long flag,
                    boolean value)
Description copied from interface: Download
Set the flag value.

Specified by:
setFlag in interface Download
Parameters:
flag - FLAG value from above
value - true to enable the flag, false to disable it.

getFlag

public boolean getFlag(long flag)
Description copied from interface: Download
Get the flag value

Specified by:
getFlag in interface Download
Parameters:
flag - FLAG value from above
Returns:

getFlags

public long getFlags()
Description copied from interface: Download
get all the flags as a bitmap

Specified by:
getFlags in interface Download
Returns:

getIndex

public int getIndex()
Description copied from interface: Download
Index of download. Download.getPosition()

Specified by:
getIndex in interface Download
Returns:
index - 0 based

calculateDefaultPaths

public File[] calculateDefaultPaths(boolean for_moving)
Description copied from interface: Download
Returns an array of size 2 indicating the appropriate locations for this download's data files and torrent file, based on Azureus's rules regarding default save paths, and move on completion rules.

This method takes one argument - for_moving. This essentially indicates whether you are getting this information for purposes of just finding where Azureus would store these files by default, or whether you are considering moving the files from its current location.

If for_moving is false, this method will determine locations for the download and the torrent file where Azureus would store them by default (it may return the current paths used by this download).

If for_moving is true, then this method will consider the download's current location, and whether it is allowed to move it - you may not be allowed to move this download (based on Azureus's current rules) if the download doesn't exist within a default save directory already. If a download is complete, we consider whether we are allowed to move downloads on completion, and whether that includes downloads outside the default save directory.

In this case, the array may contain null indicating that the Azureus doesn't believe that the download should be moved (based on the current rules the user has set out). However, you are not prevented from changing the location of the torrent file or download.

Specified by:
calculateDefaultPaths in interface Download
Parameters:
for_moving - Indicates whether you want this information for the purposes of moving the download or not.
Returns:
An array of type File of size 2, first element containing the calculated location for the download's data files, and the second element containing the location for the download's torrent file.

calculateDefaultDownloadLocation

public SaveLocationChange calculateDefaultDownloadLocation()
Description copied from interface: Download
Returns a SaveLocationChange object describing the appropriate location for the download (and torrent file) to exist in, based on the download's completion state, the for-completion rules in place, and the SaveLocationManager object in use.

Specified by:
calculateDefaultDownloadLocation in interface Download

isInDefaultSaveDir

public boolean isInDefaultSaveDir()
Description copied from interface: Download
Returns true if the download is being saved to one of the default save directories.

Specified by:
isInDefaultSaveDir in interface Download

getTorrent

public Torrent getTorrent()
Description copied from interface: Download
Each download has a corresponding torrent

Specified by:
getTorrent in interface Download
Specified by:
getTorrent in interface DownloadStub
Returns:
the download's torrent

initialize

public void initialize()
                throws DownloadException
Description copied from interface: Download
See lifecycle description above

Specified by:
initialize in interface Download
Throws:
DownloadException

start

public void start()
           throws DownloadException
Description copied from interface: Download
See lifecycle description above

Specified by:
start in interface Download
Throws:
DownloadException

startDownload

public void startDownload(boolean force)
Description copied from interface: Download
Simple method to start the download. Will not raise an error if it didn't work, or if the download is already running.

Specified by:
startDownload in interface Download
Parameters:
force - true to force the download to be started.

stopDownload

public void stopDownload()
Description copied from interface: Download
Simple method to stop the download. Will not raise an error if it didn't work, or if the download is already stopped.

Specified by:
stopDownload in interface Download

stop

public void stop()
          throws DownloadException
Description copied from interface: Download
See lifecycle description above

Specified by:
stop in interface Download
Throws:
DownloadException

stopAndQueue

public void stopAndQueue()
                  throws DownloadException
Description copied from interface: Download
See lifecycle description above

Specified by:
stopAndQueue in interface Download
Throws:
DownloadException

restart

public void restart()
             throws DownloadException
Description copied from interface: Download
See lifecycle description above

Specified by:
restart in interface Download
Throws:
DownloadException

pause

public void pause()
Description copied from interface: Download
Pause the download

Specified by:
pause in interface Download

resume

public void resume()
Description copied from interface: Download
Resume the download if paused

Specified by:
resume in interface Download

recheckData

public void recheckData()
                 throws DownloadException
Description copied from interface: Download
Performs a complete recheck of the downloaded data Download must be in stopped, queued or error state Action is performed asynchronously and will progress the download through states PREPARING back to the relevant state

Specified by:
recheckData in interface Download
Throws:
DownloadException

isStartStopLocked

public boolean isStartStopLocked()
Description copied from interface: Download
When a download is "start-stop locked" it means that seeding rules shouldn't start or stop the download as it is under manual control

Specified by:
isStartStopLocked in interface Download
Returns:
True if download is locked and should not be started or stopped

isForceStart

public boolean isForceStart()
Description copied from interface: Download
Retrieves whether the download is force started

Specified by:
isForceStart in interface Download
Returns:
True if download is force started. False if not.

setForceStart

public void setForceStart(boolean forceStart)
Description copied from interface: Download
Set the forcestart state of the download

Specified by:
setForceStart in interface Download
Parameters:
forceStart - True - Download will start, despite any Start/Stop rules/limits
False - Turn forcestart state off. Download may or may not stop, depending on Start/Stop rules/limits

getPriority

public int getPriority()
Description copied from interface: Download
Downloads can either be low or high priority (see PR_ constants above)

Specified by:
getPriority in interface Download
Returns:
the download's priority

setPriority

public void setPriority(int priority)
Description copied from interface: Download
This method sets a download's priority

Specified by:
setPriority in interface Download
Parameters:
priority - the required priority, see PR_ constants above

isPriorityLocked

public boolean isPriorityLocked()
Description copied from interface: Download
When a download's priority is locked this means that seeding rules should not change a downloads priority, it is under manual control

Specified by:
isPriorityLocked in interface Download
Returns:
whether it is locked or not

isPaused

public boolean isPaused()
Specified by:
isPaused in interface Download
Returns:

getName

public String getName()
Description copied from interface: Download
Returns the name of the torrent. Similar to Torrent.getName() and is usefull if getTorrent() returns null and you still need the name.

Specified by:
getName in interface Download
Specified by:
getName in interface DownloadStub
Returns:
name of the torrent

getTorrentFileName

public String getTorrentFileName()
Description copied from interface: Download
Returns the full file path and name of the .torrent file

Specified by:
getTorrentFileName in interface Download
Returns:
File name of the torrent.

getAttribute

public String getAttribute(TorrentAttribute attribute)
Description copied from interface: Download
Gets an attribute of this download. For category use the Category torrent attribute

Specified by:
getAttribute in interface Download
Returns:

setAttribute

public void setAttribute(TorrentAttribute attribute,
                         String value)
Description copied from interface: Download
Sets an attribute of this download. For category use the Category torrent attribute

Specified by:
setAttribute in interface Download
Parameters:
attribute - Previously created attribute
value - Value to store. null to remove attribute

getListAttribute

public String[] getListAttribute(TorrentAttribute attribute)
Specified by:
getListAttribute in interface Download

setListAttribute

public void setListAttribute(TorrentAttribute attribute,
                             String[] value)
Specified by:
setListAttribute in interface Download

setMapAttribute

public void setMapAttribute(TorrentAttribute attribute,
                            Map value)
Specified by:
setMapAttribute in interface Download
value - must be bencodable - key is string, value is Map, List, Long or byte[]

getMapAttribute

public Map getMapAttribute(TorrentAttribute attribute)
Specified by:
getMapAttribute in interface Download

setIntAttribute

public void setIntAttribute(TorrentAttribute name,
                            int value)
Description copied from interface: Download
Sets an integer attribute on this download.

Specified by:
setIntAttribute in interface Download

getIntAttribute

public int getIntAttribute(TorrentAttribute name)
Description copied from interface: Download
Gets the value of the given attribute from the download. If no value is set, then 0 will be returned.

Specified by:
getIntAttribute in interface Download

setLongAttribute

public void setLongAttribute(TorrentAttribute name,
                             long value)
Description copied from interface: Download
Sets a long attribute on this download.

Specified by:
setLongAttribute in interface Download
Specified by:
setLongAttribute in interface DownloadStub

getLongAttribute

public long getLongAttribute(TorrentAttribute name)
Description copied from interface: Download
Gets the value of the given attribute from the download. If no value is set, then 0 will be returned.

Specified by:
getLongAttribute in interface Download
Specified by:
getLongAttribute in interface DownloadStub
Returns:

setBooleanAttribute

public void setBooleanAttribute(TorrentAttribute name,
                                boolean value)
Description copied from interface: Download
Sets a boolean attribute on this download.

Specified by:
setBooleanAttribute in interface Download

getBooleanAttribute

public boolean getBooleanAttribute(TorrentAttribute name)
Description copied from interface: Download
Gets the value of the given attribute from the download. If no value is set, then false will be returned.

Specified by:
getBooleanAttribute in interface Download

hasAttribute

public boolean hasAttribute(TorrentAttribute name)
Description copied from interface: Download
Returns true if the download has an explicit value stored for the given attribute.

Specified by:
hasAttribute in interface Download

addAttributeListener

public void addAttributeListener(DownloadAttributeListener l,
                                 TorrentAttribute attr,
                                 int event_type)
Description copied from interface: DownloadEventNotifier
Adds a listener that will be informed of when attributes on a download have been read / modified.

Specified by:
addAttributeListener in interface DownloadEventNotifier
Parameters:
l - The listener to add.
attr - The torrent attribute to be notified about.
event_type - The type of event to be notified of, as defined on DownloadAttributeListener.

removeAttributeListener

public void removeAttributeListener(DownloadAttributeListener l,
                                    TorrentAttribute attr,
                                    int event_type)
Description copied from interface: DownloadEventNotifier
Removes a listener object added via the {@link #addAttributeListener(DownloadAttributeListener, TorrentAttribute, int) method.

Specified by:
removeAttributeListener in interface DownloadEventNotifier
Parameters:
l - The listener to remove.
attr - The torrent attribute which it registered with.
event_type - The type of event which it registered with.

getCategoryName

public String getCategoryName()
Description copied from interface: Download
Returns the name of the Category

Specified by:
getCategoryName in interface Download
Returns:
name of the category

setCategory

public void setCategory(String sName)
Description copied from interface: Download
Sets the category for the download

Specified by:
setCategory in interface Download
Parameters:
sName - Category name

getTags

public List<Tag> getTags()
Specified by:
getTags in interface Download
Returns:

remove

public void remove()
            throws DownloadException,
                   DownloadRemovalVetoException
Description copied from interface: Download
Removes a download. The download must be stopped or in error. Removal may fail if another component does not want the removal to occur - in this case a "veto" exception is thrown

Specified by:
remove in interface Download
Specified by:
remove in interface DownloadStub
Throws:
DownloadException
DownloadRemovalVetoException

remove

public void remove(boolean delete_torrent,
                   boolean delete_data)
            throws DownloadException,
                   DownloadRemovalVetoException
Description copied from interface: Download
Same as "remove" but, if successful, deletes the torrent and/or data

Specified by:
remove in interface Download
Throws:
DownloadException
DownloadRemovalVetoException

isRemoved

public boolean isRemoved()
Specified by:
isRemoved in interface Download
Returns:

getPosition

public int getPosition()
Description copied from interface: Download
Returns the current position in the queue Completed and Incompleted downloads have seperate position sets. This means we can have a position x for Completed, and position x for Incompleted.

Specified by:
getPosition in interface Download

getCreationTime

public long getCreationTime()
Description copied from interface: Download
returns the time this download was created in milliseconds

Specified by:
getCreationTime in interface Download
Returns:

setPosition

public void setPosition(int newPosition)
Description copied from interface: Download
Sets the position in the queue Completed and Incompleted downloads have seperate position sets

Specified by:
setPosition in interface Download

moveUp

public void moveUp()
Description copied from interface: Download
Moves the download position up one

Specified by:
moveUp in interface Download

moveDown

public void moveDown()
Description copied from interface: Download
Moves the download down one position

Specified by:
moveDown in interface Download

moveTo

public void moveTo(int position)
Description copied from interface: Download
Moves a download and re-orders the others appropriately. Note that setPosition does not do this, it merely sets the position thus making it possible, for example, for two downloads to have the same position

Specified by:
moveTo in interface Download

canBeRemoved

public boolean canBeRemoved()
                     throws DownloadRemovalVetoException
Description copied from interface: Download
Tests whether or not a download can be removed. Due to synchronization issues it is possible for a download to report OK here but still fail removal.

Specified by:
canBeRemoved in interface Download
Returns:
Throws:
DownloadRemovalVetoException

setAnnounceResult

public void setAnnounceResult(DownloadAnnounceResult result)
Specified by:
setAnnounceResult in interface Download

setScrapeResult

public void setScrapeResult(DownloadScrapeResult result)
Specified by:
setScrapeResult in interface Download

getLastAnnounceResult

public DownloadAnnounceResult getLastAnnounceResult()
Description copied from interface: Download
Gives access to the last announce result received from the tracker for the download

Specified by:
getLastAnnounceResult in interface Download
Returns:

getLastScrapeResult

public DownloadScrapeResult getLastScrapeResult()
Description copied from interface: Download
Gives access to the last scrape result received from the tracker for the download

Specified by:
getLastScrapeResult in interface Download
Returns:
a non-null DownloadScrapeResult

getAggregatedScrapeResult

public DownloadScrapeResult getAggregatedScrapeResult()
Description copied from interface: Download
Returns an aggregated scrape result of all good results, or if none the same as getLastScrapeResult

Specified by:
getAggregatedScrapeResult in interface Download
Returns:

getActivationState

public DownloadActivationEvent getActivationState()
Description copied from interface: Download
Gives access to the current activation state. Note that we currently only fire the activation listener on an increase in activation requirements. This method however gives the current view of the state and takes into account decreases too

Specified by:
getActivationState in interface Download
Returns:

getStats

public DownloadStats getStats()
Description copied from interface: Download
Gives access to the download's statistics

Specified by:
getStats in interface Download
Returns:

isPersistent

public boolean isPersistent()
Description copied from interface: Download
Downloads can be persistent (be remembered across Azureus sessions), or non-persistent.

Specified by:
isPersistent in interface Download
Returns:
true - persistent
false - non-persistent

setMaximumDownloadKBPerSecond

public void setMaximumDownloadKBPerSecond(int kb)
Description copied from interface: Download
Sets the maximum download speed in bytes per second. 0 -> unlimited

Specified by:
setMaximumDownloadKBPerSecond in interface Download

getMaximumDownloadKBPerSecond

public int getMaximumDownloadKBPerSecond()
Description copied from interface: Download
Get the max download rate allowed for this download

Specified by:
getMaximumDownloadKBPerSecond in interface Download
Returns:
upload rate in KB/s, 0 for unlimited
Since 4.8.1.3: -1 for download disabled

addRateLimiter

public void addRateLimiter(RateLimiter limiter,
                           boolean is_upload)
Specified by:
addRateLimiter in interface Download
Parameters:
limiter - create via ConnectionManager
is_upload - false -> download limit

removeRateLimiter

public void removeRateLimiter(RateLimiter limiter,
                              boolean is_upload)
Specified by:
removeRateLimiter in interface Download

getUploadRateLimitBytesPerSecond

public int getUploadRateLimitBytesPerSecond()
Description copied from interface: Download
Get the max upload rate allowed for this download.

Specified by:
getUploadRateLimitBytesPerSecond in interface Download
Returns:
upload rate in bytes per second, 0 for unlimited, -1 for upload disabled

setUploadRateLimitBytesPerSecond

public void setUploadRateLimitBytesPerSecond(int max_rate_bps)
Description copied from interface: Download
Set the max upload rate allowed for this download.

Specified by:
setUploadRateLimitBytesPerSecond in interface Download
Parameters:
max_rate_bps - limit in bytes per second, 0 for unlimited, -1 for upload disabled

getDownloadRateLimitBytesPerSecond

public int getDownloadRateLimitBytesPerSecond()
Description copied from interface: Download
Get the max download rate allowed for this download.

Specified by:
getDownloadRateLimitBytesPerSecond in interface Download
Returns:
upload rate in bytes per second, 0 for unlimited, -1 for download disabled

setDownloadRateLimitBytesPerSecond

public void setDownloadRateLimitBytesPerSecond(int max_rate_bps)
Description copied from interface: Download
Set the max download rate allowed for this download.

Specified by:
setDownloadRateLimitBytesPerSecond in interface Download
Parameters:
max_rate_bps - limit in bytes per second, 0 for unlimited, -1 for dowmload disabled

isComplete

public boolean isComplete()
Description copied from interface: Download
Indicates if the download has completed or not, exluding any files marked as Do No Download

Specified by:
isComplete in interface Download
Returns:
Download Complete status

isComplete

public boolean isComplete(boolean bIncludeDND)
Description copied from interface: Download
Indicates if the download has completed or not

Specified by:
isComplete in interface Download
Parameters:
bIncludeDND - Whether to include DND files when determining completion state
Returns:
Download Complete status

isChecking

public boolean isChecking()
Description copied from interface: Download
When a download is completed it is rechecked (if the option is enabled). This method returns true during this phase (at which time the status will be seeding)

Specified by:
isChecking in interface Download
Returns:

isMoving

public boolean isMoving()
Description copied from interface: Download
Returns true if the download is currently in the process of having its datafiles moved

Specified by:
isMoving in interface Download
Returns:

getSavePath

public String getSavePath()
Description copied from interface: Download
This returns the full save path for the download. If the download is a simple torrent, this will be the full path of the file being downloaded. If the download is a multiple file torrent, this will be the path to the directory containing all the files in the torrent.

Specified by:
getSavePath in interface Download
Specified by:
getSavePath in interface DownloadStub
Returns:
Full save path for this download.

moveDataFiles

public void moveDataFiles(File new_parent_dir)
                   throws DownloadException
Description copied from interface: Download
Move a download's data files to a new location. Download must be stopped and persistent

If a download is running, it will be automatically paused and resumed afterwards - be aware that this behaviour may generate stateChanged events being fired.

Specified by:
moveDataFiles in interface Download
Throws:
DownloadException

canMoveDataFiles

public boolean canMoveDataFiles()
Description copied from interface: Download
Returns true if Azureus will allow the data files for the torrent to be moved.

Specified by:
canMoveDataFiles in interface Download

moveTorrentFile

public void moveTorrentFile(File new_parent_dir)
                     throws DownloadException
Description copied from interface: Download
Move a download's torrent file to a new location. Download must be stopped and persistent

Specified by:
moveTorrentFile in interface Download
Throws:
DownloadException

renameDownload

public void renameDownload(String name)
                    throws DownloadException
Description copied from interface: Download
Renames the file (for a single file torrent) or directory (for a multi file torrent) where the download is being saved to. The download must be in a state to move the data files to a new location (see Download.moveDataFiles(File)).

This will not rename the displayed name for the torrent - if you wish to do that, you must do it via the TorrentAttribute class.

If a download is running, it will be automatically paused and resumed afterwards - be aware that this behaviour may generate stateChanged events being fired.

Specified by:
renameDownload in interface Download
Parameters:
name - New name for the download.
Throws:
DownloadException
See Also:
Download.moveDataFiles(File)

getPeerManager

public PeerManager getPeerManager()
Description copied from interface: Download
return the current peer manager for the download.

Specified by:
getPeerManager in interface Download
Returns:
null returned if torrent currently doesn't have one (e.g. it is stopped)

getDiskManager

public DiskManager getDiskManager()
Description copied from interface: Download
Return the disk manager, null if its not running

Specified by:
getDiskManager in interface Download
Returns:

getDiskManagerFileInfo

public DiskManagerFileInfo[] getDiskManagerFileInfo()
Description copied from interface: Download
Returns info about the torrent's files. Note that this will return "stub" values if the download isn't running (not including info such as completion status)

Specified by:
getDiskManagerFileInfo in interface Download
Returns:

getDiskManagerFileInfo

public DiskManagerFileInfo getDiskManagerFileInfo(int i)
Description copied from interface: Download
Returns file info for the given index. Note that this will return "stub" values if the download isn't running (not including info such as completion status)

Specified by:
getDiskManagerFileInfo in interface Download
Returns:
null if index is invalid

getDiskManagerFileCount

public int getDiskManagerFileCount()
Description copied from interface: Download
Return the number of DiskManagerFile objects

Specified by:
getDiskManagerFileCount in interface Download
Returns:

requestTrackerAnnounce

public void requestTrackerAnnounce()
Description copied from interface: Download
request a tracker announce

Specified by:
requestTrackerAnnounce in interface Download

requestTrackerAnnounce

public void requestTrackerAnnounce(boolean immediate)
Description copied from interface: Download
request a tracker announce

Specified by:
requestTrackerAnnounce in interface Download

requestTrackerScrape

public void requestTrackerScrape(boolean immediate)
Description copied from interface: Download
request a tracker announce

Specified by:
requestTrackerScrape in interface Download

addListener

public void addListener(DownloadListener l)
Description copied from interface: DownloadEventNotifier
Adds a listener that will be informed of changes to a download's state.

Specified by:
addListener in interface DownloadEventNotifier
Parameters:
l - The listener to add.

removeListener

public void removeListener(DownloadListener l)
Description copied from interface: DownloadEventNotifier
Removes a listener object added via the #addDownloadListener(DownloadListener) method.

Specified by:
removeListener in interface DownloadEventNotifier
Parameters:
l - The listener to remove.

addCompletionListener

public void addCompletionListener(DownloadCompletionListener l)
Description copied from interface: DownloadEventNotifier
Adds a listener that will be informed when a download moves into a completed state.

Specified by:
addCompletionListener in interface DownloadEventNotifier
Parameters:
l - The listener to add.

removeCompletionListener

public void removeCompletionListener(DownloadCompletionListener l)
Description copied from interface: DownloadEventNotifier
Removes a listener object removed via the DownloadEventNotifier.addCompletionListener(DownloadCompletionListener) method.

Specified by:
removeCompletionListener in interface DownloadEventNotifier
Parameters:
l - The listener to remove.

addTrackerListener

public void addTrackerListener(DownloadTrackerListener l)
Description copied from interface: DownloadEventNotifier
Adds a listener that will be informed when the latest announce/scrape results change.

Listener events will be immediately triggered after the listener has been added.

Specified by:
addTrackerListener in interface DownloadEventNotifier
Parameters:
l - The listener to add.

addTrackerListener

public void addTrackerListener(DownloadTrackerListener l,
                               boolean immediateTrigger)
Description copied from interface: DownloadEventNotifier
Adds a listener that will be informed when the latest announce/scrape results change.

Specified by:
addTrackerListener in interface DownloadEventNotifier
Parameters:
l - The listener to add.
immediateTrigger - Whether to immediately trigger listener's events.

removeTrackerListener

public void removeTrackerListener(DownloadTrackerListener l)
Description copied from interface: DownloadEventNotifier
Removes a listener object added via the DownloadEventNotifier.addTrackerListener(DownloadTrackerListener) or DownloadEventNotifier.addTrackerListener(DownloadTrackerListener, boolean) method.

Specified by:
removeTrackerListener in interface DownloadEventNotifier
Parameters:
l - The listener to remove.

addDownloadWillBeRemovedListener

public void addDownloadWillBeRemovedListener(DownloadWillBeRemovedListener l)
Description copied from interface: DownloadEventNotifier
Adds a listener that will be informed when a download is about to be removed. This gives the implementor the opportunity to veto the removal.

Specified by:
addDownloadWillBeRemovedListener in interface DownloadEventNotifier
Parameters:
l - The listener to add.

removeDownloadWillBeRemovedListener

public void removeDownloadWillBeRemovedListener(DownloadWillBeRemovedListener l)
Description copied from interface: DownloadEventNotifier
Removes a listener object added via the DownloadEventNotifier.addDownloadWillBeRemovedListener(DownloadWillBeRemovedListener) method.

Specified by:
removeDownloadWillBeRemovedListener in interface DownloadEventNotifier
Parameters:
l - The listener to remove.

addActivationListener

public void addActivationListener(DownloadActivationListener l)
Description copied from interface: DownloadEventNotifier
Adds a listener that will be invoked when a request is made to activate a torrent.

Specified by:
addActivationListener in interface DownloadEventNotifier
Parameters:
l - The listener to add.

removeActivationListener

public void removeActivationListener(DownloadActivationListener l)
Description copied from interface: DownloadEventNotifier
Removes a listener object added via the DownloadEventNotifier.addActivationListener(DownloadActivationListener) method.

Specified by:
removeActivationListener in interface DownloadEventNotifier
Parameters:
l - The listener to remove.

addPeerListener

public void addPeerListener(DownloadPeerListener l)
Description copied from interface: DownloadEventNotifier
Adds a listener that will be informed of when peer managers have been added / removed for a download.

Specified by:
addPeerListener in interface DownloadEventNotifier
Parameters:
l - The listener to add.

removePeerListener

public void removePeerListener(DownloadPeerListener l)
Description copied from interface: DownloadEventNotifier
Removes a listener object added via the DownloadEventNotifier.addPeerListener(DownloadPeerListener) method.

Specified by:
removePeerListener in interface DownloadEventNotifier
Parameters:
l - The listener to remove.

getSeedingRank

public int getSeedingRank()
Description copied from interface: Download
The torrents with the highest rankings will be seeded first.

Specified by:
getSeedingRank in interface Download
Returns:
Seeding Rank

setSeedingRank

public void setSeedingRank(int rank)
Description copied from interface: Download
The torrents with the highest rankings will be seeded first.

Specified by:
setSeedingRank in interface Download
Parameters:
rank - New Ranking

addPropertyListener

public void addPropertyListener(DownloadPropertyListener l)
Description copied from interface: DownloadEventNotifier
Adds a listener that will be informed of when properties on a download have been read / modified.

Specified by:
addPropertyListener in interface DownloadEventNotifier
Parameters:
l - The listener to add.

removePropertyListener

public void removePropertyListener(DownloadPropertyListener l)
Description copied from interface: DownloadEventNotifier
Removes a listener object added via the DownloadEventNotifier.addPropertyListener(DownloadPropertyListener) method.

Specified by:
removePropertyListener in interface DownloadEventNotifier
Parameters:
l - The listener to remove.

getDownloadPeerId

public byte[] getDownloadPeerId()
Description copied from interface: Download
Get the local peerID advertised to the download swarm.

Specified by:
getDownloadPeerId in interface Download
Returns:
self peer id

isMessagingEnabled

public boolean isMessagingEnabled()
Description copied from interface: Download
Is advanced AZ messaging enabled for this download.

Specified by:
isMessagingEnabled in interface Download
Returns:
true if enabled, false if disabled

setMessagingEnabled

public void setMessagingEnabled(boolean enabled)
Description copied from interface: Download
Enable or disable advanced AZ messaging for this download.

Specified by:
setMessagingEnabled in interface Download
Parameters:
enabled - true to enabled, false to disabled

moveDataFiles

public void moveDataFiles(File new_parent_dir,
                          String new_name)
                   throws DownloadException
Description copied from interface: Download
Move a download's data files to a new location, and rename the download at the same time. Download must be stopped and persistent. This is equivalent to calling moveDataFiles[File] and then renameDownload[String]. For convenience, either argument can be null, but not both.

If a download is running, it will be automatically paused and resumed afterwards - be aware that this behaviour may generate stateChanged events being fired.

Specified by:
moveDataFiles in interface Download
Throws:
DownloadException
See Also:
#moveDataFiles(File)}, #renameDownload(String)}

getUserData

public Object getUserData(Object key)
Description copied from interface: Download
get user-defined key/value

Specified by:
getUserData in interface Download
Returns:

setUserData

public void setUserData(Object key,
                        Object data)
Description copied from interface: Download
set user defined value. this is TRANSIENT and not persisted over Azureus stop/start

Specified by:
setUserData in interface Download

changeLocation

public void changeLocation(SaveLocationChange slc)
                    throws DownloadException
Description copied from interface: Download
Apply the changes in the given SaveLocationChange object - this includes moving torrent and data file data.

Specified by:
changeLocation in interface Download
Parameters:
slc - The change to apply.
Throws:
DownloadException - If there is a problem moving the data.

isStub

public boolean isStub()
Specified by:
isStub in interface DownloadStub

canStubbify

public boolean canStubbify()
Specified by:
canStubbify in interface Download

stubbify

public DownloadStub stubbify()
                      throws DownloadException,
                             DownloadRemovalVetoException
Specified by:
stubbify in interface Download
Throws:
DownloadException
DownloadRemovalVetoException

destubbify

public Download destubbify()
                    throws DownloadException
Specified by:
destubbify in interface DownloadStub
Throws:
DownloadException

getDistributedDatabases

public List<DistributedDatabase> getDistributedDatabases()
Specified by:
getDistributedDatabases in interface Download
Returns:

getTorrentHash

public byte[] getTorrentHash()
Specified by:
getTorrentHash in interface DownloadStub

getTorrentSize

public long getTorrentSize()
Specified by:
getTorrentSize in interface DownloadStub

getStubFiles

public DownloadStub.DownloadStubFile[] getStubFiles()
Specified by:
getStubFiles in interface DownloadStub

notSupported

protected void notSupported()

getPrimaryFile

public DiskManagerFileInfo getPrimaryFile()
Description copied from interface: Download
Returns the "Primary" file in the download. Usually the largest one

Specified by:
getPrimaryFile in interface Download