Class FileUploadProgress

java.lang.Object
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:
Last modified
$Date$
  • Field Details

    • 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 Details

    • 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 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

      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.