|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.ObjectjBittorrentAPI.Piece
public class Piece
Class representing a piece according to bittorrent definition. The piece is a part of data of the target file(s)
| Field Summary | |
|---|---|
private java.util.TreeMap<java.lang.Integer,java.lang.Integer> |
filesAndoffset
|
private int |
index
Index of the piece within the file(s) |
private int |
length
Length of the piece. |
private java.util.TreeMap<java.lang.Integer,byte[]> |
pieceBlock
Map containing the piece data |
(package private) byte[] |
sha1
SHA1 hash of the piece contained in the torrent file. |
| Constructor Summary | |
|---|---|
Piece(int index,
int length,
int blockSize,
byte[] sha1)
|
|
Piece(int index,
int length,
int blockSize,
byte[] sha1,
java.util.TreeMap<java.lang.Integer,java.lang.Integer> m)
Constructor of a Piece |
|
| Method Summary | |
|---|---|
void |
clearData()
|
byte[] |
data()
Returns the concatenated value of the pieceBlock map. |
java.util.TreeMap |
getFileAndOffset()
|
int |
getIndex()
Return the index of the piece |
int |
getLength()
Returns the length of the piece |
void |
setBlock(int offset,
byte[] data)
Set a block of data at the corresponding offset |
void |
setFileAndOffset(int file,
int offset)
|
java.lang.String |
toString()
Print some information about the Piece |
boolean |
verify()
Verify if the downloaded data corresponds to the original data contained in the torrent by comparing it to the SHA1 hash in the torrent |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private java.util.TreeMap<java.lang.Integer,java.lang.Integer> filesAndoffset
private int index
private int length
private java.util.TreeMap<java.lang.Integer,byte[]> pieceBlock
byte[] sha1
| Constructor Detail |
|---|
public Piece(int index,
int length,
int blockSize,
byte[] sha1)
public Piece(int index,
int length,
int blockSize,
byte[] sha1,
java.util.TreeMap<java.lang.Integer,java.lang.Integer> m)
index - Index of the piecelength - Length of the pieceblockSize - Size of a block of datasha1 - SHA1 hash that must be verified at the end of downloadm - HashTable containing the file(s) this piece belongs to and the index in these| Method Detail |
|---|
public void clearData()
public byte[] data()
public java.util.TreeMap getFileAndOffset()
public int getIndex()
public int getLength()
public void setBlock(int offset,
byte[] data)
offset - Offset of the data within the current piecedata - Data to be set at the given offset
public void setFileAndOffset(int file,
int offset)
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean verify()
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||