FTP Client

com.amoebacode.ftp
Class FTPCommandRegistry

java.lang.Object
  extended bycom.amoebacode.ftp.FTPCommandRegistry

public abstract class FTPCommandRegistry
extends java.lang.Object

FTPCommandRegistry includes all basic FTP commands and provides convenience methods for concatenating commands with arguments.


Field Summary
static java.lang.String ABORT_COMMAND
          "abor" - abort a file transfer
static java.lang.String ACCOUNT_COMMAND
          "acct" - send account information
static java.lang.String APPEND_COMMAND
          "appe" - append to a remote file
static java.lang.String ASCII_TRANSFER_TYPE
          "a" - ascii transfer type
static java.lang.String BINARY_TRANSFER_TYPE
          "i" - binary transfer type
static java.lang.String CHANGE_DIRECTORY_COMMAND
          "cwd" - change working directory
static java.lang.String DELETE_FILE_COMMAND
          "dele" - delete a remote file
static java.lang.String FILE_SIZE_COMMAND
          "size" - return the size of a file
static java.lang.String HELP_COMMAND
          "help" - return help on using the server
static java.lang.String LIST_FILES_COMMAND
          "list" - list remote files
static java.lang.String MAKE_DIRECTORY_COMMAND
          "mkd" - make a remote directory
static java.lang.String MODE_COMMAND
          "mode" - set transfer mode
static java.lang.String MODIFY_DATE_COMMAND
          "mdtm" - return the modification time of a file
static java.lang.String NAME_LIST_COMMAND
          "nlst" - name list of remote directory
static java.lang.String NULL_COMMAND
          "noop" - do nothing
static java.lang.String PASSIVE_MODE_COMMAND
          "pasv" - enter passive mode
static java.lang.String PASSWORD_COMMAND
          "pass" - send password
static java.lang.String PORT_COMMAND
          "port" - open a data port
static java.lang.String PRINT_DIRECTORY_COMMAND
          "pwd" - print working directory
static java.lang.String QUIT_COMMAND
          "quit" - terminate the connection
static java.lang.String REINITIALIZE_COMMAND
          "rein" - reinitialize the connection
static java.lang.String REMOVE_DIRECTORY_COMMAND
          "rmd" - remove a remote directory
static java.lang.String RENAME_FROM_COMMAND
          "rnfr - rename from
static java.lang.String RENAME_TO_COMMAND
          "rnto" - rename to
static java.lang.String RETRIEVE_COMMAND
          "retr" - retrieve a remote file
static java.lang.String SITE_COMMAND
          "site" - site-specific commands
private static java.lang.String SPACE
          a single space
static java.lang.String STATUS_COMMAND
          "stat" - return server status
static java.lang.String STORE_COMMAND
          "stor" - store a file on the remote host
static java.lang.String STORE_UNIQUE_COMMAND
          "stou" - store a file uniquely
static java.lang.String STRUCTURE_COMMAND
          "stru" - set file transfer structure
static java.lang.String SYSTEM_TYPE_COMMAND
          "syst" - return system type
static java.lang.String TRANSFER_TYPE_COMMAND
          "type" - set transfer type
static java.lang.String UP_DIRECTORY_COMMAND
          "cdup" - cwd to the parent of the current directory
static java.lang.String USERNAME_COMMAND
          "user" - send username
 
Constructor Summary
FTPCommandRegistry()
           
 
Method Summary
protected static java.lang.String getChangeDirectoryCommand(java.lang.String directory)
          Returns a change directory command for the specified directory.
private static java.lang.String getCommandWithArgument(java.lang.String command, java.lang.String argument)
          Composes a complete command from the specified command and argument.
protected static java.lang.String getDeleteFileCommand(java.lang.String fileName)
          Returns a delete file command for the specified filename.
protected static java.lang.String getFileSizeCommand(java.lang.String fileName)
          Returns a file size command for the specified filename.
protected static java.lang.String getMakeDirectoryCommand(java.lang.String directory)
          Returns a make directory command for the specified directory.
protected static java.lang.String getModifyDateCommand(java.lang.String fileName)
          Returns a modify date command for the specified filename.
protected static java.lang.String getPasswordCommand(java.lang.String password)
          Returns a password command for the specified password.
protected static java.lang.String getRemoveDirectoryCommand(java.lang.String directory)
          Returns a remove directory command for the specified directory.
protected static java.lang.String getRenameFromCommand(java.lang.String oldName)
          Returns a rename from command for the specified filename.
protected static java.lang.String getRenameToCommand(java.lang.String newName)
          Returns a rename to command for the specified filename.
protected static java.lang.String getRetrieveCommand(java.lang.String serverPath)
          Returns a retrieve command for the specified filename.
protected static java.lang.String getSiteCommand(java.lang.String siteArg)
          Returns a SITE command for the specified filename.
added by Pinellas County Government jdr 9/27/2004
protected static java.lang.String getStoreCommand(java.lang.String serverPath)
          Returns a store command for the specified filename.
private static java.lang.String getTransferType(boolean ascii)
          Converts the specified boolean to a String transfer type.
protected static java.lang.String getTransferTypeCommand(boolean ascii)
          Returns a transfer type command for the specified transfer type.
protected static java.lang.String getUsernameCommand(java.lang.String username)
          Returns a username command for the specified username.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ABORT_COMMAND

public static final java.lang.String ABORT_COMMAND
"abor" - abort a file transfer

See Also:
Constant Field Values

CHANGE_DIRECTORY_COMMAND

public static final java.lang.String CHANGE_DIRECTORY_COMMAND
"cwd" - change working directory

See Also:
Constant Field Values

DELETE_FILE_COMMAND

public static final java.lang.String DELETE_FILE_COMMAND
"dele" - delete a remote file

See Also:
Constant Field Values

LIST_FILES_COMMAND

public static final java.lang.String LIST_FILES_COMMAND
"list" - list remote files

See Also:
Constant Field Values

MODIFY_DATE_COMMAND

public static final java.lang.String MODIFY_DATE_COMMAND
"mdtm" - return the modification time of a file

See Also:
Constant Field Values

MAKE_DIRECTORY_COMMAND

public static final java.lang.String MAKE_DIRECTORY_COMMAND
"mkd" - make a remote directory

See Also:
Constant Field Values

NAME_LIST_COMMAND

public static final java.lang.String NAME_LIST_COMMAND
"nlst" - name list of remote directory

See Also:
Constant Field Values

PASSWORD_COMMAND

public static final java.lang.String PASSWORD_COMMAND
"pass" - send password

See Also:
Constant Field Values

PASSIVE_MODE_COMMAND

public static final java.lang.String PASSIVE_MODE_COMMAND
"pasv" - enter passive mode

See Also:
Constant Field Values

PORT_COMMAND

public static final java.lang.String PORT_COMMAND
"port" - open a data port

See Also:
Constant Field Values

PRINT_DIRECTORY_COMMAND

public static final java.lang.String PRINT_DIRECTORY_COMMAND
"pwd" - print working directory

See Also:
Constant Field Values

QUIT_COMMAND

public static final java.lang.String QUIT_COMMAND
"quit" - terminate the connection

See Also:
Constant Field Values

RETRIEVE_COMMAND

public static final java.lang.String RETRIEVE_COMMAND
"retr" - retrieve a remote file

See Also:
Constant Field Values

REMOVE_DIRECTORY_COMMAND

public static final java.lang.String REMOVE_DIRECTORY_COMMAND
"rmd" - remove a remote directory

See Also:
Constant Field Values

RENAME_FROM_COMMAND

public static final java.lang.String RENAME_FROM_COMMAND
"rnfr - rename from

See Also:
Constant Field Values

RENAME_TO_COMMAND

public static final java.lang.String RENAME_TO_COMMAND
"rnto" - rename to

See Also:
Constant Field Values

SITE_COMMAND

public static final java.lang.String SITE_COMMAND
"site" - site-specific commands

See Also:
Constant Field Values

FILE_SIZE_COMMAND

public static final java.lang.String FILE_SIZE_COMMAND
"size" - return the size of a file

See Also:
Constant Field Values

STORE_COMMAND

public static final java.lang.String STORE_COMMAND
"stor" - store a file on the remote host

See Also:
Constant Field Values

TRANSFER_TYPE_COMMAND

public static final java.lang.String TRANSFER_TYPE_COMMAND
"type" - set transfer type

See Also:
Constant Field Values

USERNAME_COMMAND

public static final java.lang.String USERNAME_COMMAND
"user" - send username

See Also:
Constant Field Values

ACCOUNT_COMMAND

public static final java.lang.String ACCOUNT_COMMAND
"acct" - send account information

See Also:
Constant Field Values

APPEND_COMMAND

public static final java.lang.String APPEND_COMMAND
"appe" - append to a remote file

See Also:
Constant Field Values

UP_DIRECTORY_COMMAND

public static final java.lang.String UP_DIRECTORY_COMMAND
"cdup" - cwd to the parent of the current directory

See Also:
Constant Field Values

HELP_COMMAND

public static final java.lang.String HELP_COMMAND
"help" - return help on using the server

See Also:
Constant Field Values

MODE_COMMAND

public static final java.lang.String MODE_COMMAND
"mode" - set transfer mode

See Also:
Constant Field Values

NULL_COMMAND

public static final java.lang.String NULL_COMMAND
"noop" - do nothing

See Also:
Constant Field Values

REINITIALIZE_COMMAND

public static final java.lang.String REINITIALIZE_COMMAND
"rein" - reinitialize the connection

See Also:
Constant Field Values

STATUS_COMMAND

public static final java.lang.String STATUS_COMMAND
"stat" - return server status

See Also:
Constant Field Values

STORE_UNIQUE_COMMAND

public static final java.lang.String STORE_UNIQUE_COMMAND
"stou" - store a file uniquely

See Also:
Constant Field Values

STRUCTURE_COMMAND

public static final java.lang.String STRUCTURE_COMMAND
"stru" - set file transfer structure

See Also:
Constant Field Values

SYSTEM_TYPE_COMMAND

public static final java.lang.String SYSTEM_TYPE_COMMAND
"syst" - return system type

See Also:
Constant Field Values

ASCII_TRANSFER_TYPE

public static final java.lang.String ASCII_TRANSFER_TYPE
"a" - ascii transfer type

See Also:
Constant Field Values

BINARY_TRANSFER_TYPE

public static final java.lang.String BINARY_TRANSFER_TYPE
"i" - binary transfer type

See Also:
Constant Field Values

SPACE

private static final java.lang.String SPACE
a single space

See Also:
Constant Field Values
Constructor Detail

FTPCommandRegistry

public FTPCommandRegistry()
Method Detail

getUsernameCommand

protected static java.lang.String getUsernameCommand(java.lang.String username)
Returns a username command for the specified username.

Parameters:
username - the username to send
Returns:
the complete username command

getPasswordCommand

protected static java.lang.String getPasswordCommand(java.lang.String password)
Returns a password command for the specified password.

Parameters:
password - the password to send
Returns:
the complete password command

getChangeDirectoryCommand

protected static java.lang.String getChangeDirectoryCommand(java.lang.String directory)
Returns a change directory command for the specified directory.

Parameters:
directory - the directory to change to
Returns:
the complete change directory command

getRenameFromCommand

protected static java.lang.String getRenameFromCommand(java.lang.String oldName)
Returns a rename from command for the specified filename.

Parameters:
oldName - the name of the file to rename
Returns:
the complete rename from command

getSiteCommand

protected static java.lang.String getSiteCommand(java.lang.String siteArg)
Returns a SITE command for the specified filename.
added by Pinellas County Government jdr 9/27/2004

Parameters:
siteArg - the argument for the SITE command
Returns:
the complete rename from command

getRenameToCommand

protected static java.lang.String getRenameToCommand(java.lang.String newName)
Returns a rename to command for the specified filename.

Parameters:
newName - the new name of the file
Returns:
the complete rename to command

getMakeDirectoryCommand

protected static java.lang.String getMakeDirectoryCommand(java.lang.String directory)
Returns a make directory command for the specified directory.

Parameters:
directory - the directory to create
Returns:
the complete make directory command

getRemoveDirectoryCommand

protected static java.lang.String getRemoveDirectoryCommand(java.lang.String directory)
Returns a remove directory command for the specified directory.

Parameters:
directory - the directory to delete
Returns:
the complete remove directory command

getDeleteFileCommand

protected static java.lang.String getDeleteFileCommand(java.lang.String fileName)
Returns a delete file command for the specified filename.

Parameters:
fileName - the file to delete
Returns:
the complete delete file command

getModifyDateCommand

protected static java.lang.String getModifyDateCommand(java.lang.String fileName)
Returns a modify date command for the specified filename.

Parameters:
fileName - the file to query
Returns:
the complete modify date command

getFileSizeCommand

protected static java.lang.String getFileSizeCommand(java.lang.String fileName)
Returns a file size command for the specified filename.

Parameters:
fileName - the file to query
Returns:
the complete file size command

getRetrieveCommand

protected static java.lang.String getRetrieveCommand(java.lang.String serverPath)
Returns a retrieve command for the specified filename.

Parameters:
serverPath - the file to retrieve
Returns:
the complete retrieve command

getStoreCommand

protected static java.lang.String getStoreCommand(java.lang.String serverPath)
Returns a store command for the specified filename.

Parameters:
serverPath - the file to store
Returns:
the complete store command

getTransferTypeCommand

protected static java.lang.String getTransferTypeCommand(boolean ascii)
Returns a transfer type command for the specified transfer type.

Parameters:
ascii - indicates whether ASCII transfer type should be used
Returns:
the complete transfer type command

getCommandWithArgument

private static java.lang.String getCommandWithArgument(java.lang.String command,
                                                       java.lang.String argument)
Composes a complete command from the specified command and argument.

Parameters:
command - the command to execute
argument - the argument to pass in
Returns:
the complete command

getTransferType

private static java.lang.String getTransferType(boolean ascii)
Converts the specified boolean to a String transfer type.

Parameters:
ascii - indicates whether ASCII transfer type should be used
Returns:
the corresponding transfer type String

FTP Client