FileTransfer.v1_1
Class FTClientWindow.TransferThread

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--FileTransfer.v1_1.FTClientWindow.TransferThread
All Implemented Interfaces:
java.lang.Runnable
Enclosing class:
FTClientWindow

class FTClientWindow.TransferThread
extends java.lang.Thread

TransferThread extends Thread. It is in charge of transfering a file from this FTClient to another one. If first ask wether the other user accepts the file this user wants to send him. If he accepts, the file is read and parts of the file are sent one at a time to the other user in the form of byte arrays. The size of the byte array is defined by the bytesize property. These operations are performed in a separate thread so that the EventDispatchThread that is in charge of handling GUI events is releaved and can continue.

It is also in charge of resuming a filetransfer. This is specified in the constructor. It uses the bytesTransferred property to know how where to restart the filetransfer.


Field Summary
private  int bytesTransferred
           
private  boolean finished
          Specifies wether the thread should continue or stop.
private  boolean shallResume
           
private  FTClientWindow window
          Reference to the FTClientWindow.
 
Fields inherited from class java.lang.Thread
contextClassLoader, daemon, eetop, group, inheritableThreadLocals, inheritedAccessControlContext, MAX_PRIORITY, MIN_PRIORITY, name, NORM_PRIORITY, priority, single_step, stillborn, stopThreadPermission, target, threadInitNumber, threadLocals, threadQ
 
Constructor Summary
FTClientWindow.TransferThread(FTClientWindow window, boolean shallResume)
          Creates a new TransferThread.
 
Method Summary
private  void resumeTransfer()
          Resumes a suspended filetransfer.
 void run()
          Checks which one of the XXXTransfer methods to call and calls it.
 void setBytesTransferred(int b)
          Sets how much of a file that has been transferred.
 void setFinished(boolean b)
          Called when the user wants the filetransfer to stop before it is finished.
private  void startTransfer()
          Starts a new filetransfer.
 
Methods inherited from class java.lang.Thread
, activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, exit, getContextClassLoader, getName, getPriority, getThreadGroup, init, interrupt, interrupt0, interrupted, isAlive, isDaemon, isInterrupted, isInterrupted, join, join, join, nextThreadNum, registerNatives, resume, resume0, setContextClassLoader, setDaemon, setName, setPriority, setPriority0, sleep, sleep, start, stop, stop, stop0, suspend, suspend0, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

finished

private boolean finished
Specifies wether the thread should continue or stop.

window

private FTClientWindow window
Reference to the FTClientWindow.

shallResume

private boolean shallResume

bytesTransferred

private int bytesTransferred
Constructor Detail

FTClientWindow.TransferThread

public FTClientWindow.TransferThread(FTClientWindow window,
                                     boolean shallResume)
Creates a new TransferThread.
Parameters:
window - Reference to the FTClientWindow.
shallResume - Specifies wether a new filetransfer shall be started or a suspended on shall be resumed.
Method Detail

run

public void run()
Checks which one of the XXXTransfer methods to call and calls it.
Overrides:
run in class java.lang.Thread

setBytesTransferred

public void setBytesTransferred(int b)
Sets how much of a file that has been transferred. Used when a filetransfer shall be resumed.
Parameters:
b - The amount.

setFinished

public void setFinished(boolean b)
Called when the user wants the filetransfer to stop before it is finished. Sets the finished property to the specified value. This is checked by this thread before sending a new filepart.

resumeTransfer

private void resumeTransfer()
Resumes a suspended filetransfer.

startTransfer

private void startTransfer()
Starts a new filetransfer.