2.17.2: 2011-06-17

net.sf.basedb.clients.web.fileupload
Class FileUploadProgress

java.lang.Object
  extended by net.sf.basedb.clients.web.fileupload.FileUploadProgress

public class FileUploadProgress
extends Object

Objects of this class holds information about the progress of an upload. Use the FileUpload.getProgress() to get the progress that is associated with a particular file upload.

Use the getTotalBytes() and getTransferredBytes() to get information about how the upload is progressing.

Version:
2.0
Author:
Nicklas
See Also:
FileUpload
Last modified
$Date$

Field Summary
private  boolean abort
           
private  String currentFilename
           
private  Throwable exception
           
private  long startTime
           
private  long totalBytes
           
private  long transferredBytes
           
 
Constructor Summary
FileUploadProgress(long totalBytes)
          Create a new FileUploadProgress object.
 
Method Summary
(package private)  void addTransferredBytes(long bytes)
          Adds a value to the number of transfered bytes.
 String getCurrentFilename()
          Get the name of the file that is currently beeing transferred.
 Throwable getException()
          Get the exception that caused the upload to fail.
 long getMillisecondsSinceStart()
          Get the number of milliseconds since the start of the upload.
 long getTotalBytes()
          Get the total number of bytes expected to upload.
 long getTransferredBytes()
          Get the number of bytes that have been uploaded so far.
 boolean hasAborted()
          Check if the upload has been requested to be aborted.
 void setAbort()
          Request that the upload should be aborted.
(package private)  void setCurrentFilename(String filename)
          Sets the name of the file that is currently uploading
(package private)  void setException(Throwable exception)
          Set the exception that caused the upload to fail.
(package private)  void setTransferredBytes(long bytes)
          Sets the number of transferred bytes.
 boolean transferIsComplete()
          Checks if the transfer is complete or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

totalBytes

private final long totalBytes

startTime

private final long startTime

transferredBytes

private long transferredBytes

currentFilename

private String currentFilename

exception

private Throwable exception

abort

private boolean abort
Constructor Detail

FileUploadProgress

FileUploadProgress(long totalBytes)
Create a new FileUploadProgress object. This constructor is package private. Use FileUpload.getProgress() to get the progress that is associated with a particular file upload.

Parameters:
totalBytes - The total number of bytes that should be uploaded.
Method Detail

getTotalBytes

public long getTotalBytes()
Get the total number of bytes expected to upload.

Returns:
The total number of bytes to upload

getTransferredBytes

public long getTransferredBytes()
Get the number of bytes that have been uploaded so far.

Returns:
The number of bytes

setTransferredBytes

void setTransferredBytes(long bytes)
Sets the number of transferred bytes.

Parameters:
bytes - The number of bytes

addTransferredBytes

void addTransferredBytes(long bytes)
Adds a value to the number of transfered bytes.

Parameters:
bytes - The value to add to the number of transfered bytes

transferIsComplete

public boolean transferIsComplete()
Checks if the transfer is complete or not. A transfer is complete when the transferred bytes equals the total bytes.

Returns:
TRUE if the transfer has been completed, FALSE otherwise

getCurrentFilename

public String getCurrentFilename()
Get the name of the file that is currently beeing transferred. The value returned is the name of the file on the client computer.

Returns:
The name of the file

setCurrentFilename

void setCurrentFilename(String filename)
Sets the name of the file that is currently uploading

Parameters:
filename - The name of the file

getException

public Throwable getException()
Get the exception that caused the upload to fail.

Returns:
A Throwable or null if no exception has occured

setException

void setException(Throwable exception)
Set the exception that caused the upload to fail.


getMillisecondsSinceStart

public long getMillisecondsSinceStart()
Get the number of milliseconds since the start of the upload.


setAbort

public void setAbort()
Request that the upload should be aborted. The associated FileUpload object will check this property at regular intervals and if set it will close the upload stream as soon as possible, and then throw an UploadAbortedException which will also be available from the getException() method.


hasAborted

public boolean hasAborted()
Check if the upload has been requested to be aborted. Use the getException() method to actually check if the upload has been aborted.


2.17.2: 2011-06-17