|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.klomp.snark.MetaInfo
public class MetaInfo
Note: this class is buggy, as it doesn't propogate custom meta fields into the bencoded info data, and from there to the info_hash. At the moment, though, it seems to work with torrents created by I2P-BT, I2PRufus and Azureus.
Constructor Summary | |
---|---|
MetaInfo(BDecoder be)
Creates a new MetaInfo from the given BDecoder. |
|
MetaInfo(java.io.InputStream in)
Creates a new MetaInfo from the given InputStream. |
|
MetaInfo(java.util.Map m)
Creates a new MetaInfo from a Map of BEValues and the SHA1 over the original bencoded info dictonary (this is a hack, we could reconstruct the bencoded stream and recalculate the hash). |
|
MetaInfo(java.lang.String announce,
java.lang.String name,
java.lang.String name_utf8,
java.util.List files,
java.util.List lengths,
int piece_length,
byte[] piece_hashes,
long length)
|
Method Summary | |
---|---|
boolean |
checkPiece(int piece,
byte[] bs,
int off,
int length)
Checks that the given piece has the same SHA1 hash as the given byte array. |
java.lang.String |
getAnnounce()
Returns the string representing the URL of the tracker for this torrent. |
java.util.List |
getFiles()
Returns a list of lists of file name hierarchies or null if it is a single name. |
byte[] |
getInfoHash()
Returns the original 20 byte SHA1 hash over the bencoded info map. |
java.util.List |
getLengths()
Returns a list of Longs indication the size of the individual files, or null if it is a single file. |
java.lang.String |
getName()
Returns the requested name for the file or toplevel directory. |
(package private) byte[] |
getPieceHashes()
Returns the piece hashes. |
int |
getPieceLength(int piece)
Return the length of a piece. |
int |
getPieces()
Returns the number of pieces. |
byte[] |
getTorrentData()
|
long |
getTotalLength()
Returns the total length of the torrent in bytes. |
MetaInfo |
reannounce(java.lang.String announce)
Creates a copy of this MetaInfo that shares everything except the announce URL. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
MetaInfo(java.lang.String announce, java.lang.String name, java.lang.String name_utf8, java.util.List files, java.util.List lengths, int piece_length, byte[] piece_hashes, long length)
public MetaInfo(java.io.InputStream in) throws java.io.IOException
java.io.IOException
public MetaInfo(BDecoder be) throws java.io.IOException
java.io.IOException
public MetaInfo(java.util.Map m) throws InvalidBEncodingException
InvalidBEncodingException
Method Detail |
---|
public java.lang.String getAnnounce()
public byte[] getInfoHash()
byte[] getPieceHashes()
public java.lang.String getName()
public java.util.List getFiles()
public java.util.List getLengths()
public int getPieces()
public int getPieceLength(int piece)
getPieces()-1
).
java.lang.IndexOutOfBoundsException
- when piece is equal to or
greater then the number of pieces in the torrent.public boolean checkPiece(int piece, byte[] bs, int off, int length)
public long getTotalLength()
public java.lang.String toString()
toString
in class java.lang.Object
public MetaInfo reannounce(java.lang.String announce)
public byte[] getTorrentData()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |