View Javadoc
1 package org.apache.commons.net.ftp; 2 3 /* ==================================================================== 4 * The Apache Software License, Version 1.1 5 * 6 * Copyright (c) 2001 The Apache Software Foundation. All rights 7 * reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in 18 * the documentation and/or other materials provided with the 19 * distribution. 20 * 21 * 3. The end-user documentation included with the redistribution, 22 * if any, must include the following acknowledgment: 23 * "This product includes software developed by the 24 * Apache Software Foundation (http://www.apache.org/)." 25 * Alternately, this acknowledgment may appear in the software itself, 26 * if and wherever such third-party acknowledgments normally appear. 27 * 28 * 4. The names "Apache" and "Apache Software Foundation" and 29 * "Apache Commons" must not be used to endorse or promote products 30 * derived from this software without prior written permission. For 31 * written permission, please contact apache@apache.org. 32 * 33 * 5. Products derived from this software may not be called "Apache", 34 * nor may "Apache" appear in their name, without 35 * prior written permission of the Apache Software Foundation. 36 * 37 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 39 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 40 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 44 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 47 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 48 * SUCH DAMAGE. 49 * ==================================================================== 50 * 51 * This software consists of voluntary contributions made by many 52 * individuals on behalf of the Apache Software Foundation. For more 53 * information on the Apache Software Foundation, please see 54 * <http://www.apache.org/>;. 55 */ 56 57 /**** 58 * FTPReply stores a set of constants for FTP reply codes. To interpret 59 * the meaning of the codes, familiarity with RFC 959 is assumed. 60 * The mnemonic constant names are transcriptions from the code descriptions 61 * of RFC 959. For those who think in terms of the actual reply code values, 62 * a set of CODE_NUM constants are provided where NUM is the numerical value 63 * of the code. 64 * <p> 65 * <p> 66 * @author Daniel F. Savarese 67 ***/ 68 69 public final class FTPReply 70 { 71 72 public static final int CODE_110 = 110; 73 public static final int CODE_120 = 120; 74 public static final int CODE_125 = 125; 75 public static final int CODE_150 = 150; 76 public static final int CODE_200 = 200; 77 public static final int CODE_202 = 202; 78 public static final int CODE_211 = 211; 79 public static final int CODE_212 = 212; 80 public static final int CODE_213 = 213; 81 public static final int CODE_214 = 214; 82 public static final int CODE_215 = 215; 83 public static final int CODE_220 = 220; 84 public static final int CODE_221 = 221; 85 public static final int CODE_225 = 225; 86 public static final int CODE_226 = 226; 87 public static final int CODE_227 = 227; 88 public static final int CODE_230 = 230; 89 public static final int CODE_250 = 250; 90 public static final int CODE_257 = 257; 91 public static final int CODE_331 = 331; 92 public static final int CODE_332 = 332; 93 public static final int CODE_350 = 350; 94 public static final int CODE_421 = 421; 95 public static final int CODE_425 = 425; 96 public static final int CODE_426 = 426; 97 public static final int CODE_450 = 450; 98 public static final int CODE_451 = 451; 99 public static final int CODE_452 = 452; 100 public static final int CODE_500 = 500; 101 public static final int CODE_501 = 501; 102 public static final int CODE_502 = 502; 103 public static final int CODE_503 = 503; 104 public static final int CODE_504 = 504; 105 public static final int CODE_530 = 530; 106 public static final int CODE_532 = 532; 107 public static final int CODE_550 = 550; 108 public static final int CODE_551 = 551; 109 public static final int CODE_552 = 552; 110 public static final int CODE_553 = 553; 111 112 public static final int RESTART_MARKER = CODE_110; 113 public static final int SERVICE_NOT_READY = CODE_120; 114 public static final int DATA_CONNECTION_ALREADY_OPEN = CODE_125; 115 public static final int FILE_STATUS_OK = CODE_150; 116 public static final int COMMAND_OK = CODE_200; 117 public static final int COMMAND_IS_SUPERFLUOUS = CODE_202; 118 public static final int SYSTEM_STATUS = CODE_211; 119 public static final int DIRECTORY_STATUS = CODE_212; 120 public static final int FILE_STATUS = CODE_213; 121 public static final int HELP_MESSAGE = CODE_214; 122 public static final int NAME_SYSTEM_TYPE = CODE_215; 123 public static final int SERVICE_READY = CODE_220; 124 public static final int SERVICE_CLOSING_CONTROL_CONNECTION = CODE_221; 125 public static final int DATA_CONNECTION_OPEN = CODE_225; 126 public static final int CLOSING_DATA_CONNECTION = CODE_226; 127 public static final int ENTERING_PASSIVE_MODE = CODE_227; 128 public static final int USER_LOGGED_IN = CODE_230; 129 public static final int FILE_ACTION_OK = CODE_250; 130 public static final int PATHNAME_CREATED = CODE_257; 131 public static final int NEED_PASSWORD = CODE_331; 132 public static final int NEED_ACCOUNT = CODE_332; 133 public static final int FILE_ACTION_PENDING = CODE_350; 134 public static final int SERVICE_NOT_AVAILABLE = CODE_421; 135 public static final int CANNOT_OPEN_DATA_CONNECTION = CODE_425; 136 public static final int TRANSFER_ABORTED = CODE_426; 137 public static final int FILE_ACTION_NOT_TAKEN = CODE_450; 138 public static final int ACTION_ABORTED = CODE_451; 139 public static final int INSUFFICIENT_STORAGE = CODE_452; 140 public static final int UNRECOGNIZED_COMMAND = CODE_500; 141 public static final int SYNTAX_ERROR_IN_ARGUMENTS = CODE_501; 142 public static final int COMMAND_NOT_IMPLEMENTED = CODE_502; 143 public static final int BAD_COMMAND_SEQUENCE = CODE_503; 144 public static final int COMMAND_NOT_IMPLEMENTED_FOR_PARAMETER = CODE_504; 145 public static final int NOT_LOGGED_IN = CODE_530; 146 public static final int NEED_ACCOUNT_FOR_STORING_FILES = CODE_532; 147 public static final int FILE_UNAVAILABLE = CODE_550; 148 public static final int PAGE_TYPE_UNKNOWN = CODE_551; 149 public static final int STORAGE_ALLOCATION_EXCEEDED = CODE_552; 150 public static final int FILE_NAME_NOT_ALLOWED = CODE_553; 151 152 // Cannot be instantiated 153 private FTPReply() 154 {} 155 156 /**** 157 * Determine if a reply code is a positive preliminary response. All 158 * codes beginning with a 1 are positive preliminary responses. 159 * Postitive preliminary responses are used to indicate tentative success. 160 * No further commands can be issued to the FTP server after a positive 161 * preliminary response until a follow up response is received from the 162 * server. 163 * <p> 164 * @param reply The reply code to test. 165 * @return True if a reply code is a postive preliminary response, false 166 * if not. 167 ***/ 168 public static boolean isPositivePreliminary(int reply) 169 { 170 return (reply >= 100 && reply < 200); 171 } 172 173 /**** 174 * Determine if a reply code is a positive completion response. All 175 * codes beginning with a 2 are positive completion responses. 176 * The FTP server will send a positive completion response on the final 177 * successful completion of a command. 178 * <p> 179 * @param reply The reply code to test. 180 * @return True if a reply code is a postive completion response, false 181 * if not. 182 ***/ 183 public static boolean isPositiveCompletion(int reply) 184 { 185 return (reply >= 200 && reply < 300); 186 } 187 188 /**** 189 * Determine if a reply code is a positive intermediate response. All 190 * codes beginning with a 3 are positive intermediate responses. 191 * The FTP server will send a positive intermediate response on the 192 * successful completion of one part of a multi-part sequence of 193 * commands. For example, after a successful USER command, a positive 194 * intermediate response will be sent to indicate that the server is 195 * ready for the PASS command. 196 * <p> 197 * @param reply The reply code to test. 198 * @return True if a reply code is a postive intermediate response, false 199 * if not. 200 ***/ 201 public static boolean isPositiveIntermediate(int reply) 202 { 203 return (reply >= 300 && reply < 400); 204 } 205 206 /**** 207 * Determine if a reply code is a negative transient response. All 208 * codes beginning with a 4 are negative transient responses. 209 * The FTP server will send a negative transient response on the 210 * failure of a command that can be reattempted with success. 211 * <p> 212 * @param reply The reply code to test. 213 * @return True if a reply code is a negative transient response, false 214 * if not. 215 ***/ 216 public static boolean isNegativeTransient(int reply) 217 { 218 return (reply >= 400 && reply < 500); 219 } 220 221 /**** 222 * Determine if a reply code is a negative permanent response. All 223 * codes beginning with a 5 are negative permanent responses. 224 * The FTP server will send a negative permanent response on the 225 * failure of a command that cannot be reattempted with success. 226 * <p> 227 * @param reply The reply code to test. 228 * @return True if a reply code is a negative permanent response, false 229 * if not. 230 ***/ 231 public static boolean isNegativePermanent(int reply) 232 { 233 return (reply >= 500 && reply < 600); 234 } 235 236 }

This page was automatically generated by Maven