1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.plugin.azureus;
21
22 import org.gudy.azureus2.core3.peer.PEPeerManager;
23 import org.gudy.azureus2.core3.peer.PEPiece;
24 import org.gudy.azureus2.plugins.peers.PeerManager;
25 import org.xnap.transfer.Segment;
26
27 /***
28 * <p>The end of the segment can change through a split.
29 */
30 public class AzureusSegment implements Segment {
31
32
33
34 /***
35 * The minimun size for a single segment.
36 */
37 public static final long MIN_SEGEMENT_SIZE = 100 * 1024;
38
39
40
41 private AzureusDownloadContainer parent;
42 private PEPiece piece;
43
44
45
46 public AzureusSegment(AzureusDownloadContainer parent, PEPiece piece)
47 {
48 this.parent = parent;
49 this.piece = piece;
50 }
51
52 public int getAvailability()
53 {
54 return 128;
55 }
56
57 /***
58 * @see org.xnap.transfer.Segment#getEnd()
59 */
60 public long getEnd()
61 {
62 return piece.getLength();
63 }
64
65 /***
66 * @see org.xnap.transfer.Segment#getStart()
67 */
68 public long getStart()
69 {
70 return piece.getPieceNumber() * PEPeerManager.BLOCK_SIZE;
71 }
72
73 /***
74 * @see org.xnap.transfer.Segment#getTotal()
75 */
76 public long getTotal()
77 {
78 return parent.getFilesize();
79 }
80
81 /***
82 * @see org.xnap.transfer.Segment#getTransferred()
83 */
84 public long getTransferred()
85 {
86 return piece.getCompleted() * PEPeerManager.BLOCK_SIZE;
87 }
88
89
90
91 }