extensions/net.sf.basedb.opengrid/trunk/src/net/sf/basedb/opengrid/filetransfer/DownloadTarget.java

Code
Comments
Other
Rev Date Author Line
4122 22 Sep 16 nicklas 1 package net.sf.basedb.opengrid.filetransfer;
4122 22 Sep 16 nicklas 2
4122 22 Sep 16 nicklas 3 import java.io.IOException;
4122 22 Sep 16 nicklas 4 import java.io.OutputStream;
4122 22 Sep 16 nicklas 5
4301 13 Jan 17 nicklas 6 import net.sf.basedb.opengrid.AbstractSession;
4301 13 Jan 17 nicklas 7
4122 22 Sep 16 nicklas 8 /**
4301 13 Jan 17 nicklas 9   Represents a local file or resource that is the target for
4301 13 Jan 17 nicklas 10   a file that is about to be downloaded from a remote server. 
4301 13 Jan 17 nicklas 11   The download is initiated by calling  
4301 13 Jan 17 nicklas 12   {@link AbstractSession#downloadFile(String, DownloadTarget)}
4301 13 Jan 17 nicklas 13   which will call {@link #getMetadata()} first and populate this
4301 13 Jan 17 nicklas 14   with as much information as it can get from the remote server.
4301 13 Jan 17 nicklas 15   Then, the {@link #getOutputStream()} is called and the file
4301 13 Jan 17 nicklas 16   data is written to the returned stream.
4122 22 Sep 16 nicklas 17   
4122 22 Sep 16 nicklas 18   @author nicklas
4122 22 Sep 16 nicklas 19   @since 1.0
4122 22 Sep 16 nicklas 20 */
4122 22 Sep 16 nicklas 21 public interface DownloadTarget 
4122 22 Sep 16 nicklas 22 {
4122 22 Sep 16 nicklas 23   /**
4122 22 Sep 16 nicklas 24     The name of the local resource.
4122 22 Sep 16 nicklas 25   */
4122 22 Sep 16 nicklas 26   public String getName();
4122 22 Sep 16 nicklas 27   
4122 22 Sep 16 nicklas 28   /**
4122 22 Sep 16 nicklas 29     Get an ouput stream for writing the file data to the
4122 22 Sep 16 nicklas 30     local resource.
4122 22 Sep 16 nicklas 31   */
4122 22 Sep 16 nicklas 32   public OutputStream getOutputStream()
4122 22 Sep 16 nicklas 33     throws IOException;
4122 22 Sep 16 nicklas 34   
4122 22 Sep 16 nicklas 35   /**
4124 23 Sep 16 nicklas 36     Get a metadata instance for collecting information
4124 23 Sep 16 nicklas 37     about the remote file. The metadata will be populated
4124 23 Sep 16 nicklas 38     before the download is started.
4124 23 Sep 16 nicklas 39     @return A metadata instance or null if not important
4122 22 Sep 16 nicklas 40   */
4124 23 Sep 16 nicklas 41   public FileMetaData getMetadata();
4124 23 Sep 16 nicklas 42   
4122 22 Sep 16 nicklas 43 }