net.sf.jftp.net
Class FilesystemConnection

java.lang.Object
  extended by net.sf.jftp.net.FilesystemConnection
All Implemented Interfaces:
BasicConnection

public class FilesystemConnection
extends java.lang.Object
implements BasicConnection


Field Summary
 java.util.Vector<java.util.Date> dateVector
           
static int filesystemBuffer
           
 
Constructor Summary
FilesystemConnection()
           
FilesystemConnection(java.lang.String path, ConnectionListener l)
           
 
Method Summary
 void addConnectionListener(ConnectionListener l)
          Add a ConnectionListener to be notified about progress and events.
 boolean cdup()
          Go up one directory if possible.
 boolean chdir(java.lang.String p)
          Change dircetory and inform listeners.
 boolean chdirNoRefresh(java.lang.String p)
          Change directory, but do not trigger an event for the listeners.
 void disconnect()
          Teminates the connection if necessary.
 int download(java.lang.String file)
          Initiate a download in the same thread.
 void fireDirectoryUpdate()
          remote directory has changed
 void fireProgressUpdate(java.lang.String file, java.lang.String type, int bytes)
           
 java.io.InputStream getDownloadInputStream(java.lang.String file)
          Initiate a download and return the content in form of an InputStream.
 java.lang.String getLocalPath()
          Get the path downloaded to.
 int[] getPermissions()
          Get file/dir permissions.
 java.lang.String getPWD()
          Get the current working dir.
 int handleDownload(java.lang.String file)
          Initiate a download, possibly non-blocking and in a new thread.
 int handleUpload(java.lang.String file)
          Initiate an upload, possibly non-blocking and in a new thread.
 boolean isConnected()
          Shows if the Connection is alive and initialized.
 void list()
          Perform any necessary actions so sortLs, sortSize and sortDates are up-to-date.
 boolean login(java.lang.String user, java.lang.String pass)
           
 boolean mkdir(java.lang.String dirName)
          Create a new directory.
 java.lang.String processPath(java.lang.String p)
           
 int removeFileOrDir(java.lang.String file)
          Remove the given item, recursively if necessary.
 boolean rename(java.lang.String file, java.lang.String to)
          Rename a file or directory.
 void sendRawCommand(java.lang.String cmd)
          Some Connections like FTP may allow raw command to be sent, use this method.
 void setConnectionListeners(java.util.Vector<ConnectionListener> l)
          Remove a ConnectionListener.
 boolean setLocalPath(java.lang.String p)
          Set the path downloded to.
 java.util.Date[] sortDates()
          Get file dates.
 java.lang.String[] sortLs()
          Get file and diretory names.
 java.lang.String[] sortSize()
          Get file sizes.
 int upload(java.lang.String file)
          Initiate an upload in the same thread.
 int upload(java.lang.String file, java.io.InputStream in)
          Initiate a download in the same thread.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

filesystemBuffer

public static int filesystemBuffer

dateVector

public java.util.Vector<java.util.Date> dateVector
Constructor Detail

FilesystemConnection

public FilesystemConnection()

FilesystemConnection

public FilesystemConnection(java.lang.String path,
                            ConnectionListener l)
Method Detail

removeFileOrDir

public int removeFileOrDir(java.lang.String file)
Description copied from interface: BasicConnection
Remove the given item, recursively if necessary.

Specified by:
removeFileOrDir in interface BasicConnection
Returns:

sendRawCommand

public void sendRawCommand(java.lang.String cmd)
Description copied from interface: BasicConnection
Some Connections like FTP may allow raw command to be sent, use this method. Implementation is optional.

Specified by:
sendRawCommand in interface BasicConnection

disconnect

public void disconnect()
Description copied from interface: BasicConnection
Teminates the connection if necessary.

Specified by:
disconnect in interface BasicConnection

isConnected

public boolean isConnected()
Description copied from interface: BasicConnection
Shows if the Connection is alive and initialized.

Specified by:
isConnected in interface BasicConnection
Returns:

getPWD

public java.lang.String getPWD()
Description copied from interface: BasicConnection
Get the current working dir.

Specified by:
getPWD in interface BasicConnection
Returns:

cdup

public boolean cdup()
Description copied from interface: BasicConnection
Go up one directory if possible.

Specified by:
cdup in interface BasicConnection
Returns:

mkdir

public boolean mkdir(java.lang.String dirName)
Description copied from interface: BasicConnection
Create a new directory.

Specified by:
mkdir in interface BasicConnection
Returns:

list

public void list()
          throws java.io.IOException
Description copied from interface: BasicConnection
Perform any necessary actions so sortLs, sortSize and sortDates are up-to-date. Implementation is optional.

Specified by:
list in interface BasicConnection
Throws:
java.io.IOException

chdir

public boolean chdir(java.lang.String p)
Description copied from interface: BasicConnection
Change dircetory and inform listeners.

Specified by:
chdir in interface BasicConnection
Returns:

chdirNoRefresh

public boolean chdirNoRefresh(java.lang.String p)
Description copied from interface: BasicConnection
Change directory, but do not trigger an event for the listeners.

Specified by:
chdirNoRefresh in interface BasicConnection
Returns:

getLocalPath

public java.lang.String getLocalPath()
Description copied from interface: BasicConnection
Get the path downloaded to.

Specified by:
getLocalPath in interface BasicConnection
Returns:

processPath

public java.lang.String processPath(java.lang.String p)

setLocalPath

public boolean setLocalPath(java.lang.String p)
Description copied from interface: BasicConnection
Set the path downloded to.

Specified by:
setLocalPath in interface BasicConnection
Returns:

sortLs

public java.lang.String[] sortLs()
Description copied from interface: BasicConnection
Get file and diretory names.

Specified by:
sortLs in interface BasicConnection
Returns:

sortSize

public java.lang.String[] sortSize()
Description copied from interface: BasicConnection
Get file sizes.

Specified by:
sortSize in interface BasicConnection
Returns:

getPermissions

public int[] getPermissions()
Description copied from interface: BasicConnection
Get file/dir permissions.

Specified by:
getPermissions in interface BasicConnection
Returns:

handleDownload

public int handleDownload(java.lang.String file)
Description copied from interface: BasicConnection
Initiate a download, possibly non-blocking and in a new thread.

Specified by:
handleDownload in interface BasicConnection
Returns:

handleUpload

public int handleUpload(java.lang.String file)
Description copied from interface: BasicConnection
Initiate an upload, possibly non-blocking and in a new thread.

Specified by:
handleUpload in interface BasicConnection
Returns:

download

public int download(java.lang.String file)
Description copied from interface: BasicConnection
Initiate a download in the same thread.

Specified by:
download in interface BasicConnection
Returns:

upload

public int upload(java.lang.String file)
Description copied from interface: BasicConnection
Initiate an upload in the same thread.

Specified by:
upload in interface BasicConnection
Returns:

upload

public int upload(java.lang.String file,
                  java.io.InputStream in)
Description copied from interface: BasicConnection
Initiate a download in the same thread. The InptuStream provides the date, file the remote file name.

Specified by:
upload in interface BasicConnection
Returns:

getDownloadInputStream

public java.io.InputStream getDownloadInputStream(java.lang.String file)
Description copied from interface: BasicConnection
Initiate a download and return the content in form of an InputStream.

Specified by:
getDownloadInputStream in interface BasicConnection
Returns:

addConnectionListener

public void addConnectionListener(ConnectionListener l)
Description copied from interface: BasicConnection
Add a ConnectionListener to be notified about progress and events.

Specified by:
addConnectionListener in interface BasicConnection

setConnectionListeners

public void setConnectionListeners(java.util.Vector<ConnectionListener> l)
Description copied from interface: BasicConnection
Remove a ConnectionListener.

Specified by:
setConnectionListeners in interface BasicConnection

fireDirectoryUpdate

public void fireDirectoryUpdate()
remote directory has changed


login

public boolean login(java.lang.String user,
                     java.lang.String pass)

fireProgressUpdate

public void fireProgressUpdate(java.lang.String file,
                               java.lang.String type,
                               int bytes)

sortDates

public java.util.Date[] sortDates()
Description copied from interface: BasicConnection
Get file dates.

Specified by:
sortDates in interface BasicConnection
Returns:

rename

public boolean rename(java.lang.String file,
                      java.lang.String to)
Description copied from interface: BasicConnection
Rename a file or directory.

Specified by:
rename in interface BasicConnection
Returns: