public abstract class AbstractFileSet extends Object
| Modifier and Type | Field and Description |
|---|---|
protected List<FileInfo> |
fileInfos
The file info about all the files which are contained within this
AbstractFileSet |
protected List<Piece> |
pieces
The pieces which contain all the information to complete the downloading of the files.
|
| Constructor and Description |
|---|
AbstractFileSet(int blockSize) |
| Modifier and Type | Method and Description |
|---|---|
int |
countCompletedPieces()
Calculates the amount of pieces which still need to be downloaded
|
long |
countRemainingBytes()
Calculates the amount of bytes which still need to be downloaded
|
abstract byte[] |
getBitfieldBytes()
Gets the have pieces in bitfield format as specified by BEP #3.
|
int |
getBlockSize()
Gets the size of a non-truncated block
|
FileInfo |
getFileForBytes(int pieceIndex,
int blockIndex,
int byteOffset)
Gets the FileInfo for the given piece and block
|
List<FileInfo> |
getFiles()
Creates an unmodifiable view of the list of files in this fileset.
|
Stream<Piece> |
getNeededPieces()
Creates a stream with only the pieces which are not done
|
Piece |
getPiece(int index)
Gets the piece with the given index
|
int |
getPieceCount()
Gets the amount of pieces in this torrent
|
abstract long |
getPieceSize()
Gets the size of a non-truncated piece.
|
long |
getTotalFileSize()
Gets the sum of the file sizes which are defined in this
AbstractFileSet |
boolean |
hasPiece(int pieceIndex)
Checks if this piece has been completed.
|
boolean |
isDone()
Tests if all pieces of this fileset have been completed.
|
void |
setHavingPiece(int pieceIndex)
Marks a piece as completed.
|
protected List<Piece> pieces
protected List<FileInfo> fileInfos
AbstractFileSetpublic boolean hasPiece(int pieceIndex)
pieceIndex - the index of the piecetrue if the piece has been completed, otherwise falseIllegalArgumentException - if the requested piece index is outside of the amount of pieces.public void setHavingPiece(int pieceIndex)
pieceIndex - the index of the pieceNoSuchElementException - if the requested piece index is outside of the amount of pieces.public FileInfo getFileForBytes(int pieceIndex, int blockIndex, int byteOffset)
pieceIndex - The piece indexblockIndex - The block index within the piecebyteOffset - The offset within the blockIllegalArgumentException - When information being requested is outside of this fileset.public Piece getPiece(int index)
index - The index of the piece to getIllegalArgumentException - if the index is outside of the files.public abstract long getPieceSize()
public int getBlockSize()
public boolean isDone()
true when all pieces are done an verified, otherwise falsepublic Stream<Piece> getNeededPieces()
public int getPieceCount()
public long getTotalFileSize()
AbstractFileSetpublic long countRemainingBytes()
public int countCompletedPieces()
public abstract byte[] getBitfieldBytes()
UnsupportedOperationException - When this implementation doesn't produce the Bitfield as defined in BEP #3.Copyright © 2016. All rights reserved.