Class FileUploadProgress
java.lang.Object
net.sf.basedb.clients.web.fileupload.FileUploadProgress
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:
- Last modified
- $Date$
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescription(package private) void
addTransferredBytes
(long bytes) Adds a value to the number of transfered bytes.Get the name of the file that is currently beeing transferred.Get the exception that caused the upload to fail.long
Get the number of milliseconds since the start of the upload.long
Get the total number of bytes expected to upload.long
Get the number of bytes that have been uploaded so far.boolean
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
Checks if the transfer is complete or not.
-
Field Details
-
totalBytes
private final long totalBytes -
startTime
private final long startTime -
transferredBytes
private long transferredBytes -
currentFilename
-
exception
-
abort
private boolean abort
-
-
Constructor Details
-
FileUploadProgress
FileUploadProgress(long totalBytes) Create a newFileUploadProgress
object. This constructor is package private. UseFileUpload.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 Details
-
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
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
Sets the name of the file that is currently uploading- Parameters:
filename
- The name of the file
-
getException
Get the exception that caused the upload to fail.- Returns:
- A
Throwable
or null if no exception has occured
-
setException
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 associatedFileUpload
object will check this property at regular intervals and if set it will close the upload stream as soon as possible, and then throw anUploadAbortedException
which will also be available from thegetException()
method. -
hasAborted
public boolean hasAborted()Check if the upload has been requested to be aborted. Use thegetException()
method to actually check if the upload has been aborted.
-