public class UtMetadata extends ExtendedMessage
Modifier and Type | Class and Description |
---|---|
static class |
UtMetadata.Type |
Modifier and Type | Method and Description |
---|---|
static UtMetadata |
data(int pieceIndex,
int totalSize,
byte[] data)
Create metadata response for a given piece.
|
Optional<byte[]> |
getData() |
int |
getPieceIndex() |
Optional<Integer> |
getTotalSize() |
UtMetadata.Type |
getType() |
static UtMetadata |
reject(int pieceIndex)
Create metadata rejection response for a given piece.
|
static UtMetadata |
request(int pieceIndex)
Create metadata request for a given piece.
|
String |
toString() |
getMessageId
public static UtMetadata request(int pieceIndex)
pieceIndex
- Piece index, non-negativepublic static UtMetadata data(int pieceIndex, int totalSize, byte[] data)
pieceIndex
- Piece index, non-negativetotalSize
- Total size of the torrent's metadata, in bytesdata
- Requested piece's datapublic static UtMetadata reject(int pieceIndex)
pieceIndex
- Piece index, non-negativepublic UtMetadata.Type getType()
public int getPieceIndex()
public Optional<byte[]> getData()
getType()
is UtMetadata.Type.DATA
,
or Optional.empty()
otherwisepublic Optional<Integer> getTotalSize()
getType()
is UtMetadata.Type.DATA
,
or Optional.empty()
otherwiseCopyright © 2016–2021. All rights reserved.