FileDocCategorySizeDatePackage
ShareItemImpl.javaAPI DocAzureus 3.0.3.43453Thu Sep 23 06:51:56 BST 2004org.gudy.azureus2.pluginsimpl.local.sharing

ShareItemImpl

public class ShareItemImpl extends Object implements ShareItem
author
parg

Fields Summary
protected ShareResourceImpl
resource
protected byte[]
fingerprint
protected org.gudy.azureus2.plugins.torrent.Torrent
torrent
protected String
torrent_save_location
Constructors Summary
protected ShareItemImpl(ShareResourceImpl _resource, byte[] _fingerprint, org.gudy.azureus2.plugins.torrent.Torrent _torrent)

		resource	= _resource;
		fingerprint	= _fingerprint;
		torrent 	= _torrent;
		
		writeTorrent();
	
protected ShareItemImpl(ShareResourceImpl _resource, byte[] _fingerprint, String _save_location)

		resource				= _resource;
		fingerprint				= _fingerprint;		
		torrent_save_location 	= _save_location;
	
Methods Summary
protected voiddelete()

		resource.deleteTorrent(this);
	
protected static org.gudy.azureus2.pluginsimpl.local.sharing.ShareItemImpldeserialiseItem(ShareResourceImpl resource, java.util.Map map)

		try{
			byte[]	hash = (byte[])map.get( "ihash");
		
			String	save_location = new String((byte[])map.get("ifile"), Constants.DEFAULT_ENCODING );
		
			return( new ShareItemImpl(resource,hash,save_location));
			
		}catch( UnsupportedEncodingException e ){
			
			throw( new ShareException( "internal error", e ));
		}
	
public byte[]getFingerPrint()

		return( fingerprint );
	
public org.gudy.azureus2.plugins.torrent.TorrentgetTorrent()

			// TODO: we don't want to hold all torrents in memory. we probably want to
			// create a TorrentFacade that caches enough data to run, say, the sharing UI
			// and then load the torrent from file on demand.
		
		if( torrent == null ){
			
			resource.readTorrent(this);
		}
		
		return( torrent );
	
public java.io.FilegetTorrentFile()

		return( resource.getTorrentFile(this));
	
protected java.lang.StringgetTorrentLocation()

		return( torrent_save_location );
	
protected voidserialiseItem(java.util.Map map)

		map.put( "ihash", fingerprint );
		
		try{
			map.put( "ifile", torrent_save_location.getBytes( Constants.DEFAULT_ENCODING ) );
			
		}catch( UnsupportedEncodingException e ){
			
			Debug.printStackTrace( e );
		}
	
protected voidsetTorrent(org.gudy.azureus2.plugins.torrent.Torrent _torrent)

		torrent	= _torrent;
	
protected voidwriteTorrent()

		if ( torrent_save_location == null ){
			
			torrent_save_location = resource.getNewTorrentLocation();
		}
		
		resource.writeTorrent( this );