lbg.protocol.data
Class TorrentGridData
java.lang.Object
lbg.protocol.data.GridData
lbg.protocol.data.TorrentGridData
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Comparable<GridData>, org.gudy.azureus2.core3.download.DownloadManagerListener
public class TorrentGridData
- extends GridData
- implements org.gudy.azureus2.core3.download.DownloadManagerListener
Grid data class where the data is shared using BitTorrent.
The file becomes available as soon as this object is instanciated.
This heavily relies on Azureus internals and could be broken with
numerous versions of Azureus. (it actually broke on 2.5) I should find
another library (which doesn't seem to exist) or code my own (which I don't
have time for).
- Author:
- Xavier Dalem
- See Also:
- Serialized Form
Constructor Summary |
protected |
TorrentGridData(java.lang.String id,
long size,
java.util.Map az_serialized_map,
byte[] checksum,
org.gudy.azureus2.core3.download.DownloadManager manager)
Create a Torrent Grid Data from an id and a file |
Method Summary |
void |
completionChanged(org.gudy.azureus2.core3.download.DownloadManager manager,
boolean bCompleted)
|
void |
downloadComplete(org.gudy.azureus2.core3.download.DownloadManager manager)
|
void |
filePriorityChanged(org.gudy.azureus2.core3.download.DownloadManager download,
org.gudy.azureus2.core3.disk.DiskManagerFileInfo file)
|
byte[] |
getChecksum()
Get checksum from data. |
java.io.InputStream |
getInputStream()
Get an input stream to read the data |
void |
positionChanged(org.gudy.azureus2.core3.download.DownloadManager download,
int oldPosition,
int newPosition)
|
void |
stateChanged(org.gudy.azureus2.core3.download.DownloadManager manager,
int state)
|
void |
toFile(java.io.File file)
Save data in a file. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
TorrentGridData
protected TorrentGridData(java.lang.String id,
long size,
java.util.Map az_serialized_map,
byte[] checksum,
org.gudy.azureus2.core3.download.DownloadManager manager)
throws GridException
- Create a Torrent Grid Data from an id and a file
- Parameters:
id
- The file ID. For restrictions on this, see GridDataaz_serialized_map
- An azureus-serialized TOTorrent map. Such a map
can be got from TOTorrent.serialiseToMap() and used with
TOTorrentFactory.deserialiseFromMap(), after which you have to write the
file as a .torrent on disk then reload it wih a TorrentDownloader
because, somehow, the TorrentDownloader has no method to use an existing
torrent and rather finds the data by himself...checksum
- The GridData.HASHING_ALGORITHM checksum for datamanager
- The Download manager that was used to share the data
when it was first tracked. This won't be used by toFile(File)
and only serves as a way to keep all useful information on the tracking
side.
- Throws:
GridException
toFile
public void toFile(java.io.File file)
throws GridException
- Description copied from class:
GridData
- Save data in a file.
This call is blocking.
- Specified by:
toFile
in class GridData
- Parameters:
file
- The file where to put data
- Throws:
GridException
getChecksum
public byte[] getChecksum()
throws GridException
- Description copied from class:
GridData
- Get checksum from data. It must be the checksum from the real
data, not of data and combined details like it is the case for torrents.
The used algorithm is specified by HASHING_ALGORITHM.
- Specified by:
getChecksum
in class GridData
- Throws:
GridException
- See Also:
GridData.HASHING_ALGORITHM
getInputStream
public java.io.InputStream getInputStream()
throws GridException
- Description copied from class:
GridData
- Get an input stream to read the data
- Specified by:
getInputStream
in class GridData
- Throws:
GridException
- If the file doesn't exist
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
stateChanged
public void stateChanged(org.gudy.azureus2.core3.download.DownloadManager manager,
int state)
- Specified by:
stateChanged
in interface org.gudy.azureus2.core3.download.DownloadManagerListener
downloadComplete
public void downloadComplete(org.gudy.azureus2.core3.download.DownloadManager manager)
- Specified by:
downloadComplete
in interface org.gudy.azureus2.core3.download.DownloadManagerListener
completionChanged
public void completionChanged(org.gudy.azureus2.core3.download.DownloadManager manager,
boolean bCompleted)
- Specified by:
completionChanged
in interface org.gudy.azureus2.core3.download.DownloadManagerListener
positionChanged
public void positionChanged(org.gudy.azureus2.core3.download.DownloadManager download,
int oldPosition,
int newPosition)
- Specified by:
positionChanged
in interface org.gudy.azureus2.core3.download.DownloadManagerListener
filePriorityChanged
public void filePriorityChanged(org.gudy.azureus2.core3.download.DownloadManager download,
org.gudy.azureus2.core3.disk.DiskManagerFileInfo file)
- Specified by:
filePriorityChanged
in interface org.gudy.azureus2.core3.download.DownloadManagerListener
Copyright (c) 2005-2008, Cyril Briquet, parts Xavier Dalem.