Methods Summary |
---|
protected java.lang.String | decode(byte[] data)
getDecoder();
if ( data != null ){
if ( decoder != null ){
try{
return( decoder.decodeString(data));
}catch( Throwable e ){
}
}
return( new String(data));
}
return( "" );
|
public java.lang.Object | getAdditionalProperty(java.lang.String name)
return( torrent.getAdditionalProperty( name ));
|
public java.net.URL | getAnnounceURL()
return( torrent.getAnnounceURL());
|
public TorrentAnnounceURLList | getAnnounceURLList()
return( new TorrentAnnounceURLListImpl( this ));
|
public java.lang.String | getComment()
return( decode(torrent.getComment()));
|
public java.lang.String | getCreatedBy()
return( decode( torrent.getCreatedBy()));
|
public long | getCreationDate()
return( torrent.getCreationDate());
|
protected void | getDecoder()
// We defer the getting of the decoder until it is required as this Torrent may have been
// created in order to simply remove additional properties from it before serialising it
// Indeed, this was happening and unfortunately resulting in 1) the encoding being
// serialised 2) the user being prompted for an encoding choice
try{
decoder = LocaleTorrentUtil.getTorrentEncoding( torrent );
}catch( Throwable e ){
}
|
public java.lang.String | getEncoding()
getDecoder();
if ( decoder != null ){
return( decoder.getName());
}
return( Constants.DEFAULT_ENCODING );
|
public TorrentFile[] | getFiles()
TOTorrentFile[] files = torrent.getFiles();
TorrentFile[] res = new TorrentFile[files.length];
for (int i=0;i<res.length;i++){
TOTorrentFile tf = files[i];
byte[][] comps = tf.getPathComponents();
String name = "";
for (int j=0;j<comps.length;j++){
String comp = decode(comps[j]);
comp = FileUtil.convertOSSpecificChars( comp );
name += (j==0?"":File.separator)+comp;
}
res[i] = new TorrentFileImpl(name, tf.getLength());
}
return( res );
|
public byte[] | getHash()
try{
return( torrent.getHash());
}catch( TOTorrentException e ){
Debug.printStackTrace( e );
return( null );
}
|
public java.net.URL | getMagnetURI()
if ( magnet_plugin == null ){
PluginInterface magnet_pi = AzureusCoreFactory.getSingleton().getPluginManager().getPluginInterfaceByClass( MagnetPlugin.class );
if ( magnet_pi != null ){
magnet_plugin = (MagnetPlugin)magnet_pi.getPlugin();
}
}
if ( magnet_plugin == null ){
throw( new TorrentException( "MegnetPlugin unavailable" ));
}
try{
URL res = magnet_plugin.getMagnetURL( torrent.getHash());
return( res );
}catch( TOTorrentException e ){
throw( new TorrentException(e ));
}
|
public java.util.Map | getMapProperty(java.lang.String name)
return( TorrentUtils.getPluginMapProperty( torrent, name ));
|
public java.lang.String | getName()
String name = decode( torrent.getName());
name = FileUtil.convertOSSpecificChars( name );
return( name );
|
public long | getPieceCount()
return( torrent.getNumberOfPieces());
|
public long | getPieceSize()
return( torrent.getPieceLength());
|
public byte[][] | getPieces()
try{
return( torrent.getPieces());
}catch( TOTorrentException e ){
Debug.printStackTrace( e );
return( new byte[0][0] );
}
|
public java.lang.String | getPluginStringProperty(java.lang.String name)
PluginInterface p = pi;
if ( p == null ){
p = UtilitiesImpl.getPluginThreadContext();
}
if ( p == null ){
name = "<internal>." + name;
}else{
name = p.getPluginID() + "." + name;
}
return( TorrentUtils.getPluginStringProperty( torrent, name ));
|
public java.lang.Object[] | getQueryableInterfaces()
return new Object[] { torrent };
|
public java.lang.String | getRelationText()
return propogatedRelationText(torrent);
|
public long | getSize()
return( torrent.getSize());
|
public TOTorrent | getTorrent()
return( torrent );
|
public boolean | isComplete()
// TODO: could check the download state too I guess...
return( complete );
|
public boolean | isDecentralised()
return( TorrentUtils.isDecentralised( torrent ));
|
public boolean | isDecentralisedBackupEnabled()
return( TorrentUtils.getDHTBackupEnabled( torrent ));
|
public boolean | isDecentralisedBackupRequested()
return( TorrentUtils.isDHTBackupRequested( torrent ));
|
public boolean | isPrivate()
return( TorrentUtils.getPrivate( torrent ));
|
public Torrent | removeAdditionalProperties()
try{
TOTorrent t = TOTorrentFactory.deserialiseFromMap(torrent.serialiseToMap());
t.removeAdditionalProperties();
return( new TorrentImpl( t ));
}catch( TOTorrentException e ){
Debug.printStackTrace(e);
return( this );
}
|
public void | save()
try{
TorrentUtils.writeToFile( torrent );
}catch( TOTorrentException e ){
throw( new TorrentException( "Torrent::save Fails", e ));
}
|
public void | setAnnounceURL(java.net.URL url)
torrent.setAnnounceURL( url );
updated();
|
public void | setComment(java.lang.String comment)
torrent.setComment( comment );
|
public void | setComplete(java.io.File data_dir)
try{
LocaleTorrentUtil.setDefaultTorrentEncoding( torrent );
DownloadManagerState download_manager_state =
DownloadManagerStateFactory.getDownloadState( torrent );
TorrentUtils.setResumeDataCompletelyValid( download_manager_state );
download_manager_state.save();
complete = true;
}catch( Throwable e ){
throw( new TorrentException("encoding selection fails", e ));
}
|
public void | setDecentralisedBackupRequested(boolean requested)
TorrentUtils.setDHTBackupRequested( torrent, requested );
|
public void | setDefaultEncoding()
setEncoding(Constants.DEFAULT_ENCODING);
|
public void | setEncoding(java.lang.String encoding)
try {
LocaleTorrentUtil.setTorrentEncoding(torrent, encoding);
} catch(LocaleUtilEncodingException e) {
throw new TorrentEncodingException("Failed to set the encoding",e);
}
|
public void | setMapProperty(java.lang.String name, java.util.Map value)
TorrentUtils.setPluginMapProperty( torrent, name, value );
|
public void | setPluginStringProperty(java.lang.String name, java.lang.String value)
PluginInterface p = pi;
if ( p == null ){
p = UtilitiesImpl.getPluginThreadContext();
}
if ( p == null ){
name = "<internal>." + name;
}else{
name = p.getPluginID() + "." + name;
}
TorrentUtils.setPluginStringProperty( torrent, name, value );
|
public void | setPrivate(boolean priv)
TorrentUtils.setPrivate( torrent, priv );
|
protected void | updated()
try{
DownloadImpl dm = (DownloadImpl)DownloadManagerImpl.getDownloadStatic( torrent );
if ( dm != null ){
dm.torrentChanged();
}
}catch( DownloadException e ){
// torrent may not be running
}
|
public boolean | wasCreatedByUs()
return( TorrentUtils.isCreatedTorrent( torrent ));
|
public byte[] | writeToBEncodedData()
try{
Map map = torrent.serialiseToMap();
return( BEncoder.encode( map ));
}catch( Throwable e ){
throw( new TorrentException( "Torrent::writeToBEncodedData: fails", e ));
}
|
public void | writeToFile(java.io.File file)
try{
// don't use TorrentUtils.writeToFile as this updates the internal torrent
// file reference an means that the torrent get's auto-written to the new
// location in future, most likley NOT the desired behaviour
torrent.serialiseToBEncodedFile( file );
}catch( TOTorrentException e ){
throw( new TorrentException( "Torrent::writeToFile: fails", e ));
}
|
public java.util.Map | writeToMap()
try{
return( torrent.serialiseToMap());
}catch( TOTorrentException e ){
throw( new TorrentException( "Torrent::writeToMap: fails", e ));
}
|