wjhk.jupload2.upload
Interface FileUploadManagerThread

All Known Implementing Classes:
FileUploadManagerThreadImpl

public interface FileUploadManagerThread

Author:
etienne_sf

Field Summary
static int UPLOAD_STATUS_CHUNK_UPLOADED_WAITING_FOR_RESPONSE
          A chunk (a part) of the file identified by numOfFileInCurrentRequest has been sent.
static int UPLOAD_STATUS_FILE_UPLOADED_WAITING_FOR_RESPONSE
          All data for the file identified by numOfFileInCurrentRequest has been sent.
static int UPLOAD_STATUS_NOT_STARTED
          Indicates that nothings has begun
static int UPLOAD_STATUS_UPLOADED
          The upload for the file identified by numOfFileInCurrentRequest is finished
static int UPLOAD_STATUS_UPLOADING
          We're sending data to the server, for the file identified by numOfFileInCurrentRequest.
 
Method Summary
 void anotherFileHasBeenSent(UploadFilePacket uploadFilePacket, UploadFileData newlyUploadedFileData)
          This method is called each time a new file is sent to the server.
 void currentRequestIsFinished(UploadFilePacket packet)
          This method is called when the server response for the upload indicates a success.
 JUploadException getUploadException()
          Get the last upload exception that occurs.
 void interrupt()
          Check if the thread is running...
 boolean isAlive()
          Check if the thread is running...
 boolean isUploadFinished()
          Indicates whether the upload is finished or not.
 void join()
          The heart of the program.
 void nbBytesUploaded(long nbBytes, UploadFileData uploadFileData)
          Used by the UploadFileData#uploadFile(java.io.OutputStream, long) for each uploaded buffer
 void run()
          The heart of the program.
 void setUploadException(JUploadException uploadException)
          Stores the last upload exception that occurs.
 void setUploadStatus(UploadFilePacket uploadFilePacket, UploadFileData uploadFileData, int uploadStatus)
          Indicate the current state of the upload, to allow a correct display of UPLOAD_STATUS_UPLOADED status. the upload progress bar.
 void start()
          The heart of the program.
 void stopUpload()
          Reaction to the user click on the 'Stop' button, or any action from the user asking to stop the upload.
 

Field Detail

UPLOAD_STATUS_NOT_STARTED

static final int UPLOAD_STATUS_NOT_STARTED
Indicates that nothings has begun

See Also:
Constant Field Values

UPLOAD_STATUS_UPLOADING

static final int UPLOAD_STATUS_UPLOADING
We're sending data to the server, for the file identified by numOfFileInCurrentRequest.

See Also:
Constant Field Values

UPLOAD_STATUS_CHUNK_UPLOADED_WAITING_FOR_RESPONSE

static final int UPLOAD_STATUS_CHUNK_UPLOADED_WAITING_FOR_RESPONSE
A chunk (a part) of the file identified by numOfFileInCurrentRequest has been sent. But the server response has not been received yet.

See Also:
Constant Field Values

UPLOAD_STATUS_FILE_UPLOADED_WAITING_FOR_RESPONSE

static final int UPLOAD_STATUS_FILE_UPLOADED_WAITING_FOR_RESPONSE
All data for the file identified by numOfFileInCurrentRequest has been sent. But the server response has not been received yet.

See Also:
Constant Field Values

UPLOAD_STATUS_UPLOADED

static final int UPLOAD_STATUS_UPLOADED
The upload for the file identified by numOfFileInCurrentRequest is finished

See Also:
Constant Field Values
Method Detail

join

void join()
          throws InterruptedException
The heart of the program. This method prepare the upload, then calls doUpload for each HTTP request.

Throws:
InterruptedException
See Also:
Thread.join()

run

void run()
The heart of the program. This method prepare the upload, then calls doUpload for each HTTP request.

See Also:
Thread.run()

start

void start()
The heart of the program. This method prepare the upload, then calls doUpload for each HTTP request.

See Also:
Thread.start()

interrupt

void interrupt()
Check if the thread is running...

See Also:
Thread.interrupt()

isAlive

boolean isAlive()
Check if the thread is running...

Returns:
True if it's running
See Also:
Thread.isAlive()

setUploadException

void setUploadException(JUploadException uploadException)
Stores the last upload exception that occurs. This method won't write to the log file.

Parameters:
uploadException -

getUploadException

JUploadException getUploadException()
Get the last upload exception that occurs.

Returns:
The last upload exception, or null if no exception occurs.

isUploadFinished

boolean isUploadFinished()
Indicates whether the upload is finished or not. As several conditions can make the upload being finished (all files uploaded, an error occured, the user stops the upload), a specific boolean is built. It's managed by the run() method.

Returns:
true if the upload is finished. False otherwise.

nbBytesUploaded

void nbBytesUploaded(long nbBytes,
                     UploadFileData uploadFileData)
                     throws JUploadException
Used by the UploadFileData#uploadFile(java.io.OutputStream, long) for each uploaded buffer

Parameters:
nbBytes - Number of additional bytes that where uploaded.
uploadFileData - The file that is currently being uploade (or null if no file is being uploaded)
Throws:
JUploadException

setUploadStatus

void setUploadStatus(UploadFilePacket uploadFilePacket,
                     UploadFileData uploadFileData,
                     int uploadStatus)
                     throws JUploadException
Indicate the current state of the upload, to allow a correct display of UPLOAD_STATUS_UPLOADED status. the upload progress bar.

Parameters:
uploadFilePacket - The current packet. This parameter is mandatory only for the
uploadFileData - The file whose upload begins, is going on or is finished.
uploadStatus -
Throws:
JUploadException

stopUpload

void stopUpload()
Reaction to the user click on the 'Stop' button, or any action from the user asking to stop the upload. The upload should go on for the current file, and stop before starting the next upload request to the server, to avoid strange problems on the server.


anotherFileHasBeenSent

void anotherFileHasBeenSent(UploadFilePacket uploadFilePacket,
                            UploadFileData newlyUploadedFileData)
                            throws JUploadException
This method is called each time a new file is sent to the server. It's main aim is to allow a proper display of the progress bar. It is public, as upload is done in another thread, whose class maybe in another package.

Parameters:
uploadFilePacket -
newlyUploadedFileData -
Throws:
JUploadException

currentRequestIsFinished

void currentRequestIsFinished(UploadFilePacket packet)
                              throws JUploadException
This method is called when the server response for the upload indicates a success. It is public, as upload is done in another thread, whose class maybe in another package.

Parameters:
packet - The packet of files that was successfully uploaded.
Throws:
JUploadException