ch.claudio.trial.torrent
Class Metainfo

java.lang.Object
  extended by ch.claudio.trial.torrent.Metainfo

public class Metainfo
extends java.lang.Object

Structure of files: List> files value of files is a list. each value of the list is a dictionary containing length and path int length=(int)files[i].get("length"); String[] path=(String[])files[i].get("path") length is an int path is a list of strings.

Version:
$Id: Metainfo.java 148 2006-09-14 20:52:32Z claudio $
Author:
Claudio Nieder

Constructor Summary
Metainfo(java.io.InputStream input)
          Initialize the instance by reading torrent meta information from input stream
 
Method Summary
 java.util.List<FileInfo> getFileInfo()
           
 byte[] getHash(int index)
           
 int getHashCount()
           
 java.util.List<byte[]> getHashes()
           
 long getPieceLength()
           
 long getTotalLength()
          Return the length of all files summed together.
 java.net.URL getUrl()
          Retrieve the tracker 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

public Metainfo(java.io.InputStream input)
         throws java.io.IOException
Initialize the instance by reading torrent meta information from input stream

Parameters:
input - stream
Throws:
java.io.IOException
Method Detail

getUrl

public java.net.URL getUrl()
Retrieve the tracker URL

Returns:
the url

getFileInfo

public java.util.List<FileInfo> getFileInfo()
Returns:
List of files.

getHashes

public java.util.List<byte[]> getHashes()
Returns:
List of hashes.

getHash

public byte[] getHash(int index)
Parameters:
index - The number of the requested hash. 0 is the first one.
Returns:
The hash with the given index.

getHashCount

public int getHashCount()
Returns:
The numbe of hashes in this torrent

getPieceLength

public long getPieceLength()
Returns:
the pieceLength

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()

getTotalLength

public long getTotalLength()
Return the length of all files summed together.

Returns:
the totalLength