Jala 1.3

## Class jala.BitTorrent

    Object
       |
       +--jala.BitTorrent

class jala.BitTorrent

This class provides methods to create a BitTorrent metadata file from any desired file.
Defined in BitTorrent.js

Constructor Summary
`jala.BitTorrent (<String> filePath, <String> trackerUrl)` Constructs a new BitTorrent file.

Method Summary
`Object` | `get(<String> name)` Get a torrent property.
`Date` | `getCreationDate()` Get the creation date of the torrent.
`Number` | `getPieceLength()` Get the piece length of the torrent.
`helma.File` | `getSourceFile()` Returns the underlying source file.
`helma.File` | `getTorrentFile()` Returns the underlying torrent file.
`Array` | `keys()` Get all available property names.
`void` | `save(<String> filename)` Saves the torrent as file.
`void` | `set(<String> name, <Object> value)` Set a torrent property.
`void` | `setCreationDate(<Date> date)` Set the creation date of the torrent.
`void` | `setPieceLength(<Number> length)` Set the piece length of the torrent.
`String` | `toString()` Get a string representation of the torrent.
`<static> Object` | `bdecode(<String> code)` The bdecode method.
`<static> String` | `bencode(<Object> obj)` The bencode method.

Constructor Detail

### jala.BitTorrent

    jala.BitTorrent(<String> filePath, <String> trackerUrl)

Constructs a new BitTorrent file.

Parameters:

`filePath` - The path to the original file.

`trackerUrl` - The URL string of the tracker.

Returns:

A new BitTorrent file.

Method Detail

### get

    Object get(<String> name)

Get a torrent property.

Parameters:

`name` - The name of the property.

Returns:

The value of the property.

### getCreationDate

    Date getCreationDate()

Get the creation date of the torrent.

Returns:

The torrent's creation date.

### getPieceLength

    Number getPieceLength()

Get the piece length of the torrent.

Returns:

The torrent's piece length.

### getSourceFile

    helma.File getSourceFile()

Returns the underlying source file.

Returns:

The source file.

### getTorrentFile

    helma.File getTorrentFile()

Returns the underlying torrent file.

Returns:

The torrent file.

### keys

    Array keys()

Get all available property names.

Returns:

The list of property names.

### save

    void save(<String> filename)

Saves the torrent as file.

Parameters:

`filename` - An optional name for the torrent file. If no name is given it will be composed from name of source file as defined in the torrent plus the ending ".torrent".

### set

    void set(<String> name, <Object> value)

Set a torrent property.

Parameters:

`name` - The name of the property.

`value` - The property's value.

### setCreationDate

    void setCreationDate(<Date> date)

Set the creation date of the torrent.

Parameters:

`date` - The desired creation date.

### setPieceLength

    void setPieceLength(<Number> length)

Set the piece length of the torrent.

Parameters:

`length` - The desired piece length.

### toString

    String toString()

Get a string representation of the torrent.

Returns:

The torrent as string.

### bdecode

    <static> Object bdecode(<String> code)

The bdecode method. Turns an encoded string into a corresponding JavaScript object structure. FIXME: Handle with caution...

Parameters:

`code` - The encoded string.

Returns:

The decoded JavaScript structure.

### bencode

    <static> String bencode(<Object> obj)

The bencode method. Turns an arbitrary JavaScript object structure into a corresponding encoded string.

Parameters:

`obj` - The target JavaScript object.

Returns:

The encoded string.

Jala 1.3

Documentation generated by JSDoc on Tue Jan 8 15:45:31 2008