Comparable<PartialPiece>
class PartialPiece extends Object implements Comparable<PartialPiece>
Constructor | Description |
---|---|
PartialPiece(Piece piece,
int len,
File tempDir) |
Used by PeerCoordinator.
|
Modifier and Type | Method | Description |
---|---|---|
int |
compareTo(PartialPiece opp) |
|
boolean |
equals(Object o) |
Make this simple so PeerCoordinator can keep a List.
|
int |
getDownloaded() |
How many bytes are good - as set by setDownloaded() or read()
|
byte[] |
getHash() |
Piece must be complete.
|
int |
getLength() |
|
int |
getPiece() |
piece number
|
Request |
getRequest() |
Convert this PartialPiece to a request for the next chunk.
|
int |
hashCode() |
|
void |
read(DataInputStream din,
int offset,
int len) |
Blocking.
|
void |
release() |
Release all resources.
|
void |
setDownloaded(int offset) |
Call this if necessary before returning a PartialPiece to the PeerCoordinator.
|
String |
toString() |
|
void |
write(DataOutput out,
int offset,
int len) |
Piece must be complete.
|
public PartialPiece(Piece piece, int len, File tempDir)
piece
- Piece number requested.len
- must be equal to the piece lengthpublic Request getRequest()
public int getPiece()
public int getLength()
public int getDownloaded()
public void setDownloaded(int offset)
public byte[] getHash() throws IOException
IOException
public void read(DataInputStream din, int offset, int len) throws IOException
IOException
public void write(DataOutput out, int offset, int len) throws IOException
out
- stream to write tooffset
- offset in the piecelen
- length to writeIOException
public void release()
public int compareTo(PartialPiece opp)
compareTo
in interface Comparable<PartialPiece>
public boolean equals(Object o)