|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.lang.Thread
wjhk.jupload2.upload.DefaultFileUploadThread
public abstract class DefaultFileUploadThread
This class is based on the FileUploadThread class. It's an abstract
class that contains the default implementation for the
FileUploadThread interface.
It contains the following abstract methods, which must be implemented in the
children classes. These methods are called in this order:
startRequest(long, boolean, int, boolean): start of the UploadRequest.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class java.lang.Thread |
|---|
Thread.State, Thread.UncaughtExceptionHandler |
| Field Summary | |
|---|---|
(package private) UploadFileData[] |
filesToUpload
This array will contain a 'copy' of the relevant element of the filesDataParam array (see the constructor). |
(package private) long |
maxChunkSize
The value of the applet parameter maxChunkSize, or its default value. |
(package private) int |
nbMaxFilesPerUpload
Maximum number of files for FTP upload. |
(package private) boolean |
stop
If set to 'true', the thread will stop the crrent upload. |
(package private) Exception |
uploadException
Thread Exception, if any occured during upload. |
(package private) UploadPolicy |
uploadPolicy
The upload policy contains all parameters needed to define the way files should be uploaded, including the URL. |
| Fields inherited from class java.lang.Thread |
|---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
| Constructor Summary | |
|---|---|
DefaultFileUploadThread(FileData[] filesDataParam,
UploadPolicy uploadPolicy,
JProgressBar progressBar)
Creates a new instance. |
|
| Method Summary | |
|---|---|
(package private) abstract void |
afterFile(int index)
Idem as beforeFile(int), but is called after each file (and
each chunks for each file). |
(package private) abstract void |
beforeFile(int index)
This method is called before sending the bytes corresponding to the file whose index is given in argument. |
(package private) abstract void |
beforeRequest(int firstFileToUploadParam,
int nbFilesToUploadParam)
This method is called before starting of each request. |
(package private) abstract void |
cleanAll()
Clean any used resource, like a 'permanent' connection. |
(package private) abstract void |
cleanRequest()
Clean any used resource of the last executed request. |
void |
close()
Closes the connection to the server and releases resources. |
(package private) abstract int |
finishRequest()
This method is called at the end of each request. |
(package private) abstract long |
getAdditionnalBytesForUpload(int indexFile)
This methods upload overhead for the file number indexFile in the filesDataParam given to the constructor. |
Exception |
getException()
Get the exception that occurs during upload. |
(package private) abstract OutputStream |
getOutputStream()
Get the output stream where the files should be written for upload. |
(package private) abstract String |
getResponseBody()
Return the the body for the server response. |
String |
getResponseMsg()
Get the server Output. |
long |
getStartTime()
Retrieve the start time of this thread. |
long |
getTotalLength()
|
long |
getUploadedLength()
|
boolean |
isUploadStopped()
Returns true if someone asks the thread to stop. |
void |
nbBytesUploaded(long nbBytes)
Used by the UploadFileData.uploadFile(java.io.OutputStream, long) for each uploaded buffer |
String |
quoteCRLF(String s)
Replace \r and \n by correctly displayed end of line characters. |
void |
run()
The heart of the program. |
(package private) void |
setResponseMsg(String msg)
Add a String that has been read from the server response. |
(package private) abstract void |
startRequest(long contentLength,
boolean bChunkEnabled,
int chunkPart,
boolean bLastChunk)
This method is called for each upload request to the server. |
void |
stopUpload()
Stopping the Thread |
| Methods inherited from class java.lang.Thread |
|---|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface wjhk.jupload2.upload.FileUploadThread |
|---|
isAlive, join, join, start |
| Field Detail |
|---|
UploadFileData[] filesToUpload
UploadFileData contained by this array.
UploadPolicy uploadPolicy
long maxChunkSize
int nbMaxFilesPerUpload
boolean stop
UploadFileData class us it.
UploadFileData.uploadFile(java.io.OutputStream, long)Exception uploadException
| Constructor Detail |
|---|
public DefaultFileUploadThread(FileData[] filesDataParam,
UploadPolicy uploadPolicy,
JProgressBar progressBar)
filesDataParam - The files to be uploaded.uploadPolicy - The upload policy to be applied.progressBar - The progressBar bar to be updated.| Method Detail |
|---|
public long getUploadedLength()
getUploadedLength in interface FileUploadThreadFileUploadThread.getUploadedLength()public long getTotalLength()
getTotalLength in interface FileUploadThreadFileUploadThread.getTotalLength()public void stopUpload()
FileUploadThread
stopUpload in interface FileUploadThreadFileUploadThread.stopUpload()public boolean isUploadStopped()
FileUploadThread
isUploadStopped in interface FileUploadThreadFileUploadThread.isUploadStopped()public String getResponseMsg()
getResponseMsg in interface FileUploadThreadpublic Exception getException()
getException in interface FileUploadThreadpublic void nbBytesUploaded(long nbBytes)
nbBytesUploaded in interface FileUploadThreadnbBytes - Number of bytes uploaded.FileUploadThread.nbBytesUploaded(long)
abstract long getAdditionnalBytesForUpload(int indexFile)
throws JUploadIOException
indexFile - The index of the file in the filesDataParam array, whose
addtional length is asked.
JUploadIOException
abstract void beforeRequest(int firstFileToUploadParam,
int nbFilesToUploadParam)
throws JUploadException
firstFileToUploadParam - nbFilesToUploadParam -
JUploadException
abstract void startRequest(long contentLength,
boolean bChunkEnabled,
int chunkPart,
boolean bLastChunk)
throws JUploadException
getOutputStream() methods
is then called to know where the uploaded files should be written.
contentLength - The total number of bytes for the files (or the
chunk) to upload in this query.bChunkEnabled - True if this upload is part of a file (can occurs
only if the maxChunkSize applet parameter is set). False
otherwise.chunkPart - The chunk number. Should be ignored if bChunkEnabled is
false.bLastChunk - True if in chunk mode, and this upload is the last one.
Should be ignored if bChunkEnabled is false.
JUploadException
abstract int finishRequest()
throws JUploadException
JUploadExceptionstartRequest(long, boolean, int, boolean)
abstract void beforeFile(int index)
throws JUploadException
index - The index of the file that will be sent just after
JUploadException
abstract void afterFile(int index)
throws JUploadException
beforeFile(int), but is called after each file (and
each chunks for each file).
index - The index of the file that was just sent.
JUploadException
abstract void cleanRequest()
throws JUploadException
JUploadException
abstract void cleanAll()
throws JUploadException
JUploadException
abstract OutputStream getOutputStream()
throws JUploadException
JUploadExceptionabstract String getResponseBody()
void setResponseMsg(String msg)
msg - The server message to be set.public final long getStartTime()
getStartTime in interface FileUploadThreadpublic final void run()
run in interface Runnablerun in class ThreadThread.run()public void close()
FileUploadThread
close in interface FileUploadThreadFileUploadThread.close()public final String quoteCRLF(String s)
s - The original string
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||