wt.clients.dndMicroApplet
Class ContentDownloader

java.lang.Object
  extended bywt.clients.dndMicroApplet.ContentDownloader
All Implemented Interfaces:
Runnable

final class ContentDownloader
extends Object
implements Runnable

Runnable which downloads from a specified URL to a specified file and uses a specified applet to update the user as to progress of the operation. Intended for usage from background threads.

Note that file download progress dialogs are quite doable instead of using showStatus() as is done currently. The current approach was selected for simplicity, unobtrusiveness, and small size of this class.


Field Summary
private  Applet applet
          Applet to show status through and as a source of Locale
private static int BUFFER_SIZE
          Size of buffer used for download
private  File newFile
          Newly created file to download to
private  ResourceBundle rb
          Resource bundle to use for localization
private static char REPL_CHAR
          Safe replacement character for ' in MessageFormat strings.
private  URL sourceURL
          URL to download from
 
Constructor Summary
(package private) ContentDownloader(Applet applet, URL sourceURL, File newFile)
          Takes applet to allow use of showStatus() and getLocale(), a URL to download from, and a newly created file to download to.
 
Method Summary
private  void delete(File file)
          Delete file via FileOperation
private  FileOutputStream getFileOutputStream(File file)
          Get file output stream for file via FileOperation
 void run()
          Workhorse method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPL_CHAR

private static final char REPL_CHAR
Safe replacement character for ' in MessageFormat strings. This is as per (and extracted from) wt.util.WTMessage.

See Also:
Constant Field Values

BUFFER_SIZE

private static final int BUFFER_SIZE
Size of buffer used for download

See Also:
Constant Field Values

applet

private Applet applet
Applet to show status through and as a source of Locale


sourceURL

private URL sourceURL
URL to download from


newFile

private File newFile
Newly created file to download to


rb

private ResourceBundle rb
Resource bundle to use for localization

Constructor Detail

ContentDownloader

ContentDownloader(Applet applet,
                  URL sourceURL,
                  File newFile)
Takes applet to allow use of showStatus() and getLocale(), a URL to download from, and a newly created file to download to.

Method Detail

run

public void run()
Workhorse method.

Specified by:
run in interface Runnable

getFileOutputStream

private FileOutputStream getFileOutputStream(File file)
                                      throws Exception
Get file output stream for file via FileOperation

Throws:
Exception

delete

private void delete(File file)
Delete file via FileOperation