org.finj
Class FTPCommand
java.lang.Object
org.finj.FTPCommand
public class FTPCommand
- extends java.lang.Object
This class contains constants and methods that simplify handling
and internationalization of FTP client commands.
Commands according to RFC959-4.1 http://www.ietf.org/rfc/rfc0959.txt
(October 1995).
Copyright (C) 2000-2008 Javier Iglesias.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- Version:
- $Id: FTPCommand.java 57 2009-07-21 22:59:27Z jiglesias $
- Author:
- Javier Iglesias -- jiglesias@users.sourceforge.net
Field Summary |
static int |
ABORT
This command tells the server to abort the previous
FTP service command and any associated transfer of data. |
static int |
ACCOUNT
The argument field is a Telnet string identifying the
user's account. |
static int |
ALLOCATE
This command may be required by some servers to reserve
sufficient storage to accommodate the new file to be
transferred. |
static int |
APPEND_WITH_CREATE
This command causes the server-DTP to accept the data
transferred via the data connection and to store the data
in a file at the server site. |
static int |
CHANGE_TO_PARENT_DIRECTORY
This command is a special cas of CHANGE_WORKING_DIRECTORY,
and is included to simplify the implementation of programs
for transferring directory trees between operating systems having
different syntaxes for naming the parent directory. |
static int |
CHANGE_WORKING_DIRECTORY
This command allows the user to work with a different
directory or dataset for file storage or retrieval without
altering his login or accounting information. |
static int |
DATA_PORT
The argument is a host-port specification for the
data port to be userd in data connection. |
static int |
DELETE_FILE
This command causes the file specified in the pathname
to be deleted at the server site. |
static int |
FILE_STRUCTURE
The argument is a single Telnet character code specifying
file structure described in the section on Data Representation
and Storage of RFC959. |
static int |
HELP
This command shall cause the server to send helpful
information regarding its implementation status over the
control connection to the user. |
static int |
LIST
This command causes a list to be sent from the server to
the passive DTP. |
static int |
LOGOUT
This command terminates a USER_NAME and if
file transfer is not in progress, the server closes
the control connection. |
static int |
MAKE_DIRECTORY
This command causes the directory specified in the pathname
to be created as a directory (if the pathname is absolute)
or as a subdirectory of the current working directory (if
the pathname is relative). |
static int |
NAME_LIST
This command causes a directory listing to be sent from
server to user site. |
static int |
NO_OPERATION
This command does not affect any parameters or previously
entered commands. |
static int |
PASSIVE
This command requests the server-DTP to "listen" on
a data port (which is not its default data port)
and to wait for a connection rather that initiate
one upon receipt of a transfer command. |
static int |
PASSWORD
The argument field is a Telnet string specifying the
user's password. |
static int |
PRINT_WORKING_DIRECTORY
This command causes the name of the current directory
to be returned in the response. |
static int |
REINITIALIZE
This command terminates a USER_NAME, flushing
all I/O and account information, except to allow any
transfer in progress to be completed. |
static int |
REMOVE_DIRECTORY
This command causes the directory specified in the
pathname to be removed as a directory (if the pathname
is absolute) or as a subdirectory of the current working
directory (if the pathname is relative). |
static int |
RENAME_FROM
This command specifies the old pathname of the file
which is to be renamed. |
static int |
RENAME_TO
This command specifies the name pathname of teh file
specified in the immediately preceding RENAME_FROM. |
static int |
REPRESENTATION_TYPE
The argument specifies the representation type as
described in the section on Data Representation and
Storage of RFC959. |
static int |
RESTART
The argument field represents the server marker at which
file transfer is to be restarted. |
static int |
RETRIEVE
This command causes the server-DTP to transfer a copy
of the file, specified in the pathname, to the server-
or user-DTP at the other end of the data connection. |
static int |
SITE_PARAMETERS
This command is used by the server to provide services
specific to his system that are essential to file transfer
but not sufficiently universal to be included as commands
in the protocol. |
static int |
STATUS
This command shall cause a status response to be sent over
the control connection in the form of a response. |
static int |
STORE_FILE
This command causes the server-DTP to accept the data
transferred via the data connection and to store the
data as a file at the server site. |
static int |
STORE_UNIQUE_FILE
This command behaves like STORE_FILE except that
the resultant file is to be created in the current directory
under a name unique to that directory. |
static int |
STRUCTURE_MOUNT
This command allows the user to mount a different file
system data structure without altering his login or
accounting information. |
static int |
SYSTEM
This command is used to find out the type of operating
system at the server. |
static int |
TRANSFER_MODE
The argument is a single Telnet character code
specifying the data transfer modes described in
the section on Transmission Modes of RFC959. |
static int |
USER_NAME
The argument is a Telnet string identifying the user. |
Constructor Summary |
FTPCommand(int code)
Constructs a new instance of this class that
represents the code passed
as parameter. |
FTPCommand(int code,
java.util.Locale locale)
Constructs a new instance of this class that
represents the code passed
as parameter that will use the provided
locale for messages. |
FTPCommand(int code,
java.lang.String argument)
Constructs a new instance of this class that
represents the code passed
as parameter, with the specified argument
string. |
FTPCommand(int code,
java.lang.String argument,
java.util.Locale locale)
Constructs a new instance of this class that
represents the code passed
as parameter, with the specified argument
string that will use the provided locale
for messages. |
Method Summary |
int |
getCode()
Returns the FTP code of this command. |
java.lang.String |
getCommandToExecute()
Returns the FTP code that has to be printed to the
control connection for the server to understand the
request. |
java.lang.String |
getMessage()
Returns a localized version of the message corresponding
to the original one's code. |
protected java.lang.String |
getMessageFromCode(int code)
Returns the message that corresponds to the
code given as parameter. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
USER_NAME
public static final int USER_NAME
- The argument is a Telnet string identifying the user.
The user identification is that which is required
by the server for access to its file system.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:1:'USER'",
Constant Field Values
PASSWORD
public static final int PASSWORD
- The argument field is a Telnet string specifying the
user's password. This command must be immediately preceded
by the user name command, and, for some sites, completes
the user's identification for access control.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:1:'PASS'",
Constant Field Values
ACCOUNT
public static final int ACCOUNT
- The argument field is a Telnet string identifying the
user's account. The command is not necessarily related
to the USER_NAME, as some sites may require an
account for login and others only for specific access,
such as sotring files.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:1:'ACCT'",
Constant Field Values
CHANGE_WORKING_DIRECTORY
public static final int CHANGE_WORKING_DIRECTORY
- This command allows the user to work with a different
directory or dataset for file storage or retrieval without
altering his login or accounting information.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:1:'CWD'",
Constant Field Values
CHANGE_TO_PARENT_DIRECTORY
public static final int CHANGE_TO_PARENT_DIRECTORY
- This command is a special cas of CHANGE_WORKING_DIRECTORY,
and is included to simplify the implementation of programs
for transferring directory trees between operating systems having
different syntaxes for naming the parent directory.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:1:'CDUP'",
Constant Field Values
STRUCTURE_MOUNT
public static final int STRUCTURE_MOUNT
- This command allows the user to mount a different file
system data structure without altering his login or
accounting information.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:1:'SMNT'",
Constant Field Values
REINITIALIZE
public static final int REINITIALIZE
- This command terminates a USER_NAME, flushing
all I/O and account information, except to allow any
transfer in progress to be completed. All parameters
are reset to the default settings and the control
connection is left open. This is identical to the
state in which a user finds himself immediately after
the control connection is opened. A USER_NAME
may be expected to follow.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:1:'REIN'",
Constant Field Values
LOGOUT
public static final int LOGOUT
- This command terminates a USER_NAME and if
file transfer is not in progress, the server closes
the control connection. If file transfer is in progress,
the connection will remain open for result response
and the server will the close it.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:1:'QUIT'",
Constant Field Values
DATA_PORT
public static final int DATA_PORT
- The argument is a host-port specification for the
data port to be userd in data connection. There are
defaults for both the user and server ata ports, and
under normal circumstances this command and its response
are not needed. If this command is used, the argument
is the concatenation of a 32-bit internet host address
and a 16-bit TCP port address. This address information
is broken into 8-bit fields and the value of each field
is transmitted as a decimal number (in character string
representation). The fields are separated by commas.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:2:'PORT'",
Constant Field Values
PASSIVE
public static final int PASSIVE
- This command requests the server-DTP to "listen" on
a data port (which is not its default data port)
and to wait for a connection rather that initiate
one upon receipt of a transfer command. The response
to this command includes the host and port address
this server is listening to.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:2:'PASV'",
Constant Field Values
REPRESENTATION_TYPE
public static final int REPRESENTATION_TYPE
- The argument specifies the representation type as
described in the section on Data Representation and
Storage of RFC959.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:2:'TYPE'",
"RFC959-3:1:'Data Representation and Storage'",
Constant Field Values
FILE_STRUCTURE
public static final int FILE_STRUCTURE
- The argument is a single Telnet character code specifying
file structure described in the section on Data Representation
and Storage of RFC959.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:2:'STRU'",
"RFC959-3:1:'Data Representation and Storage'",
Constant Field Values
TRANSFER_MODE
public static final int TRANSFER_MODE
- The argument is a single Telnet character code
specifying the data transfer modes described in
the section on Transmission Modes of RFC959.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:2:'MODE'",
"RFC959-3:4:'Transmission Modes'",
Constant Field Values
RETRIEVE
public static final int RETRIEVE
- This command causes the server-DTP to transfer a copy
of the file, specified in the pathname, to the server-
or user-DTP at the other end of the data connection.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'RETR'",
Constant Field Values
STORE_FILE
public static final int STORE_FILE
- This command causes the server-DTP to accept the data
transferred via the data connection and to store the
data as a file at the server site. If the file specified
in the pathname exists at the server site, then its
contents shall be replaced by the data being transfered.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'STOR'",
Constant Field Values
STORE_UNIQUE_FILE
public static final int STORE_UNIQUE_FILE
- This command behaves like STORE_FILE except that
the resultant file is to be created in the current directory
under a name unique to that directory. The 250 "Transfer Started"
response must include the name generated.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'STOU'",
Constant Field Values
APPEND_WITH_CREATE
public static final int APPEND_WITH_CREATE
- This command causes the server-DTP to accept the data
transferred via the data connection and to store the data
in a file at the server site. If the file specified in the
pathname exists at the server site, then the data shall
be appended to that file.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'APPE'",
Constant Field Values
ALLOCATE
public static final int ALLOCATE
- This command may be required by some servers to reserve
sufficient storage to accommodate the new file to be
transferred. The argument shall be a decimal integer
representing the number of bytes (using the logical byte
size) of storage to be reserved for the file.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'ALLO'",
Constant Field Values
RESTART
public static final int RESTART
- The argument field represents the server marker at which
file transfer is to be restarted. This command does not
cause file transfer but skips over the file to the
specified data checkpoint. This command shall be immediately
followed by the appropriate FTP service command which shall
cause file transfer to resume.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'REST'",
Constant Field Values
RENAME_FROM
public static final int RENAME_FROM
- This command specifies the old pathname of the file
which is to be renamed. This command must be immediately
followed by a RENAME_TO . Together the two commands
cause a file to be renamed.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'RNFR'",
Constant Field Values
RENAME_TO
public static final int RENAME_TO
- This command specifies the name pathname of teh file
specified in the immediately preceding RENAME_FROM.
Together the two commands cause a file to be renamed.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'RNTO'",
Constant Field Values
ABORT
public static final int ABORT
- This command tells the server to abort the previous
FTP service command and any associated transfer of data.
The control connection is not to be closed by the server,
but the data connection must be closed.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'ABOR'",
Constant Field Values
DELETE_FILE
public static final int DELETE_FILE
- This command causes the file specified in the pathname
to be deleted at the server site. If an extra level of
protection is desired (such as the query, "Do you really
wish to delete?"), it should be provided by teh user-FTP
process.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'DELE'",
Constant Field Values
REMOVE_DIRECTORY
public static final int REMOVE_DIRECTORY
- This command causes the directory specified in the
pathname to be removed as a directory (if the pathname
is absolute) or as a subdirectory of the current working
directory (if the pathname is relative).
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'RMD'",
Constant Field Values
MAKE_DIRECTORY
public static final int MAKE_DIRECTORY
- This command causes the directory specified in the pathname
to be created as a directory (if the pathname is absolute)
or as a subdirectory of the current working directory (if
the pathname is relative).
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'MKD'",
Constant Field Values
PRINT_WORKING_DIRECTORY
public static final int PRINT_WORKING_DIRECTORY
- This command causes the name of the current directory
to be returned in the response.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'PWD'",
Constant Field Values
LIST
public static final int LIST
- This command causes a list to be sent from the server to
the passive DTP. If the pathname specifies a directory or
other group of files, the server should transfer a list of
files in the specified directory. If the pathname specifies
a file then the server should send current information on
the file. A null argument implies the user's current working
directory or default directory. The data transfer is over the
data connection in type ASCII or type EBCDIC. (The user must
ensure that the DATA_TYPE is appropriately ASCII or EBCDIC).
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'LIST'",
Constant Field Values
NAME_LIST
public static final int NAME_LIST
- This command causes a directory listing to be sent from
server to user site. The pathname should specify a directory
or other system-specific file group descriptor; a null argument
implies the current directory. The server will return a stream
of names of files and no other information. The data transfer
is over the data connection in type ASCII or type EBCDIC.
(The user must ensure that the DATA_TYPE is appropriately ASCII
or EBCDIC).
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'NLST'",
Constant Field Values
SITE_PARAMETERS
public static final int SITE_PARAMETERS
- This command is used by the server to provide services
specific to his system that are essential to file transfer
but not sufficiently universal to be included as commands
in the protocol. The nature of these services and the
specification of their syntax can be stated in a response
to HELP "site" command.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'SITE'",
Constant Field Values
SYSTEM
public static final int SYSTEM
- This command is used to find out the type of operating
system at the server. The response shall have as its first
word one of teh system names listed in the current version
of the Assigned Numbers document. (As of 2000-07-31: RFC1700)
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'SYST'",
Constant Field Values
STATUS
public static final int STATUS
- This command shall cause a status response to be sent over
the control connection in the form of a response. The command
may be sent during a file transfer in which case the server
will respond with the status of teh operation in progress,
or it may be sent between file transfers. In the latter case,
the command may have an argument field. If the argument is
a pathname, the command is analogous to the LIST
except that data shall be transferred over the control connection.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'STAT'",
Constant Field Values
HELP
public static final int HELP
- This command shall cause the server to send helpful
information regarding its implementation status over the
control connection to the user. The command may take
an argument (e.g., any command name) and return more
specific information as a response.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'HELP'",
Constant Field Values
NO_OPERATION
public static final int NO_OPERATION
- This command does not affect any parameters or previously
entered commands. It specifies no action other than that
of the server send an OK response.
- Since:
- v1.0
- See Also:
- "RFC959-4:1:3:'NOOP'",
Constant Field Values
FTPCommand
public FTPCommand(int code)
- Constructs a new instance of this class that
represents the
code
passed
as parameter.
- Parameters:
code
- FTP command to represent.- Since:
- v1.0
FTPCommand
public FTPCommand(int code,
java.util.Locale locale)
- Constructs a new instance of this class that
represents the
code
passed
as parameter that will use the provided
locale
for messages.
- Parameters:
code
- FTP command to represent.locale
- language to user for messages.- Since:
- v1.0
FTPCommand
public FTPCommand(int code,
java.lang.String argument)
- Constructs a new instance of this class that
represents the
code
passed
as parameter, with the specified argument
string.
- Parameters:
code
- FTP command to represent.argument
- argument to the FTP code
.- Since:
- v1.0
FTPCommand
public FTPCommand(int code,
java.lang.String argument,
java.util.Locale locale)
- Constructs a new instance of this class that
represents the
code
passed
as parameter, with the specified argument
string that will use the provided locale
for messages.
- Parameters:
code
- FTP command to represent.argument
- argument to the FTP code
.locale
- language to user for messages.- Since:
- v1.0
getCode
public int getCode()
- Returns the FTP code of this command.
- Returns:
- command code
- Since:
- v1.0
getMessage
public java.lang.String getMessage()
- Returns a localized version of the message corresponding
to the original one's code. This will only work if a
localized version of the messages are provided.
- Returns:
- code of the response sent by FTP server.
- Since:
- v1.0
getMessageFromCode
protected java.lang.String getMessageFromCode(int code)
- Returns the message that corresponds to the
code
given as parameter.
- Parameters:
code
- one of the codes defined in this class.- Since:
- v1.0
getCommandToExecute
public java.lang.String getCommandToExecute()
- Returns the FTP code that has to be printed to the
control connection for the server to understand the
request.
- Returns:
- a valid FTP command to be interpreted by the server.
- Since:
- v1.0
Copyright © 2009. All Rights Reserved.