net.sf.tacos.demo.pages.forms
Class ImportWorker

java.lang.Object
  extended by java.lang.Thread
      extended by net.sf.tacos.demo.pages.forms.ImportWorker
All Implemented Interfaces:
Serializable, Runnable, ProgressWorker

public class ImportWorker
extends Thread
implements ProgressWorker, Serializable

Imports a file from a form.

Author:
jkuhnert
See Also:
ProgressBar, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
protected  org.apache.tapestry.request.IUploadFile file
          uploading file bytestream
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ImportWorker(org.apache.tapestry.request.IUploadFile file)
          Creates a new instance of thread that will manage importing the specified file.
 
Method Summary
 void cancelTask()
          Can be invoked by a user inpatient to see the request completed.
 double getCurrentProgress()
          Should represent a number value indicating the current progress value out of the total derived in ProgressWorker.getTotalProgress().
 String getCurrentStatus()
          If value not null will be used to display any textual information that may be useful to see along with the basic numeric values.
 double getTotalProgress()
          The total value that this progress represents.
 boolean isComplete()
          Should return true once the task is completed.
 void run()
          
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

file

protected org.apache.tapestry.request.IUploadFile file
uploading file bytestream

Constructor Detail

ImportWorker

public ImportWorker(org.apache.tapestry.request.IUploadFile file)
             throws IOException
Creates a new instance of thread that will manage importing the specified file.

Parameters:
file - The file to import
Throws:
IOException - if an io error occurs
Method Detail

getTotalProgress

public double getTotalProgress()
The total value that this progress represents. This should be specific to your task, not in terms of percent complete, as the percentage values will be calculated automatically by the ProgressBar.

Specified by:
getTotalProgress in interface ProgressWorker
Returns:
Number representing the total value for this progress bar.

getCurrentProgress

public double getCurrentProgress()
Should represent a number value indicating the current progress value out of the total derived in ProgressWorker.getTotalProgress().

Specified by:
getCurrentProgress in interface ProgressWorker
Returns:
The current progress value.

getCurrentStatus

public String getCurrentStatus()
If value not null will be used to display any textual information that may be useful to see along with the basic numeric values.

Specified by:
getCurrentStatus in interface ProgressWorker
Returns:
String representation of what is currently being worked on by this task.

isComplete

public boolean isComplete()
Should return true once the task is completed.

Specified by:
isComplete in interface ProgressWorker
Returns:
True, if and only if the thread represented by this task is complete.

cancelTask

public void cancelTask()
Can be invoked by a user inpatient to see the request completed. Method doesn't have to cancel exactly when called, or at all, but it is expected that this method will block at least until the task is complete. Only return from this call if calling ProgressWorker.isComplete() will return true.

Specified by:
cancelTask in interface ProgressWorker

run

public void run()

Specified by:
run in interface Runnable
Overrides:
run in class Thread