net.sf.jftp.net
Class FtpConnection

java.lang.Object
  |
  +--net.sf.jftp.net.FtpConnection
All Implemented Interfaces:
BasicConnection, FtpConstants

public class FtpConnection
extends java.lang.Object
implements BasicConnection, FtpConstants

Base class. All control transactions are made here.


Field Summary
static java.lang.String ABOR
           
static java.lang.String ASCII
           
static java.lang.String BINARY
           
static java.lang.String BLOCKED
           
static java.lang.String COMPRESSED
           
static int DENIED
           
static java.lang.String DOWNLOAD
           
static java.lang.String EBCDIC
           
static java.lang.String GENERIC_FAILED
           
 boolean hasUploaded
           
static java.lang.String L8
           
static java.lang.String LOGIN_OK
           
static java.lang.String OFFLINE
           
static int R
           
static java.lang.String STREAM
           
static java.lang.String UPLOAD
           
static int W
           
 boolean work
           
static java.lang.String WRONG_LOGIN_DATA
           
 
Fields inherited from interface net.sf.jftp.net.FtpConstants
ACCT, ADAT, ALLO, APPE, AUTH, CCC, CDUP, CONF, CWD, DELE, ENC, FTP200_OK, FTP215_SYSTEM_TYPE, FTP220_SERVICE_READY, FTP221_SERVICE_CLOSING, FTP226_CLOSING_DATA_REQUEST_SUCCESSFUL, FTP227_ENTERING_PASSIVE_MODE, FTP230_LOGGED_IN, FTP250_COMPLETED, FTP257_PATH_CREATED, FTP331_USER_OK_NEED_PASSWORD, HELP, LIST, MIC, MKD, MODE, NLST, NOOP, PASS, PASV, PBSZ, PORT, PROT, PWD, QUIT, RC110, RC120, RC125, RC150, RC202, RC211, RC212, RC213, RC214, RC225, RC332, RC350, RC421, RC425, RC426, RC450, RC451, RC452, RC500, RC501, RC502, RC503, RC504, RC530, RC532, RC550, RC551, RC552, RC553, REIN, REST, RETR, RMD, RNFR, RNTO, SITE, SMNT, STAT, STOR, STOU, STRU, SYST, TYPE, USER
 
Constructor Summary
FtpConnection(java.lang.String host)
           
FtpConnection(java.lang.String host, int port, java.lang.String initCWD)
           
 
Method Summary
 void abort()
           
 void addConnectionListener(ConnectionListener l)
           
 void ascii()
          Tell server we want ascii data connections.
 void binary()
          Tell server we want binary data connections.
 boolean cdup()
          Change to the parent of the current working directory.
 boolean chdir(java.lang.String p)
          parses directory and does a chdir()
 boolean chdirNoRefresh(java.lang.String p)
          parses directory and does a chdir(), but does not send an update signal
 boolean chdirRaw(java.lang.String dirName)
          change directory, use chdir instead if you do not parse the dir correctly...
 void disconnect()
          disconnect
 void download(java.lang.String file)
          download a file
 void downloadDir(java.lang.String dir)
          recursive download of a directory
 void fireActionFinished(FtpConnection con)
          transfer is done
 void fireConnectionFailed(FtpConnection con, java.lang.String why)
          we are not logged in for some reason
 void fireConnectionInitialized(FtpConnection con)
          connection is there and user logged in
 void fireDirectoryUpdate(FtpConnection con)
          remote directory has changed
 void fireProgressUpdate(java.lang.String file, java.lang.String type, int bytes)
          progress update
 java.lang.String getCachedPWD()
          gets current remote directory (cached)
 ConnectionHandler getConnectionHandler()
           
 DataConnection getDataConnection()
           
 java.lang.String getHost()
           
 java.lang.String getLine(java.lang.String until)
          reads until line found or error
 java.lang.String getLine(java.lang.String[] until)
          reads until line found or error
 java.lang.String getLocalPath()
          get the local cwd
 java.lang.String getOsType()
          try to determine the os-type to properly parse the ls-output
 java.lang.String getPassword()
           
 int[] getPermissions(java.lang.String file)
          sorts the filesizes
 int getPort()
           
 java.lang.String getPWD()
          gets current remote directory
 java.lang.String getTypeNow()
           
 java.lang.String getUsername()
           
 void handleDownload(java.lang.String file)
           
 void handleUpload(java.lang.String file)
           
 boolean isConnected()
           
 void list(java.lang.String outfile)
          lists remote directory
 java.lang.String login(java.lang.String username, java.lang.String password)
          connects to the server.
 boolean mkdir(java.lang.String dirName)
          create a directory
 java.lang.String mode(java.lang.String code)
           
 void modeBlocked()
          unsupported at this time
 void modeCompressed()
           
 void modeStream()
           
 void noop()
          do nothing, but flush buffers
 void pause(int time)
          waits a specified amount of time (in milliseconds)
 void removeFileOrDir(java.lang.String file)
          remove a remote file or directory
 void sendRawCommand(java.lang.String cmd)
          execute noop -> command -> noop
 void setConnectionHandler(ConnectionHandler h)
           
 void setConnectionListeners(java.util.Vector l)
           
 boolean setLocalPath(java.lang.String newPath)
          set the path downloaded to
 java.lang.String[] sortLs(java.lang.String file)
          parses the ls-output
 java.lang.String[] sortSize(java.lang.String file)
          sorts the filesizes
 java.lang.String system()
          This command is used to find out the type of operating system at the server.
 boolean type(java.lang.String code)
           
 void upload(java.lang.String file)
           
 void uploadDir(java.lang.String dir)
          uploads a directory recursively
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WRONG_LOGIN_DATA

public static final java.lang.String WRONG_LOGIN_DATA
See Also:
Constant Field Values

OFFLINE

public static final java.lang.String OFFLINE
See Also:
Constant Field Values

GENERIC_FAILED

public static final java.lang.String GENERIC_FAILED
See Also:
Constant Field Values

LOGIN_OK

public static final java.lang.String LOGIN_OK
See Also:
Constant Field Values

DOWNLOAD

public static final java.lang.String DOWNLOAD
See Also:
Constant Field Values

UPLOAD

public static final java.lang.String UPLOAD
See Also:
Constant Field Values

ABOR

public static final java.lang.String ABOR
See Also:
Constant Field Values

R

public static final int R
See Also:
Constant Field Values

W

public static final int W
See Also:
Constant Field Values

DENIED

public static final int DENIED
See Also:
Constant Field Values

work

public boolean work

hasUploaded

public boolean hasUploaded

ASCII

public static final java.lang.String ASCII
See Also:
Constant Field Values

BINARY

public static final java.lang.String BINARY
See Also:
Constant Field Values

EBCDIC

public static final java.lang.String EBCDIC
See Also:
Constant Field Values

L8

public static final java.lang.String L8
See Also:
Constant Field Values

STREAM

public static final java.lang.String STREAM
See Also:
Constant Field Values

BLOCKED

public static final java.lang.String BLOCKED
See Also:
Constant Field Values

COMPRESSED

public static final java.lang.String COMPRESSED
See Also:
Constant Field Values
Constructor Detail

FtpConnection

public FtpConnection(java.lang.String host)

FtpConnection

public FtpConnection(java.lang.String host,
                     int port,
                     java.lang.String initCWD)
Method Detail

login

public java.lang.String login(java.lang.String username,
                              java.lang.String password)
connects to the server.


sortSize

public java.lang.String[] sortSize(java.lang.String file)
sorts the filesizes

Specified by:
sortSize in interface BasicConnection

getPermissions

public int[] getPermissions(java.lang.String file)
sorts the filesizes

Specified by:
getPermissions in interface BasicConnection

sortLs

public java.lang.String[] sortLs(java.lang.String file)
parses the ls-output

Specified by:
sortLs in interface BasicConnection

getOsType

public java.lang.String getOsType()
try to determine the os-type to properly parse the ls-output


handleDownload

public void handleDownload(java.lang.String file)
Specified by:
handleDownload in interface BasicConnection

download

public void download(java.lang.String file)
download a file

Specified by:
download in interface BasicConnection

downloadDir

public void downloadDir(java.lang.String dir)
recursive download of a directory


handleUpload

public void handleUpload(java.lang.String file)
Specified by:
handleUpload in interface BasicConnection

upload

public void upload(java.lang.String file)
Specified by:
upload in interface BasicConnection

uploadDir

public void uploadDir(java.lang.String dir)
uploads a directory recursively


removeFileOrDir

public void removeFileOrDir(java.lang.String file)
remove a remote file or directory

Specified by:
removeFileOrDir in interface BasicConnection

disconnect

public void disconnect()
disconnect

Specified by:
disconnect in interface BasicConnection

sendRawCommand

public void sendRawCommand(java.lang.String cmd)
execute noop -> command -> noop

Specified by:
sendRawCommand in interface BasicConnection

getLine

public java.lang.String getLine(java.lang.String until)
reads until line found or error


getLine

public java.lang.String getLine(java.lang.String[] until)
reads until line found or error


isConnected

public boolean isConnected()
Specified by:
isConnected in interface BasicConnection

getPWD

public java.lang.String getPWD()
gets current remote directory

Specified by:
getPWD in interface BasicConnection

getCachedPWD

public java.lang.String getCachedPWD()
gets current remote directory (cached)


chdirRaw

public boolean chdirRaw(java.lang.String dirName)
change directory, use chdir instead if you do not parse the dir correctly...


cdup

public boolean cdup()
Change to the parent of the current working directory. The CDUP command is a special case of CWD, and is included to simplify the implementation of programs for transferring directory trees between operating systems having different syntaxes for naming the parent directory.

Specified by:
cdup in interface BasicConnection

mkdir

public boolean mkdir(java.lang.String dirName)
create a directory

Specified by:
mkdir in interface BasicConnection

list

public void list(java.lang.String outfile)
          throws java.io.IOException
lists remote directory

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

chdir

public boolean chdir(java.lang.String p)
parses directory and does a chdir()

Specified by:
chdir in interface BasicConnection

chdirNoRefresh

public boolean chdirNoRefresh(java.lang.String p)
parses directory and does a chdir(), but does not send an update signal

Specified by:
chdirNoRefresh in interface BasicConnection

pause

public void pause(int time)
waits a specified amount of time (in milliseconds)


getLocalPath

public java.lang.String getLocalPath()
get the local cwd

Specified by:
getLocalPath in interface BasicConnection

setLocalPath

public boolean setLocalPath(java.lang.String newPath)
set the path downloaded to

Specified by:
setLocalPath in interface BasicConnection

getPort

public int getPort()

binary

public void binary()
Tell server we want binary data connections.


ascii

public void ascii()
Tell server we want ascii data connections.


type

public boolean type(java.lang.String code)

getTypeNow

public java.lang.String getTypeNow()

noop

public void noop()
do nothing, but flush buffers


abort

public void abort()

system

public java.lang.String system()
This command is used to find out the type of operating system at the server. The reply shall have as its first word one of the system names listed in the current version of the Assigned Numbers document (RFC 943).


modeStream

public void modeStream()

modeBlocked

public void modeBlocked()
unsupported at this time


modeCompressed

public void modeCompressed()

mode

public java.lang.String mode(java.lang.String code)

getHost

public java.lang.String getHost()

getUsername

public java.lang.String getUsername()

getPassword

public java.lang.String getPassword()

getDataConnection

public DataConnection getDataConnection()

addConnectionListener

public void addConnectionListener(ConnectionListener l)
Specified by:
addConnectionListener in interface BasicConnection

setConnectionListeners

public void setConnectionListeners(java.util.Vector l)
Specified by:
setConnectionListeners in interface BasicConnection

fireDirectoryUpdate

public void fireDirectoryUpdate(FtpConnection con)
remote directory has changed


fireProgressUpdate

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


fireConnectionInitialized

public void fireConnectionInitialized(FtpConnection con)
connection is there and user logged in


fireConnectionFailed

public void fireConnectionFailed(FtpConnection con,
                                 java.lang.String why)
we are not logged in for some reason


fireActionFinished

public void fireActionFinished(FtpConnection con)
transfer is done


getConnectionHandler

public ConnectionHandler getConnectionHandler()

setConnectionHandler

public void setConnectionHandler(ConnectionHandler h)