Package chemaxon.util
Class UploadThread
java.lang.Object
java.lang.Thread
chemaxon.util.UploadThread
- All Implemented Interfaces:
Runnable
Class for uploading a file from the client side to the server side via
HTML forms using a thread.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
getData()
Returns the saved data in bytes.Returns the original name of saved file.getError()
For retrieving stored exceptions.getFile()
Returns the file object.Returns the file content, if the selected file haven't been saved on the server side.Returns the name of saved file.int
Returns the size of saved file.getParameter
(String name) Returns the value of parameter posted by the HTML form.Returns the names of parameters posted by the HTML form.int
Returns the rate of saved data and whole data.boolean
Indicates if the operation was successful.boolean
Check the current state.void
run()
Starts uploading.void
setFinished
(boolean f) Finishes the upload process.void
setParams
(String type, int length, InputStream is) Setting parameters.void
setParams
(String type, int length, InputStream is, String dir) Seting parameters.void
setParams
(String type, int length, InputStream is, String dir, String tmp) Setting the parameters.Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
UploadThread
public UploadThread()
-
-
Method Details
-
setParams
Setting parameters. Calling this the file selected on the client side will be saved in a string, won't be saved as a file. The content of the file can be obtained bygetFileContent()
.- Parameters:
type
- The type of the request, can be determined by therequest.getContentType()
function.length
- The length of the request, can be determined by therequest.getContentLength()
function.is
- The inputstream of the request, can be determined by therequest.getInputStream()
function.
-
setParams
Seting parameters. Calling this the file selected on the client side will be saved on the server side with its original name.- Parameters:
type
- The type of the request, can be determined by therequest.getContentType()
method.length
- The length of the request, can be determined by therequest.getContentLength()
method.is
- The inputstream of the request, can be determined by therequest.getInputStream()
method.dir
- The directory of the server in which the file will be saved with its original name.
-
setParams
Setting the parameters. Calling this the file selected on the client side will be saved on the server side assavedFileName
.- Parameters:
type
- The type of the request, can be determined by therequest.getContentType()
funtion.length
- The length of the request, can be determined by therequest.getContentLength()
funtion.is
- The inputstream of the request, can be determined by therequest.getInputStream()
funtion.dir
- The directory of the server in which the file will be saved.tmp
- The name of the file as which it will be saved in thedir
directory.
-
getFileContent
Returns the file content, if the selected file haven't been saved on the server side.- Returns:
- the content of the file as String
-
getData
public int getData()Returns the saved data in bytes.- Returns:
- the amount of data saved.
-
getFileName
Returns the name of saved file.- Returns:
- the name of the saved file
-
getFile
Returns the file object.- Returns:
- the file
-
getFileSize
public int getFileSize()Returns the size of saved file.- Returns:
- the size of the file
-
getDefaultFileName
Returns the original name of saved file.- Returns:
- the default file name
-
getParameterNames
Returns the names of parameters posted by the HTML form.- Returns:
- an enumeration of all parameter names
-
getParameter
Returns the value of parameter posted by the HTML form.- Parameters:
name
- Name of the parameter.- Returns:
- the parameter value
-
isFinished
public boolean isFinished()Check the current state.- Returns:
true
if uploading has finished, else returnsfalse
.
-
setFinished
public void setFinished(boolean f) Finishes the upload process.- Parameters:
f
- new value for finished
-
getPercent
public int getPercent()Returns the rate of saved data and whole data.- Returns:
- current percent
-
run
public void run()Starts uploading. -
getSuccess
public boolean getSuccess()Indicates if the operation was successful.- Returns:
true
, if the file was saved successfully
-
getError
For retrieving stored exceptions.- Returns:
- the Exception, or
null
if there were no exceptions.
-