java.lang.Object
org.klomp.snark.Request
Field Summary
FieldsModifier and TypeFieldDescription(package private) final intLength in bytes.(package private) final intOffset in the piece.private final PartialPieceThe piece this request covers.(package private) longSend time.Constructor Summary
ConstructorsConstructorDescriptionRequest(PartialPiece piece, int off) Dummy Request forPeerState.returnPartialPieces(); len is zero.Request(PartialPiece piece, int off, int len) Creates a new Request.Method Summary
All MethodsModifier and TypeMethodDescriptionbooleanTwo requests are equal if they share the same piece, offset, and length.The PartialPiece this Request is for.intgetPiece()The piece number this Request is for.inthashCode()Hash based on piece number, offset, and length.voidread(DataInputStream din, BandwidthListener bwl) Read from stream.toString()A string representation of the request.
Field Details
piece
The piece this request covers.off
final int offOffset in the piece.len
final int lenLength in bytes.sendTime
long sendTimeSend time.
Constructor Details
Request
Request(PartialPiece piece, int off, int len) Creates a new Request.- Parameters:
piece- Piece number requested.off- the offset in the array.len- the number of bytes requested.
Request
Request(PartialPiece piece, int off) Dummy Request forPeerState.returnPartialPieces(); len is zero.- Parameters:
piece- Piece number requested.off- the offset in the array.
Method Details
read
Read from stream.- Parameters:
din- stream carrying the requested block databwl- listener credited with the downloaded bytes- Throws:
IOException- if the stream ends early or the offset is not a block boundary
getPiece
public int getPiece()The piece number this Request is for.- Returns:
- the index of the piece this request covers
getPartialPiece
hashCode
equals
toString
A string representation of the request.- Overrides:
toStringin classObject- Returns:
- "(piece,off,len)" as the
toString()form