1. /*
  2. * Copyright 2001-2004 The Apache Software Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package org.apache.commons.net.nntp;
  17. /***
  18. * NNTPReply stores a set of constants for NNTP reply codes. To interpret
  19. * the meaning of the codes, familiarity with RFC 977 is assumed.
  20. * The mnemonic constant names are transcriptions from the code descriptions
  21. * of RFC 977. For those who think in terms of the actual reply code values,
  22. * a set of CODE_NUM constants are provided where NUM is the numerical value
  23. * of the code.
  24. * <p>
  25. * <p>
  26. * @author Daniel F. Savarese
  27. ***/
  28. public final class NNTPReply
  29. {
  30. public static final int CODE_100 = 100;
  31. public static final int CODE_199 = 199;
  32. public static final int CODE_200 = 200;
  33. public static final int CODE_201 = 201;
  34. public static final int CODE_202 = 202;
  35. public static final int CODE_205 = 205;
  36. public static final int CODE_211 = 211;
  37. public static final int CODE_215 = 215;
  38. public static final int CODE_220 = 220;
  39. public static final int CODE_221 = 221;
  40. public static final int CODE_222 = 222;
  41. public static final int CODE_223 = 223;
  42. public static final int CODE_230 = 230;
  43. public static final int CODE_231 = 231;
  44. public static final int CODE_235 = 235;
  45. public static final int CODE_240 = 240;
  46. public static final int CODE_281 = 281;
  47. public static final int CODE_335 = 335;
  48. public static final int CODE_340 = 340;
  49. public static final int CODE_381 = 381;
  50. public static final int CODE_400 = 400;
  51. public static final int CODE_408 = 408;
  52. public static final int CODE_411 = 411;
  53. public static final int CODE_412 = 412;
  54. public static final int CODE_420 = 420;
  55. public static final int CODE_421 = 421;
  56. public static final int CODE_422 = 422;
  57. public static final int CODE_423 = 423;
  58. public static final int CODE_430 = 430;
  59. public static final int CODE_435 = 435;
  60. public static final int CODE_436 = 436;
  61. public static final int CODE_437 = 437;
  62. public static final int CODE_440 = 440;
  63. public static final int CODE_441 = 441;
  64. public static final int CODE_482 = 482;
  65. public static final int CODE_500 = 500;
  66. public static final int CODE_501 = 501;
  67. public static final int CODE_502 = 502;
  68. public static final int CODE_503 = 503;
  69. public static final int HELP_TEXT_FOLLOWS = CODE_100;
  70. public static final int DEBUG_OUTPUT = CODE_199;
  71. public static final int SERVER_READY_POSTING_ALLOWED = CODE_200;
  72. public static final int SERVER_READY_POSTING_NOT_ALLOWED = CODE_201;
  73. public static final int SLAVE_STATUS_NOTED = CODE_202;
  74. public static final int CLOSING_CONNECTION = CODE_205;
  75. public static final int GROUP_SELECTED = CODE_211;
  76. public static final int ARTICLE_RETRIEVED_HEAD_AND_BODY_FOLLOW = CODE_220;
  77. public static final int ARTICLE_RETRIEVED_HEAD_FOLLOWS = CODE_221;
  78. public static final int ARTICLE_RETRIEVED_BODY_FOLLOWS = CODE_222;
  79. public static final int
  80. ARTICLE_RETRIEVED_REQUEST_TEXT_SEPARATELY = CODE_223;
  81. public static final int ARTICLE_LIST_BY_MESSAGE_ID_FOLLOWS = CODE_230;
  82. public static final int NEW_NEWSGROUP_LIST_FOLLOWS = CODE_231;
  83. public static final int ARTICLE_TRANSFERRED_OK = CODE_235;
  84. public static final int ARTICLE_POSTED_OK = CODE_240;
  85. public static final int AUTHENTICATION_ACCEPTED = CODE_281;
  86. public static final int SEND_ARTICLE_TO_TRANSFER = CODE_335;
  87. public static final int SEND_ARTICLE_TO_POST = CODE_340;
  88. public static final int MORE_AUTH_INFO_REQUIRED = CODE_381;
  89. public static final int SERVICE_DISCONTINUED = CODE_400;
  90. public static final int NO_SUCH_NEWSGROUP = CODE_411;
  91. public static final int AUTHENTICATION_REQUIRED = CODE_408;
  92. public static final int NO_NEWSGROUP_SELECTED = CODE_412;
  93. public static final int NO_CURRENT_ARTICLE_SELECTED = CODE_420;
  94. public static final int NO_NEXT_ARTICLE = CODE_421;
  95. public static final int NO_PREVIOUS_ARTICLE = CODE_422;
  96. public static final int NO_SUCH_ARTICLE_NUMBER = CODE_423;
  97. public static final int NO_SUCH_ARTICLE_FOUND = CODE_430;
  98. public static final int ARTICLE_NOT_WANTED = CODE_435;
  99. public static final int TRANSFER_FAILED = CODE_436;
  100. public static final int ARTICLE_REJECTED = CODE_437;
  101. public static final int POSTING_NOT_ALLOWED = CODE_440;
  102. public static final int POSTING_FAILED = CODE_441;
  103. public static final int AUTHENTICATION_REJECTED = CODE_482;
  104. public static final int COMMAND_NOT_RECOGNIZED = CODE_500;
  105. public static final int COMMAND_SYNTAX_ERROR = CODE_501;
  106. public static final int PERMISSION_DENIED = CODE_502;
  107. public static final int PROGRAM_FAULT = CODE_503;
  108. // Cannot be instantiated
  109. private NNTPReply()
  110. {}
  111. /***
  112. * Determine if a reply code is an informational response. All
  113. * codes beginning with a 1 are positive informational responses.
  114. * Informational responses are used to provide human readable
  115. * information such as help text.
  116. * <p>
  117. * @param reply The reply code to test.
  118. * @return True if a reply code is an informational response, false
  119. * if not.
  120. ***/
  121. public static boolean isInformational(int reply)
  122. {
  123. return (reply >= 100 && reply < 200);
  124. }
  125. /***
  126. * Determine if a reply code is a positive completion response. All
  127. * codes beginning with a 2 are positive completion responses.
  128. * The NNTP server will send a positive completion response on the final
  129. * successful completion of a command.
  130. * <p>
  131. * @param reply The reply code to test.
  132. * @return True if a reply code is a postive completion response, false
  133. * if not.
  134. ***/
  135. public static boolean isPositiveCompletion(int reply)
  136. {
  137. return (reply >= 200 && reply < 300);
  138. }
  139. /***
  140. * Determine if a reply code is a positive intermediate response. All
  141. * codes beginning with a 3 are positive intermediate responses.
  142. * The NNTP server will send a positive intermediate response on the
  143. * successful completion of one part of a multi-part command or
  144. * sequence of commands. For example, after a successful POST command,
  145. * a positive intermediate response will be sent to indicate that the
  146. * server is ready to receive the article to be posted.
  147. * <p>
  148. * @param reply The reply code to test.
  149. * @return True if a reply code is a postive intermediate response, false
  150. * if not.
  151. ***/
  152. public static boolean isPositiveIntermediate(int reply)
  153. {
  154. return (reply >= 300 && reply < 400);
  155. }
  156. /***
  157. * Determine if a reply code is a negative transient response. All
  158. * codes beginning with a 4 are negative transient responses.
  159. * The NNTP server will send a negative transient response on the
  160. * failure of a correctly formatted command that could not be performed
  161. * for some reason. For example, retrieving an article that does not
  162. * exist will result in a negative transient response.
  163. * <p>
  164. * @param reply The reply code to test.
  165. * @return True if a reply code is a negative transient response, false
  166. * if not.
  167. ***/
  168. public static boolean isNegativeTransient(int reply)
  169. {
  170. return (reply >= 400 && reply < 500);
  171. }
  172. /***
  173. * Determine if a reply code is a negative permanent response. All
  174. * codes beginning with a 5 are negative permanent responses.
  175. * The NNTP server will send a negative permanent response when
  176. * it does not implement a command, a command is incorrectly formatted,
  177. * or a serious program error occurs.
  178. * <p>
  179. * @param reply The reply code to test.
  180. * @return True if a reply code is a negative permanent response, false
  181. * if not.
  182. ***/
  183. public static boolean isNegativePermanent(int reply)
  184. {
  185. return (reply >= 500 && reply < 600);
  186. }
  187. }
  188. /* Emacs configuration
  189. * Local variables: **
  190. * mode: java **
  191. * c-basic-offset: 4 **
  192. * indent-tabs-mode: nil **
  193. * End: **
  194. */