pulse - the web application framework Get pulse at SourceForge.net. Fast, secure and Free Open Source software downloads Ohloh project report for pulse-java

org.torweg.pulse.service.request
Class UploadProgress

java.lang.Object
  extended by org.torweg.pulse.service.request.UploadProgress
All Implemented Interfaces:
java.io.Serializable, org.apache.commons.fileupload.ProgressListener

public class UploadProgress
extends java.lang.Object
implements org.apache.commons.fileupload.ProgressListener, java.io.Serializable

represents the progress of a file upload.

Version:
$Revision: 1395 $
Author:
Thomas Weber
See Also:
Command, UploadProgressCheck.getProgress(ServiceRequest), Serialized Form

Constructor Summary
UploadProgress()
           
 
Method Summary
 java.lang.String getErrorMessage()
          returns the error message or null, if no error occurred.
 int getProgress()
          returns the progress in percent or -1, if the total content-length is unknown.
 boolean isErroneous()
          returns whether the upload was erroneous, i.e. it failed.
 boolean isStale()
          returns whether the information in this UploadProgress can be considered stale, i.e. it is ready to be removed.
protected  void setError(java.lang.Exception e, java.util.Locale locale)
          marks the upload as erroneous, giving the cause and current request locale.
protected  void setFinished()
          marks the progress to be finished.
 void update(long pBytesRead, long pContentLength, int pItems)
          updates the progess.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UploadProgress

public UploadProgress()
Method Detail

update

public final void update(long pBytesRead,
                         long pContentLength,
                         int pItems)
updates the progess.

Specified by:
update in interface org.apache.commons.fileupload.ProgressListener
Parameters:
pBytesRead - the total number of bytes, which have been read so far.
pContentLength - the total number of bytes, which are being read. May be -1, if this number is unknown.
pItems - the number of the field, which is currently being read. (0 = no item so far, 1 = first item is being read, ...)
See Also:
ProgressListener.update(long, long, int)

isStale

public final boolean isStale()
returns whether the information in this UploadProgress can be considered stale, i.e. it is ready to be removed.

Returns:
true, if the UploadProgress can be considered stale

getProgress

public final int getProgress()
returns the progress in percent or -1, if the total content-length is unknown.

Returns:
the progress in percent or -1, if the total content-length is unknown

setFinished

protected final void setFinished()
marks the progress to be finished.


setError

protected final void setError(java.lang.Exception e,
                              java.util.Locale locale)
marks the upload as erroneous, giving the cause and current request locale.

Parameters:
e - the cause
locale - the current locale

getErrorMessage

public final java.lang.String getErrorMessage()
returns the error message or null, if no error occurred.

Returns:
the error message

isErroneous

public final boolean isErroneous()
returns whether the upload was erroneous, i.e. it failed.

Returns:
true, if and only if the upload failed. Otherwise false.