extensions/net.sf.basedb.genepattern/trunk/src/net/sf/basedb/genepattern/file/FileProxy.java

Code
Comments
Other
Rev Date Author Line
1107 03 Jun 09 nicklas 1 package net.sf.basedb.genepattern.file;
1107 03 Jun 09 nicklas 2
1107 03 Jun 09 nicklas 3 import java.io.IOException;
1107 03 Jun 09 nicklas 4 import java.io.InputStream;
1107 03 Jun 09 nicklas 5 import java.io.OutputStream;
1107 03 Jun 09 nicklas 6
1107 03 Jun 09 nicklas 7 /**
1107 03 Jun 09 nicklas 8   A proxy for a file that is going to be used by a GenePattern job.
1107 03 Jun 09 nicklas 9   Files are added to {@link FileTransferGateway#addFile(String, FileProxy)}.
1107 03 Jun 09 nicklas 10   <p>
1107 03 Jun 09 nicklas 11   Implementors of this interface may choose if they want to implement
1107 03 Jun 09 nicklas 12   {@link #getInputStream()} or {@link #writeTo(OutputStream)}. If the
1107 03 Jun 09 nicklas 13   <code>getInputStream()</code> method returns a non-null object that 
1107 03 Jun 09 nicklas 14   stream is used for copying the file. The <code>writeTo()</code>
1107 03 Jun 09 nicklas 15   method is only used if <code>getInputStream()</code> return null.
1107 03 Jun 09 nicklas 16   
1107 03 Jun 09 nicklas 17   @author nicklas
1107 03 Jun 09 nicklas 18   @since 1.0
1107 03 Jun 09 nicklas 19 */
1107 03 Jun 09 nicklas 20 public interface FileProxy 
1107 03 Jun 09 nicklas 21 {
1107 03 Jun 09 nicklas 22   /**
1107 03 Jun 09 nicklas 23     Get the name of the file.
1107 03 Jun 09 nicklas 24   */
1107 03 Jun 09 nicklas 25   public String getFileName();
1107 03 Jun 09 nicklas 26   
1107 03 Jun 09 nicklas 27   /**
1107 03 Jun 09 nicklas 28     Get an input stream for reading the file data. May
1107 03 Jun 09 nicklas 29     return null if the implementation can't supply an input stream
1107 03 Jun 09 nicklas 30     but then {@link #writeTo(OutputStream)} must be implemented instead.
1107 03 Jun 09 nicklas 31     @return An input stream or null
1107 03 Jun 09 nicklas 32   */
1107 03 Jun 09 nicklas 33   public InputStream getInputStream()
1107 03 Jun 09 nicklas 34     throws IOException;
1107 03 Jun 09 nicklas 35   
1107 03 Jun 09 nicklas 36   /**
1107 03 Jun 09 nicklas 37     Write the file data to the given output stream. This method only needs
1107 03 Jun 09 nicklas 38     to be implemented if the {@link #getInputStream()} returns null.
1107 03 Jun 09 nicklas 39     @param out The output stream to write the file data to
1107 03 Jun 09 nicklas 40   */
1107 03 Jun 09 nicklas 41   public void writeTo(OutputStream out)
1107 03 Jun 09 nicklas 42     throws IOException;
1107 03 Jun 09 nicklas 43 }