jBittorrentAPI
Class TorrentProcessor

java.lang.Object
  extended by jBittorrentAPI.TorrentProcessor

public class TorrentProcessor
extends java.lang.Object

Class enabling to process a torrent file


Field Summary
private  TorrentFile torrent
           
 
Constructor Summary
TorrentProcessor()
           
TorrentProcessor(TorrentFile torrent)
           
 
Method Summary
 int addFile(java.io.File file)
          Add the files in the list to the torrent
 int addFile(java.lang.String filename)
          Add the files in the list to the torrent
 int addFiles(java.util.List l)
          Add the files in the list to the torrent
 int addFiles(java.lang.Object[] filenames)
          Add the files in the list to the torrent
 void generatePieceHashes()
          Generate the SHA-1 hashes for the files in the current object TorrentFile
 void generatePieceHashes(TorrentFile torr)
          Generate the SHA-1 hashes for the file in the torrent in parameter
 byte[] generateTorrent()
          Generate the bytes for the current object TorrentFile
 byte[] generateTorrent(TorrentFile torr)
          Generate the bytes of the bencoded TorrentFile data
 TorrentFile getTorrent()
          Returns the local TorrentFile in its current state
 TorrentFile getTorrentFile(java.util.Map m)
          Given a Map, retrieve all useful information and represent it as a TorrentFile object
 java.util.Map parseTorrent(java.io.File file)
          Given a File (supposed to be a torrent), parse it and represent it as a Map
 java.util.Map parseTorrent(java.lang.String filename)
          Given the path of a torrent, parse the file and represent it as a Map
 void setAnnounceURL(java.lang.String url)
          Sets the announce url of the torrent
 void setComment(java.lang.String comment)
          Sets the comment about this torrent
 void setCreationDate(long date)
          Sets the time the torrent was created
 void setCreator(java.lang.String creator)
          Sets the creator of the torrent.
 void setEncoding(java.lang.String encoding)
          Sets the encoding of the torrent
 void setName(java.lang.String name)
          Sets the directory the files have to be saved in (in case of multiple files torrent)
 void setPieceLength(int length)
          Sets the pieceLength
 void setTorrent(TorrentFile torr)
          Sets the TorrentFile object of the Publisher equals to the given one
 void setTorrentData(java.lang.String url, int pLength, java.lang.String comment, java.lang.String encoding, java.lang.String filename)
          Updates the TorrentFile object according to the given parameters
 void setTorrentData(java.lang.String url, int pLength, java.lang.String comment, java.lang.String encoding, java.lang.String name, java.util.List filenames)
          Updates the TorrentFile object according to the given parameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

torrent

private TorrentFile torrent
Constructor Detail

TorrentProcessor

public TorrentProcessor()

TorrentProcessor

public TorrentProcessor(TorrentFile torrent)
Method Detail

addFile

public int addFile(java.io.File file)
Add the files in the list to the torrent

Parameters:
file - The file to be added
Returns:
int The number of file that have been added
Throws:
java.lang.Exception

addFile

public int addFile(java.lang.String filename)
Add the files in the list to the torrent

Parameters:
filename - The path of the file to be added
Returns:
int The number of file that have been added
Throws:
java.lang.Exception

addFiles

public int addFiles(java.util.List l)
             throws java.lang.Exception
Add the files in the list to the torrent

Parameters:
l - A list containing the File or String object representing the files to be added
Returns:
int The number of files that have been added
Throws:
java.lang.Exception

addFiles

public int addFiles(java.lang.Object[] filenames)
Add the files in the list to the torrent

Parameters:
filenames - An array containing the files to be added
Returns:
int The number of files that have been added
Throws:
java.lang.Exception

generatePieceHashes

public void generatePieceHashes()
Generate the SHA-1 hashes for the files in the current object TorrentFile


generatePieceHashes

public void generatePieceHashes(TorrentFile torr)
Generate the SHA-1 hashes for the file in the torrent in parameter

Parameters:
torr - TorrentFile

generateTorrent

public byte[] generateTorrent()
Generate the bytes for the current object TorrentFile

Returns:
byte[]

generateTorrent

public byte[] generateTorrent(TorrentFile torr)
Generate the bytes of the bencoded TorrentFile data

Parameters:
torr - TorrentFile
Returns:
byte[]

getTorrent

public TorrentFile getTorrent()
Returns the local TorrentFile in its current state

Returns:
TorrentFile

getTorrentFile

public TorrentFile getTorrentFile(java.util.Map m)
Given a Map, retrieve all useful information and represent it as a TorrentFile object

Parameters:
m - Map
Returns:
TorrentFile

parseTorrent

public java.util.Map parseTorrent(java.io.File file)
Given a File (supposed to be a torrent), parse it and represent it as a Map

Parameters:
file - File
Returns:
Map

parseTorrent

public java.util.Map parseTorrent(java.lang.String filename)
Given the path of a torrent, parse the file and represent it as a Map

Parameters:
filename - String
Returns:
Map

setAnnounceURL

public void setAnnounceURL(java.lang.String url)
Sets the announce url of the torrent

Parameters:
url - String

setComment

public void setComment(java.lang.String comment)
Sets the comment about this torrent

Parameters:
comment - String

setCreationDate

public void setCreationDate(long date)
Sets the time the torrent was created

Parameters:
date - long

setCreator

public void setCreator(java.lang.String creator)
Sets the creator of the torrent. This should be the client name and version

Parameters:
creator - String

setEncoding

public void setEncoding(java.lang.String encoding)
Sets the encoding of the torrent

Parameters:
encoding - String

setName

public void setName(java.lang.String name)
Sets the directory the files have to be saved in (in case of multiple files torrent)

Parameters:
name - String

setPieceLength

public void setPieceLength(int length)
Sets the pieceLength

Parameters:
length - int

setTorrent

public void setTorrent(TorrentFile torr)
Sets the TorrentFile object of the Publisher equals to the given one

Parameters:
torr - TorrentFile

setTorrentData

public void setTorrentData(java.lang.String url,
                           int pLength,
                           java.lang.String comment,
                           java.lang.String encoding,
                           java.lang.String filename)
Updates the TorrentFile object according to the given parameters

Parameters:
url - The announce url
pLength - The length of the pieces of the torrent
comment - The comments for the torrent
encoding - The encoding of the torrent
filename - The path of the file to be added to the torrent

setTorrentData

public void setTorrentData(java.lang.String url,
                           int pLength,
                           java.lang.String comment,
                           java.lang.String encoding,
                           java.lang.String name,
                           java.util.List filenames)
                    throws java.lang.Exception
Updates the TorrentFile object according to the given parameters

Parameters:
url - The announce url
pLength - The length of the pieces of the torrent
comment - The comments for the torrent
encoding - The encoding of the torrent
name - The name of the directory to save the files in
filenames - The path of the file to be added to the torrent
Throws:
java.lang.Exception