|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.finj.FTPResponse
public class FTPResponse
This class contains constants and methods that simplify handling and internationalization of FTP server replies. Codes according to RFC959-4.2 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
Field Summary | |
---|---|
static int |
BAD_COMMAND_SEQUENCE_CODE
Bad sequence of commands. |
static int |
CAN_T_OPEN_DATA_CONNECTION_CODE
Can't open data connection. |
static int |
COMMAND_NOT_IMPLEMENTED_CODE
Command not implemented. |
static int |
COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER_CODE
Command not implemented for that parameter. |
static int |
CONTROL_CONNECTION_CLOSED_CODE
Service closing control connection. |
static int |
CONTROL_CONNECTION_OPENED_CODE
Service ready for new user. |
static int |
DATA_CONNECTION_ABORTED_CODE
Connection closed; transfer aborted. |
static int |
DATA_CONNECTION_ABOUT_TO_BE_OPENED_CODE
File status okay; about to open data connection. |
static int |
DATA_CONNECTION_ALREADY_OPENED_CODE
Data Connection already open; transfer starting. |
static int |
DATA_CONNECTION_CLOSED_CODE
Closing data connection. |
static int |
DATA_CONNECTION_OPENED_CODE
Data connection open; no transfer in progress. |
static int |
DIRECTORY_STATUS_CODE
Directory status |
static int |
ENTERING_PASSIVE_MODE_CODE
Entering Passive Mode (h1,h2,h3,h4,p1,p2). |
static int |
EXCEEDED_STORAGE_ALLOCATION_CODE
Requested file action aborted. |
static int |
FILE_STATUS_CODE
File status. |
static int |
FINE_NAME_NOT_ALLOWED_CODE
Requested action not taken. |
static int |
HELP_MESSAGE_CODE
Help message. |
static int |
NEED_ACCOUNT_FOR_LOGIN_CODE
Need account for login. |
static int |
NEED_ACCOUNT_FOR_STORING_FILES_CODE
Need account for storing files. |
static int |
NOT_LOGGED_IN_CODE
Not logged in. |
static int |
PAGE_TYPE_UNKNOWN_CODE
Requested action aborted: page type unknown. |
static int |
PATHNAME_CREATED_CODE
"PATHNAME" created. |
static int |
PERMANENT_NEGATIVE_COMPLETION_RESPONSE_CODE
Syntax error, command unrecognized. |
static int |
PERMANENTLY_UNAVAILABLE_FILE_CODE
Requested action not taken. |
static int |
POSITIVE_COMPLETION_RESPONSE_CODE
Command okay. |
static int |
REQUESTED_FILE_ACTION_OK_CODE
Requested file action okay, completed. |
static int |
REQUESTED_FILE_ACTION_PENDING_CODE
Requested file action pending further information. |
static int |
RESTART_MARKER_RESPONSE_CODE
Restart marker response. |
static int |
SERVICE_NOT_AVAILABLE_CODE
Service not available, closing control connection. |
static int |
SUPERFLOUS_COMMAND_CODE
Command not implemented, superfluous at this site. |
static int |
SYNTAX_ERROR_IN_ARGUMENTS_CODE
Syntax error n parameters or arguments. |
static int |
SYSTEM_STATUS_OR_HELP_RESPONSE_CODE
System status, or system help response. |
static int |
SYSTEM_TYPE_NAME_CODE
NAME system type. |
static int |
TRANSIENT_INSUFFICIENT_STORAGE_SPACE_CODE
Requested action not taken. |
static int |
TRANSIENT_LOCAL_PROCESSING_ERROR_CODE
Requested action aborted: local error in processing. |
static int |
TRANSIENT_UNAVAILABLE_FILE_CODE
Requested file action not taken. |
static int |
USER_LOGGED_IN_CODE
User logged in, proceed. |
static int |
USERNAME_OK_NEED_PASSWORD_CODE
User name okay, need password. |
static int |
WILL_BE_READY_IN_MINUTES_CODE
Service ready in nnn minutes. |
Constructor Summary | |
---|---|
FTPResponse(int code,
java.lang.String text,
java.lang.String[] multi,
java.util.Locale locale)
Initializes the current instance with the info provided. |
|
FTPResponse(java.lang.String response)
Constructs a new instance of this class that will use FTPConstants.DEFAULT_LOCALE as
default locale. |
|
FTPResponse(java.lang.String response,
java.util.Locale locale)
Constructs a new instance of this class that will use locale as
message language. |
|
FTPResponse(java.lang.String response,
java.lang.String[] multiline)
Constructs a new instance of this class that will use FTPConstants.DEFAULT_LOCALE as
default locale, and will store a multiline answer. |
|
FTPResponse(java.lang.String response,
java.lang.String[] multiline,
java.util.Locale locale)
Constructs a new instance of this class that will use locale as
message language. |
Method Summary | |
---|---|
static boolean |
closesMultilineResponse(java.lang.String response,
int code)
Tests a line of a response to know if it closes a multiline answer. |
int |
getCode()
Returns the FTP code of this response. |
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. |
java.lang.String[] |
getMultilineText()
Returns the multiline answer received with this response. |
java.lang.String |
getOriginalMessage()
Returns the original message received from the FTP server and passed at construction time. |
boolean |
isMultiline()
Returns true if this response anounces a multi line response, e.g., STAT command. |
static boolean |
opensMultilineResponse(java.lang.String response)
Tests the first line of a response to know if it opens a multiline answer. |
static int |
parseCode(java.lang.String response)
Returns the code contained in the response passed as parameter. |
static java.lang.String |
parseOriginalMessage(java.lang.String response)
Returns the message contained in the response passed as parameter. |
java.lang.String[] |
parseServerPassivePort()
Returns the host passive port parsed from the original text of response. |
java.lang.String |
parseWorkingDirectory()
This command causes the name of the current working directory to be returned. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int RESTART_MARKER_RESPONSE_CODE
MARK yyyy = mmmm
Where yyyy
is User-process data stream marker,
and mmmm
server's equivalent marker
(note the spaces between markers and '=`).
public static final int WILL_BE_READY_IN_MINUTES_CODE
nnn
minutes.
public static final int DATA_CONNECTION_ALREADY_OPENED_CODE
public static final int DATA_CONNECTION_ABOUT_TO_BE_OPENED_CODE
public static final int POSITIVE_COMPLETION_RESPONSE_CODE
public static final int SUPERFLOUS_COMMAND_CODE
public static final int SYSTEM_STATUS_OR_HELP_RESPONSE_CODE
public static final int DIRECTORY_STATUS_CODE
public static final int FILE_STATUS_CODE
public static final int HELP_MESSAGE_CODE
public static final int SYSTEM_TYPE_NAME_CODE
NAME
system type.
Where NAME
is an official system name from
the list in the Assigned Numbers document.
public static final int CONTROL_CONNECTION_OPENED_CODE
public static final int CONTROL_CONNECTION_CLOSED_CODE
public static final int DATA_CONNECTION_OPENED_CODE
public static final int DATA_CONNECTION_CLOSED_CODE
public static final int ENTERING_PASSIVE_MODE_CODE
public static final int USER_LOGGED_IN_CODE
public static final int REQUESTED_FILE_ACTION_OK_CODE
public static final int PATHNAME_CREATED_CODE
public static final int USERNAME_OK_NEED_PASSWORD_CODE
public static final int NEED_ACCOUNT_FOR_LOGIN_CODE
public static final int REQUESTED_FILE_ACTION_PENDING_CODE
public static final int SERVICE_NOT_AVAILABLE_CODE
public static final int CAN_T_OPEN_DATA_CONNECTION_CODE
public static final int DATA_CONNECTION_ABORTED_CODE
public static final int TRANSIENT_UNAVAILABLE_FILE_CODE
public static final int TRANSIENT_LOCAL_PROCESSING_ERROR_CODE
public static final int TRANSIENT_INSUFFICIENT_STORAGE_SPACE_CODE
public static final int PERMANENT_NEGATIVE_COMPLETION_RESPONSE_CODE
public static final int SYNTAX_ERROR_IN_ARGUMENTS_CODE
public static final int COMMAND_NOT_IMPLEMENTED_CODE
public static final int BAD_COMMAND_SEQUENCE_CODE
public static final int COMMAND_NOT_IMPLEMENTED_FOR_THAT_PARAMETER_CODE
public static final int NOT_LOGGED_IN_CODE
public static final int NEED_ACCOUNT_FOR_STORING_FILES_CODE
public static final int PERMANENTLY_UNAVAILABLE_FILE_CODE
public static final int PAGE_TYPE_UNKNOWN_CODE
public static final int EXCEEDED_STORAGE_ALLOCATION_CODE
public static final int FINE_NAME_NOT_ALLOWED_CODE
Constructor Detail |
---|
public FTPResponse(java.lang.String response)
FTPConstants.DEFAULT_LOCALE
as
default locale.
response
- original response message received on the
control connection.public FTPResponse(java.lang.String response, java.lang.String[] multiline)
FTPConstants.DEFAULT_LOCALE
as
default locale, and will store a multiline answer.
response
- original response message received on the
control connection.multiline
- text received with this response.public FTPResponse(java.lang.String response, java.util.Locale locale) throws java.lang.IllegalArgumentException
locale
as
message language. If not available,
messages for default language
(Locale.US
) will be used.
response
- original response message received on the
control connection.locale
- language to use for message.
java.lang.IllegalArgumentException
public FTPResponse(java.lang.String response, java.lang.String[] multiline, java.util.Locale locale) throws java.lang.IllegalArgumentException
locale
as
message language. If not available,
messages for default language
(Locale.US
) will be used.
response
- original response message received on the
control connection.multiline
- text received with this response.locale
- language to use for message.
java.lang.IllegalArgumentException
public FTPResponse(int code, java.lang.String text, java.lang.String[] multi, java.util.Locale locale)
code
- valid FTP code.text
- original message found in the response.multi
- multiline info received with this message.locale
- language to use for message.Method Detail |
---|
public int getCode()
public java.lang.String getMessage()
public java.lang.String getOriginalMessage()
public boolean isMultiline()
STAT
command.
true
if more lines are coming next
the one used to construct this instance.public java.lang.String[] getMultilineText()
null
else.protected java.lang.String getMessageFromCode(int code)
code
given as parameter.
code
- one of the codes defined in this class.public static boolean opensMultilineResponse(java.lang.String response)
response
- FTP server response to interpret.public static boolean closesMultilineResponse(java.lang.String response, int code)
response
- FTP server response to interpret.public static int parseCode(java.lang.String response) throws java.lang.IllegalArgumentException
response
passed as parameter.
This code are in fact the 3 first characters
of the response
.
response
- FTP server response to interpret.
java.lang.IllegalArgumentException
- when response
's 3 first characters
are not a valid three digit numberpublic static java.lang.String parseOriginalMessage(java.lang.String response) throws java.lang.IllegalArgumentException
response
passed as parameter.
response
- FTP server response to interpret.
java.lang.IllegalArgumentException
- when response
isn't parsable.public java.lang.String[] parseServerPassivePort() throws FTPException
java.lang.String[]
FTPException
- Response doesn't contain the required informationpublic java.lang.String parseWorkingDirectory()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |