001: /*
002: * Copyright 2001-2005 The Apache Software Foundation
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.commons.net.nntp;
017:
018: /***
019: * NNTPReply stores a set of constants for NNTP reply codes. To interpret
020: * the meaning of the codes, familiarity with RFC 977 is assumed.
021: * The mnemonic constant names are transcriptions from the code descriptions
022: * of RFC 977. For those who think in terms of the actual reply code values,
023: * a set of CODE_NUM constants are provided where NUM is the numerical value
024: * of the code.
025: * <p>
026: * <p>
027: * @author Daniel F. Savarese
028: ***/
029:
030: public final class NNTPReply {
031:
032: public static final int CODE_100 = 100;
033: public static final int CODE_199 = 199;
034: public static final int CODE_200 = 200;
035: public static final int CODE_201 = 201;
036: public static final int CODE_202 = 202;
037: public static final int CODE_205 = 205;
038: public static final int CODE_211 = 211;
039: public static final int CODE_215 = 215;
040: public static final int CODE_220 = 220;
041: public static final int CODE_221 = 221;
042: public static final int CODE_222 = 222;
043: public static final int CODE_223 = 223;
044: public static final int CODE_230 = 230;
045: public static final int CODE_231 = 231;
046: public static final int CODE_235 = 235;
047: public static final int CODE_240 = 240;
048: public static final int CODE_281 = 281;
049: public static final int CODE_335 = 335;
050: public static final int CODE_340 = 340;
051: public static final int CODE_381 = 381;
052: public static final int CODE_400 = 400;
053: public static final int CODE_408 = 408;
054: public static final int CODE_411 = 411;
055: public static final int CODE_412 = 412;
056: public static final int CODE_420 = 420;
057: public static final int CODE_421 = 421;
058: public static final int CODE_422 = 422;
059: public static final int CODE_423 = 423;
060: public static final int CODE_430 = 430;
061: public static final int CODE_435 = 435;
062: public static final int CODE_436 = 436;
063: public static final int CODE_437 = 437;
064: public static final int CODE_440 = 440;
065: public static final int CODE_441 = 441;
066: public static final int CODE_482 = 482;
067: public static final int CODE_500 = 500;
068: public static final int CODE_501 = 501;
069: public static final int CODE_502 = 502;
070: public static final int CODE_503 = 503;
071:
072: public static final int HELP_TEXT_FOLLOWS = CODE_100;
073: public static final int DEBUG_OUTPUT = CODE_199;
074: public static final int SERVER_READY_POSTING_ALLOWED = CODE_200;
075: public static final int SERVER_READY_POSTING_NOT_ALLOWED = CODE_201;
076: public static final int SLAVE_STATUS_NOTED = CODE_202;
077: public static final int CLOSING_CONNECTION = CODE_205;
078: public static final int GROUP_SELECTED = CODE_211;
079: public static final int ARTICLE_RETRIEVED_HEAD_AND_BODY_FOLLOW = CODE_220;
080: public static final int ARTICLE_RETRIEVED_HEAD_FOLLOWS = CODE_221;
081: public static final int ARTICLE_RETRIEVED_BODY_FOLLOWS = CODE_222;
082: public static final int ARTICLE_RETRIEVED_REQUEST_TEXT_SEPARATELY = CODE_223;
083: public static final int ARTICLE_LIST_BY_MESSAGE_ID_FOLLOWS = CODE_230;
084: public static final int NEW_NEWSGROUP_LIST_FOLLOWS = CODE_231;
085: public static final int ARTICLE_TRANSFERRED_OK = CODE_235;
086: public static final int ARTICLE_POSTED_OK = CODE_240;
087: public static final int AUTHENTICATION_ACCEPTED = CODE_281;
088: public static final int SEND_ARTICLE_TO_TRANSFER = CODE_335;
089: public static final int SEND_ARTICLE_TO_POST = CODE_340;
090: public static final int MORE_AUTH_INFO_REQUIRED = CODE_381;
091: public static final int SERVICE_DISCONTINUED = CODE_400;
092: public static final int NO_SUCH_NEWSGROUP = CODE_411;
093: public static final int AUTHENTICATION_REQUIRED = CODE_408;
094: public static final int NO_NEWSGROUP_SELECTED = CODE_412;
095: public static final int NO_CURRENT_ARTICLE_SELECTED = CODE_420;
096: public static final int NO_NEXT_ARTICLE = CODE_421;
097: public static final int NO_PREVIOUS_ARTICLE = CODE_422;
098: public static final int NO_SUCH_ARTICLE_NUMBER = CODE_423;
099: public static final int NO_SUCH_ARTICLE_FOUND = CODE_430;
100: public static final int ARTICLE_NOT_WANTED = CODE_435;
101: public static final int TRANSFER_FAILED = CODE_436;
102: public static final int ARTICLE_REJECTED = CODE_437;
103: public static final int POSTING_NOT_ALLOWED = CODE_440;
104: public static final int POSTING_FAILED = CODE_441;
105: public static final int AUTHENTICATION_REJECTED = CODE_482;
106: public static final int COMMAND_NOT_RECOGNIZED = CODE_500;
107: public static final int COMMAND_SYNTAX_ERROR = CODE_501;
108: public static final int PERMISSION_DENIED = CODE_502;
109: public static final int PROGRAM_FAULT = CODE_503;
110:
111: // Cannot be instantiated
112:
113: private NNTPReply() {
114: }
115:
116: /***
117: * Determine if a reply code is an informational response. All
118: * codes beginning with a 1 are positive informational responses.
119: * Informational responses are used to provide human readable
120: * information such as help text.
121: * <p>
122: * @param reply The reply code to test.
123: * @return True if a reply code is an informational response, false
124: * if not.
125: ***/
126: public static boolean isInformational(int reply) {
127: return (reply >= 100 && reply < 200);
128: }
129:
130: /***
131: * Determine if a reply code is a positive completion response. All
132: * codes beginning with a 2 are positive completion responses.
133: * The NNTP server will send a positive completion response on the final
134: * successful completion of a command.
135: * <p>
136: * @param reply The reply code to test.
137: * @return True if a reply code is a postive completion response, false
138: * if not.
139: ***/
140: public static boolean isPositiveCompletion(int reply) {
141: return (reply >= 200 && reply < 300);
142: }
143:
144: /***
145: * Determine if a reply code is a positive intermediate response. All
146: * codes beginning with a 3 are positive intermediate responses.
147: * The NNTP server will send a positive intermediate response on the
148: * successful completion of one part of a multi-part command or
149: * sequence of commands. For example, after a successful POST command,
150: * a positive intermediate response will be sent to indicate that the
151: * server is ready to receive the article to be posted.
152: * <p>
153: * @param reply The reply code to test.
154: * @return True if a reply code is a postive intermediate response, false
155: * if not.
156: ***/
157: public static boolean isPositiveIntermediate(int reply) {
158: return (reply >= 300 && reply < 400);
159: }
160:
161: /***
162: * Determine if a reply code is a negative transient response. All
163: * codes beginning with a 4 are negative transient responses.
164: * The NNTP server will send a negative transient response on the
165: * failure of a correctly formatted command that could not be performed
166: * for some reason. For example, retrieving an article that does not
167: * exist will result in a negative transient response.
168: * <p>
169: * @param reply The reply code to test.
170: * @return True if a reply code is a negative transient response, false
171: * if not.
172: ***/
173: public static boolean isNegativeTransient(int reply) {
174: return (reply >= 400 && reply < 500);
175: }
176:
177: /***
178: * Determine if a reply code is a negative permanent response. All
179: * codes beginning with a 5 are negative permanent responses.
180: * The NNTP server will send a negative permanent response when
181: * it does not implement a command, a command is incorrectly formatted,
182: * or a serious program error occurs.
183: * <p>
184: * @param reply The reply code to test.
185: * @return True if a reply code is a negative permanent response, false
186: * if not.
187: ***/
188: public static boolean isNegativePermanent(int reply) {
189: return (reply >= 500 && reply < 600);
190: }
191:
192: }
193:
194: /* Emacs configuration
195: * Local variables: **
196: * mode: java **
197: * c-basic-offset: 4 **
198: * indent-tabs-mode: nil **
199: * End: **
200: */
|