View Javadoc

1   /*
2    *  XNap - A P2P framework and client.
3    *
4    *  See the file AUTHORS for copyright information.
5    *
6    *  This program is free software; you can redistribute it and/or modify
7    *  it under the terms of the GNU General Public License as published by
8    *  the Free Software Foundation.
9    *
10   *  This program is distributed in the hope that it will be useful,
11   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   *  GNU General Public License for more details.
14   *
15   *  You should have received a copy of the GNU General Public License
16   *  along with this program; if not, write to the Free Software
17   *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18   */
19  
20  package org.xnap.transfer;
21  
22  import org.xnap.peer.*;
23  
24  /***
25   * Defines the requirements for classes that can be queued.
26   *
27   * @see TransferQueue
28   */
29  public interface Queueable {
30  
31  	/***
32  	 * Returns the time when the queueable was enqueued in milli seconds.
33  	 */
34  	long getEnqueueTime();
35  	
36      /***
37       * @see Transfer#getFilename()
38       */
39      String getFilename();
40  
41      /***
42       * @see Transfer#getFilesize()
43       */
44      long getFilesize();
45  
46      /***
47       * @see Transfer#getPeer()
48       */
49      Peer getPeer(); 
50  
51  	/***
52  	 * Basically a boost factor. Higher values will yield better queue
53  	 * positions.
54  	 */
55  	int getPriority();
56  
57      /***
58       * Returns the position in the queue.
59       */
60      int getQueuePosition();
61  
62      /***
63       * Invoked by the queue to update the position.
64       *
65       * @param position if 0, the item has been dequeued from the
66       *                 queue and startQueued() has been called.
67       */
68      void setQueuePosition(int position);
69  
70  	/***
71  	 * Invoked by queue once the item moves to the top of the queue and is
72  	 * ready to run.
73  	 *
74  	 * @return true, if item has accepted the running state and should be 
75  	 * dequeued; false, if item wants to remain queued
76  	 */
77  	boolean startTransfer();
78  
79  }