⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 download.java

📁 这是一个基于java编写的torrent的P2P源码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
	public int
	getPosition();
	
		/**
		 * returns the time this download was created in milliseconds
		 * @return
		 */
	
	public long
	getCreationTime();
	
	/**
	 * Sets the position in the queue
	 * Completed and Incompleted downloads have seperate position sets
   *
   * @since 2.0.8.0
	 */
	public void
	setPosition(
		int newPosition);

	/**
	 * Moves the download position up one
   *
   * @since 2.1.0.0
	 */
	public void
	moveUp();
	
	/**
	 * Moves the download down one position
   *
   * @since 2.1.0.0
	 */
	public void
	moveDown();
	
		/**
		 * 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 
		 * @param position
		 * @since 2.3.0.7
		 */
	
	public void
	moveTo(
		int		position );
	
	/**
	 * 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.
	 * @return
	 * @throws DownloadRemovalVetoException
   *
   * @since 2.0.7.0
	 */
	public boolean
	canBeRemoved()
	
		throws DownloadRemovalVetoException;
	
	public void
	setAnnounceResult(
		DownloadAnnounceResult	result );
	
	public void
	setScrapeResult(
		DownloadScrapeResult	result );
	
	/**
	 * Gives access to the last announce result received from the tracker for the download
	 * @return
   *
   * @since 2.0.7.0
	 */
	
	public DownloadAnnounceResult
	getLastAnnounceResult();
	
	/**
	 * Gives access to the last scrape result received from the tracker for the download
	 * @return a non-null DownloadScrapeResult
   *
   * @since 2.0.7.0
	 */
	public DownloadScrapeResult
	getLastScrapeResult();
	
	/**
	 * 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
	 * @return
	 * @since 2.4.0.3
	 */
	
	public DownloadActivationEvent
	getActivationState();
	
	/**
	 * Gives access to the download's statistics
	 * @return
   *
   * @since 2.0.7.0
	 */
	public DownloadStats
	getStats();
	
	/** Downloads can be persistent (be remembered accross Azureus sessions), or
	 * non-persistent.
	 *
	 * @return true - persistent<br>
	 *         false - non-persistent
     *
     * @since 2.1.0.0
	 */
	
    public boolean
    isPersistent();
  
    /**
     * Sets the maximum download speed in bytes per second. 0 -> unlimited
     * @since 2.1.0.2
     * @param kb
     */
    
  	public void
	setMaximumDownloadKBPerSecond(
		int		kb );
  	
  	public int
	getMaximumDownloadKBPerSecond();
    
    
    /**
     * Get the max upload rate allowed for this download.
     * @return upload rate in bytes per second, 0 for unlimited, -1 for upload disabled
     */
    public int getUploadRateLimitBytesPerSecond();
    
    /**
     * Set the max upload rate allowed for this download.
     * @param max_rate_bps limit in bytes per second, 0 for unlimited, -1 for upload disabled
     */
    public void setUploadRateLimitBytesPerSecond( int max_rate_bps );
    

	/**
	 * Indicates if the download has completed or not, exluding any files marked
	 * as Do No Download
	 *  
	 * @return Download Complete status
	 * @since 2.1.0.4
	 */
	public boolean isComplete();

	/**
	 * Indicates if the download has completed or not
	 *  
	 * @param bIncludeDND Whether to include DND files when determining 
	 *                     completion state
	 * @return Download Complete status
	 * 
	 * @since 2.4.0.3
	 */
	public boolean isComplete(boolean bIncludeDND);

  		/**
  		 * 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)
  		 * @return
  		 * @since 2.3.0.6
  		 */
  	
	public boolean
 	isChecking();
	
	/**
	 * 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.
	 * 
	 * @return Full save path for this download.
	 */
  	public String
	getSavePath();
  	
  		/**
  		 * Move a download's data files to a new location. Download must be stopped and persistent
  		 * @since 2.3.0.5
  		 * @param new_parent_dir
  		 * @throws DownloadException
  		 */
  	
  	public void
  	moveDataFiles(
  		File	new_parent_dir )
  	
  		throws DownloadException;
  	
  		/**
		 * Move a download's torrent file to a new location. Download must be stopped and persistent
		 * @since 2.3.0.5
		 * @param new_parent_dir
		 * @throws DownloadException
		 */
  	public void
  	moveTorrentFile(
  		File	new_parent_dir ) 
  	
  		throws DownloadException;

  	/**
  	 * 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 {@link #moveDataFiles(File)}).
  	 * 
  	 * <p>
  	 * 
  	 * This will not rename the displayed name for the torrent - if you wish to do that, you must do it via
  	 * the {@link org.gudy.azureus2.plugins.torrent.TorrentAttribute TorrentAttribute} class.
  	 * 
  	 * @param name New name for the download.
  	 * @see #moveDataFiles(File)
  	 */
  	public void renameDownload(String name) throws DownloadException;
  	
  		/**
  		 * return the current peer manager for the download. 
  		 * @return	null returned if torrent currently doesn't have one (e.g. it is stopped)
  		 */
  	
  	public PeerManager
	getPeerManager();
  	
		/**
		 * Return the disk manager, null if its not running
		 * @return
		 * @since 2.3.0.1
		 */
	
	public DiskManager
	getDiskManager();
	
		/**
		 * 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)
		 * @return
		 * @since 2.3.0.1
		 */
	
	public DiskManagerFileInfo[]
	getDiskManagerFileInfo();
	
  		/**
  		 * request a tracker announce 
  		 * @since 2.1.0.5
  		 */
  	
  	public void
	requestTrackerAnnounce();
  	
  		/**
		 * request a tracker announce 
		 * @since 2.3.0.7
		 */
  	
 	public void
	requestTrackerAnnounce(
		boolean		immediate );
 	
		/**
		 * request a tracker announce 
		 * @since 2.3.0.7
		 */
 	
	public void
	requestTrackerScrape(
		boolean		immediate );
	
	/**
	 * Adds a listener to the download that will be informed of changes in the download's state
	 * @param l
   *
   * @since 2.0.7.0
	 */
	public void
	addListener(
		DownloadListener	l );
	
	/**
	 * Removes listeners added above
	 * @param l
   *
   * @since 2.0.7.0
	 */
	public void
	removeListener(
		DownloadListener	l );

	/**
	 * Adds a listener that will be informed when the latest announce/scrape results change.
	 * <p>
	 * listener events will be immediately triggered after listener is added
	 * 
	 * @param l
   *
   * @since 2.0.7.0
	 */
	public void
	addTrackerListener(
		DownloadTrackerListener	l );
	
	/**
	 * Adds a listener that will be informed when the latest announce/scrape results change
	 *  
	 * @param l Listener to add
	 * @param immediateTrigger Whether to immediately trigger listener's events
   *
   * @since 2.4.0.3
	 */
	void addTrackerListener(DownloadTrackerListener l, boolean immediateTrigger);
  
	/**
	 * Removes listeners added above
	 * @param l
   *
   * @since 2.0.7.0
	 */
	public void
	removeTrackerListener(
		DownloadTrackerListener	l );
	
	/**
	 * 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
	 * @param l
   *
   * @since 2.0.7.0
	 */
	public void
	addDownloadWillBeRemovedListener(
		DownloadWillBeRemovedListener	l );
	
	/**
	 * Removes the listener added above
	 * @param l
   *
   * @since 2.0.7.0
	 */
	public void
	removeDownloadWillBeRemovedListener(
		DownloadWillBeRemovedListener	l );
	
		/**
		 * Add a listener that will be invoked when a request is made to activate a torrent
		 * @param l
		 * @since 2403
		 */
	
	public void
	addActivationListener(
		DownloadActivationListener		l );
	
		/**
		 * Remove a listener that will be invoked when a request is made to activate a torrent
		 * @param l
		 * @since 2403
		 */
	
	public void
	removeActivationListener(
		DownloadActivationListener		l );
	
	/**
	 * Adds a listener to the download that will be informed of 
	 * @param l
   *
   * @since 2.1.0.0
	 */
	public void
	addPeerListener(
		DownloadPeerListener	l );
	
	/**
	 * Removes listeners added above
	 * @param l
   *
   * @since 2.1.0.0
	 */
	public void
	removePeerListener(
		DownloadPeerListener	l );

	/**
	 * The torrents with the highest rankings will be seeded first.
	 * 
	 * @return Seeding Rank
	 */
	public int getSeedingRank();

	/**
	 * The torrents with the highest rankings will be seeded first.
	 * 
	 * @param rank New Ranking
	 */
	public void setSeedingRank(int rank);
  
	public void
	addPropertyListener(
		DownloadPropertyListener	l );
	
	public void
	removePropertyListener(
		DownloadPropertyListener	l );
	
  /**
   * Get the local peerID advertised to the download swarm.
   * @return self peer id
   * 
   * @since 2.1.0.5
   */
  public byte[] getDownloadPeerId();
  
  /**
   * Is advanced AZ messaging enabled for this download.
   * @return true if enabled, false if disabled
   */
  public boolean isMessagingEnabled();
  
  /**
   * Enable or disable advanced AZ messaging for this download.
   * @param enabled true to enabled, false to disabled
   */
  public void setMessagingEnabled( boolean enabled );
  
  
  /**
   * Set the authenticator that will be used by this download to handle secure torrent session
   * handshaking and data encryption/decryption.
   * @param auth handler
   */
  public void setSessionAuthenticator( SessionAuthenticator auth );
  
  /**
   * 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.
   * 
   * <p>
   * 
   * This method takes one argument - <i>for_moving</i>. 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.
   * 
   * <p>
   * 
   * If <i>for_moving</i> is <tt>false</tt>, 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). 
   * 
   * <p>
   * 
   * If <i>for_moving</i> is <tt>true</tt>, 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.
   * 
   * <p>
   * 
   * In this case, the array may contain <tt>null</tt> 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.
   * 
   * @since 2.5.0.2
   * @param for_moving Indicates whether you want this information for the purposes
   *     of moving the download or not.
   * @author amc1
   * @return An array of type <tt>File</tt> 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.
   */
  public File[] calculateDefaultPaths(boolean for_moving);
  
  /**
   * Returns <tt>true</tt> if the download is being saved to one of the default
   * save directories.
   * 
   * @since 2.5.0.2
   * @author amc1
   */
  public boolean isInDefaultSaveDir();


}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -