ip1.ex14
Class JFtp

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--ip1.ex14.JFtpThread
              |
              +--ip1.ex14.JFtp
All Implemented Interfaces:
java.lang.Runnable

public class JFtp
extends JFtpThread

JFtp is a multi-threaded graphical FTP client. The JFtp class implements the program's main thread which handles user itneraction and can fire up FTP control threads.

Version:
$Id: JFtp.java,v 1.40 2003/10/17 14:03:39 sharky Exp $
See Also:
JFtpThread, JFtpControl

Nested Class Summary
(package private)  class JFtp.RefreshTask
          A TimerTask to refresh JFtp's thread view.
 class JFtp.RootQueueItem
           
 
Nested classes inherited from class ip1.ex14.JFtpThread
 
Field Summary
protected  int argMaxThreads
          Do we use multithread?
protected  boolean argPassive
          Do we use passive mode ?
protected  java.lang.String argUrl
          Initial URL.
protected  java.io.File localDir
          The local working directory.
protected  JFtpWindow mainWindow
          JFtp's main window.
protected static java.lang.String version
          Program version.
 
Fields inherited from class ip1.ex14.JFtpThread
children, counter, id, node, parent, queue, state, STATE_EXITED, STATE_NOTRUNNING, STATE_SHUTDOWN, threadTree, threadTreeChanged, type
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
JFtp(java.lang.String[] argv)
          The constructor parses the command line arguments.
 
Method Summary
protected  void connect(java.net.URL u)
          Connects to an FTP server.
 void debug(java.lang.String msg)
          Displays a message both in applet and standard output.
protected  void delete(JFtpEntry entry)
          Delete a file.
protected  void dispRemote(java.util.Vector contents)
          Change the contents of the remote file list.
private  boolean download(JFtpEntry entry)
          Download a file.
private  JFtpControl getAuxControl(java.net.URL url)
          Return an auxilary control connection.
protected  JFtpControl getControl()
          Return the active control connection.
 void localCwd(java.lang.String dir)
          Change the local working directory.
static void main(java.lang.String[] argv)
          The program's main routine.
 void queueDownload(JFtpEntry entry)
          Queue the download of a file.
 void queueUpload(JFtpEntry entry)
          Queue the upload of a file.
protected  void refreshLocalList()
          Refresh local file list.
protected  void refreshRemoteList()
          Refresh the remote file list.
protected  void refreshUrl()
          Change the current URL in the window.
protected  void removeChild(JFtpControl theThread)
          Remove a control thread.
 void run()
          Thread entry point.
protected  void setPassive(boolean passive)
          Set active or passive mode.
private  boolean upload(JFtpEntry entry)
          Upload a file.
private  void usage()
          Display program usage.
 
Methods inherited from class ip1.ex14.JFtpThread
addChild, addQueue, dumpQueue, getChild, getRoot, isBusy, peekQueue, propagateTreeChange, queueShutdown, readQueue, refreshNode, refreshThreadView, removeChild, reset, shutdown, toString, waitShutdown
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

version

protected static final java.lang.String version
Program version.

See Also:
Constant Field Values

mainWindow

protected JFtpWindow mainWindow
JFtp's main window.


argUrl

protected java.lang.String argUrl
Initial URL.


argPassive

protected boolean argPassive
Do we use passive mode ?


argMaxThreads

protected int argMaxThreads
Do we use multithread?


localDir

protected java.io.File localDir
The local working directory.

Constructor Detail

JFtp

public JFtp(java.lang.String[] argv)
The constructor parses the command line arguments.

Parameters:
argv - the command line arguments
Method Detail

debug

public void debug(java.lang.String msg)
Displays a message both in applet and standard output.

Overrides:
debug in class JFtpThread
Parameters:
msg - the message to print

download

private boolean download(JFtpEntry entry)
Download a file.


delete

protected void delete(JFtpEntry entry)
Delete a file.

Parameters:
entry - the entry to delete
See Also:
JFtpWindow.actionPerformed(java.awt.event.ActionEvent)

dispRemote

protected void dispRemote(java.util.Vector contents)
Change the contents of the remote file list.


localCwd

public void localCwd(java.lang.String dir)
Change the local working directory.

Parameters:
dir - the directory to change to

getAuxControl

private JFtpControl getAuxControl(java.net.URL url)
Return an auxilary control connection.

See Also:
getControl()

getControl

protected JFtpControl getControl()
Return the active control connection.

See Also:
getAuxControl(java.net.URL)

main

public static void main(java.lang.String[] argv)
The program's main routine.

See Also:
run()

connect

protected void connect(java.net.URL u)
Connects to an FTP server.

Parameters:
u - the URL to connect to
See Also:
JFtpWindow.actionPerformed(java.awt.event.ActionEvent)

queueDownload

public void queueDownload(JFtpEntry entry)
Queue the download of a file.

See Also:
download(ip1.ex14.JFtpEntry), JFtpWindow.actionPerformed(java.awt.event.ActionEvent)

queueUpload

public void queueUpload(JFtpEntry entry)
Queue the upload of a file.

Parameters:
entry - the entry to upload
See Also:
upload(ip1.ex14.JFtpEntry), JFtpWindow.actionPerformed(java.awt.event.ActionEvent)

removeChild

protected void removeChild(JFtpControl theThread)
Remove a control thread.

See Also:
JFtpThread.removeChild(ip1.ex14.JFtpThread), refreshRemoteList()

refreshLocalList

protected void refreshLocalList()
Refresh local file list.

See Also:
JFtpWindow.actionPerformed(java.awt.event.ActionEvent)

refreshRemoteList

protected void refreshRemoteList()
Refresh the remote file list.

See Also:
dispRemote(java.util.Vector), JFtpControl.queueList()

refreshUrl

protected void refreshUrl()
Change the current URL in the window.


run

public void run()
Thread entry point.

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

setPassive

protected void setPassive(boolean passive)
Set active or passive mode.


upload

private boolean upload(JFtpEntry entry)
Upload a file.

See Also:
queueUpload(ip1.ex14.JFtpEntry)

usage

private void usage()
Display program usage.