|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.torrentMech.codec.Torrent
public class Torrent
Torrent represents a decoded Torrent file. Dictionaries are stored internally as Hashtable objects
while lists are stored as LinkedList objects. Values from the decoded torrent can be called from
various class methods. Malformed torrent files will throw a
com.torrentMech.codec.CorruptTorrentException.
| Field Summary | |
|---|---|
private int |
pos
Used internally to keep the current position withing the bencoded torrent string during decoding. |
private java.lang.String |
torrent
Internally represents the original bencoded torrent. |
private static int |
TORRENT_E
Used within the decoder methods to keep track of current stage of decoding. |
private static int |
TORRENT_KEY
Used within the decoder methods to keep track of current stage of decoding. |
private static int |
TORRENT_LIST_ELEMENT
Used within the decoder methods to keep track of current stage of decoding. |
private static int |
TORRENT_VALUE
Used within the decoder methods to keep track of current stage of decoding. |
private java.util.Hashtable |
torrentTree
Internally represents the top level dictionary of the torrent. |
| Constructor Summary | |
|---|---|
Torrent(java.io.BufferedReader br)
Populates the Torrent instance with torrent details read from a java.io.BufferedReader. |
|
Torrent(java.lang.String torrent)
Populates the Torrent instance with torrent details read from a java.lang.String. |
|
| Method Summary | |
|---|---|
private java.lang.String |
checkOptionalKey(java.lang.String key)
Internal utility method for the Torrent class to assist in retrieving requests for optional keys within the torrent. |
private java.util.Hashtable |
decodeDict()
Decode a bencoded torrent's dictionary into it's key/value pairs. |
private java.lang.String |
decodeInt()
Decodes integer values of a torrent. |
private java.util.LinkedList |
decodeList()
Decodes list sections of the torrent. |
private java.lang.String |
decodeString()
Decodes String sections of the torrent. |
java.lang.String |
getComment()
|
java.lang.String |
getCreatedBy()
|
long |
getCreationDate()
|
java.lang.String[][] |
getFiles()
Returns a two-dimensional java.lang.String array of the files contained in the torrent. |
java.lang.String |
getTorrent()
|
java.lang.String[] |
getTrackers()
Returns all unique trackers for this torrent. |
boolean |
isMultiFile()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final int TORRENT_KEY
private static final int TORRENT_VALUE
private static final int TORRENT_E
private static final int TORRENT_LIST_ELEMENT
private int pos
private java.util.Hashtable torrentTree
private java.lang.String torrent
| Constructor Detail |
|---|
public Torrent(java.io.BufferedReader br)
throws CorruptTorrentException
java.io.BufferedReader.
CorruptTorrentException
public Torrent(java.lang.String torrent)
throws CorruptTorrentException
java.lang.String. This
String is not a path or URL to a torrent, but the actual Bencoded torrent.
CorruptTorrentException| Method Detail |
|---|
public java.lang.String getTorrent()
public java.lang.String[] getTrackers()
java.lang.String array of all the unique trackers for this torrent.public java.lang.String[][] getFiles()
java.lang.String array of the files contained in the torrent.
Each of the first dimensions of the array is the file name including path and each of the second
dimensions of the array is the corresponding file length in bytes. The array is initialized in the
form [n][2] where n is the # of files in the torrent.[MyFolder\File1.txt] [MyFolder\File2.txt]
[1024] [2436]
java.lang.String array of the torrent files including
their path and length.public boolean isMultiFile()
public long getCreationDate()
public java.lang.String getCreatedBy()
Null if none exists.public java.lang.String getComment()
Null if none exists.private java.lang.String checkOptionalKey(java.lang.String key)
java.lang.String value of the requested key or null
if the key doesn't exist.
private java.util.Hashtable decodeDict()
throws CorruptTorrentException
CorruptTorrentException
private java.lang.String decodeString()
throws CorruptTorrentException
CorruptTorrentException
private java.lang.String decodeInt()
throws CorruptTorrentException
CorruptTorrentException
private java.util.LinkedList decodeList()
throws CorruptTorrentException
CorruptTorrentException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||