chemaxon.util
Class UploadThread

java.lang.Object
  extended by java.lang.Thread
      extended by chemaxon.util.UploadThread
All Implemented Interfaces:
java.lang.Runnable

public class UploadThread
extends java.lang.Thread

Class for uploading a file from the client side to the server side via HTML forms using a thread.

Author:
Gabor Bartha

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
UploadThread()
           
 
Method Summary
 int getData()
          Returns the saved data in bytes.
 java.lang.String getDefaultFileName()
          Returns the original name of saved file.
 java.lang.Exception getError()
          For retrieving stored exceptions.
 java.io.File getFile()
          Returns the file object.
 java.lang.String getFileContent()
          Returns the file content, if the selected file haven't been saved on the server side.
 java.lang.String getFileName()
          Returns the name of saved file.
 int getFileSize()
          Returns the size of saved file.
 java.lang.String getParameter(java.lang.String name)
          Returns the value of parameter posted by the HTML form.
 java.util.Enumeration getParameterNames()
          Returns the names of parameters posted by the HTML form.
 int getPercent()
          Returns the rate of saved data and whole data.
 boolean getSuccess()
          Indicates if the operation was successful.
 boolean isFinished()
          Returns true if uploading has finished, else returns false.
 void run()
          Starts uploading.
 void setFinished(boolean f)
          Finishes the upload process.
 void setParams(java.lang.String type, int length, java.io.InputStream is)
          Setting parameters.
 void setParams(java.lang.String type, int length, java.io.InputStream is, java.lang.String dir)
          Seting parameters.
 void setParams(java.lang.String type, int length, java.io.InputStream is, java.lang.String dir, java.lang.String tmp)
          Setting the parameters.
 
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
 

Constructor Detail

UploadThread

public UploadThread()
Method Detail

setParams

public void setParams(java.lang.String type,
                      int length,
                      java.io.InputStream is)
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 by getFileContent().

Parameters:
type - The type of the request, can be determined by the request.getContentType() function.
length - The length of the request, can be determined by the request.getContentLength() function.
is - The inputstream of the request, can be determined by the request.getInputStream() function.

setParams

public void setParams(java.lang.String type,
                      int length,
                      java.io.InputStream is,
                      java.lang.String dir)
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 the request.getContentType() method.
length - The length of the request, can be determined by the request.getContentLength() method.
is - The inputstream of the request, can be determined by the request.getInputStream() method.
dir - The directory of the server in which the file will be saved with its original name.

setParams

public void setParams(java.lang.String type,
                      int length,
                      java.io.InputStream is,
                      java.lang.String dir,
                      java.lang.String tmp)
Setting the parameters. Calling this the file selected on the client side will be saved on the server side as savedFileName.

Parameters:
type - The type of the request, can be determined by the request.getContentType() funtion.
length - The length of the request, can be determined by the request.getContentLength() funtion.
is - The inputstream of the request, can be determined by the request.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 the dir directory.

getFileContent

public java.lang.String getFileContent()
Returns the file content, if the selected file haven't been saved on the server side.


getData

public int getData()
Returns the saved data in bytes.


getFileName

public java.lang.String getFileName()
Returns the name of saved file.


getFile

public java.io.File getFile()
Returns the file object.


getFileSize

public int getFileSize()
Returns the size of saved file.


getDefaultFileName

public java.lang.String getDefaultFileName()
Returns the original name of saved file.


getParameterNames

public java.util.Enumeration getParameterNames()
Returns the names of parameters posted by the HTML form.


getParameter

public java.lang.String getParameter(java.lang.String name)
Returns the value of parameter posted by the HTML form.

Parameters:
name - Name of the parameter.

isFinished

public boolean isFinished()
Returns true if uploading has finished, else returns false.


setFinished

public void setFinished(boolean f)
Finishes the upload process.


getPercent

public int getPercent()
Returns the rate of saved data and whole data.


run

public void run()
Starts uploading.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

getSuccess

public boolean getSuccess()
Indicates if the operation was successful.

Returns:
true, if the file was saved successfully

getError

public java.lang.Exception getError()
For retrieving stored exceptions.

Returns:
the Exception, or null if there were no exceptions.