KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > net > smtp > SMTPReply


1 /*
2  * Copyright 2001-2005 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.smtp;
17
18 /***
19  * SMTPReply stores a set of constants for SMTP reply codes. To interpret
20  * the meaning of the codes, familiarity with RFC 821 is assumed.
21  * The mnemonic constant names are transcriptions from the code descriptions
22  * of RFC 821. For those who think in terms of the actual reply code values,
23  * a set of CODE_NUM constants are provided where NUM is the numerical value
24  * of the code.
25  * <p>
26  * <p>
27  * @author Daniel F. Savarese
28  ***/

29
30 public final class SMTPReply
31 {
32
33     public static final int CODE_211 = 211;
34     public static final int CODE_214 = 214;
35     public static final int CODE_215 = 215;
36     public static final int CODE_220 = 220;
37     public static final int CODE_221 = 221;
38     public static final int CODE_250 = 250;
39     public static final int CODE_251 = 251;
40     public static final int CODE_354 = 354;
41     public static final int CODE_421 = 421;
42     public static final int CODE_450 = 450;
43     public static final int CODE_451 = 451;
44     public static final int CODE_452 = 452;
45     public static final int CODE_500 = 500;
46     public static final int CODE_501 = 501;
47     public static final int CODE_502 = 502;
48     public static final int CODE_503 = 503;
49     public static final int CODE_504 = 504;
50     public static final int CODE_550 = 550;
51     public static final int CODE_551 = 551;
52     public static final int CODE_552 = 552;
53     public static final int CODE_553 = 553;
54     public static final int CODE_554 = 554;
55
56     public static final int SYSTEM_STATUS = CODE_211;
57     public static final int HELP_MESSAGE = CODE_214;
58     public static final int SERVICE_READY = CODE_220;
59     public static final int SERVICE_CLOSING_TRANSMISSION_CHANNEL = CODE_221;
60     public static final int ACTION_OK = CODE_250;
61     public static final int USER_NOT_LOCAL_WILL_FORWARD = CODE_251;
62     public static final int START_MAIL_INPUT = CODE_354;
63     public static final int SERVICE_NOT_AVAILABLE = CODE_421;
64     public static final int ACTION_NOT_TAKEN = CODE_450;
65     public static final int ACTION_ABORTED = CODE_451;
66     public static final int INSUFFICIENT_STORAGE = CODE_452;
67     public static final int UNRECOGNIZED_COMMAND = CODE_500;
68     public static final int SYNTAX_ERROR_IN_ARGUMENTS = CODE_501;
69     public static final int COMMAND_NOT_IMPLEMENTED = CODE_502;
70     public static final int BAD_COMMAND_SEQUENCE = CODE_503;
71     public static final int COMMAND_NOT_IMPLEMENTED_FOR_PARAMETER = CODE_504;
72     public static final int MAILBOX_UNAVAILABLE = CODE_550;
73     public static final int USER_NOT_LOCAL = CODE_551;
74     public static final int STORAGE_ALLOCATION_EXCEEDED = CODE_552;
75     public static final int MAILBOX_NAME_NOT_ALLOWED = CODE_553;
76     public static final int TRANSACTION_FAILED = CODE_554;
77
78     // Cannot be instantiated
79
private SMTPReply()
80     {}
81
82     /***
83      * Determine if a reply code is a positive preliminary response. All
84      * codes beginning with a 1 are positive preliminary responses.
85      * Postitive preliminary responses are used to indicate tentative success.
86      * No further commands can be issued to the SMTP server after a positive
87      * preliminary response until a follow up response is received from the
88      * server.
89      * <p>
90      * <b> Note: </b> <em> No SMTP commands defined in RFC 822 provide this
91      * type of reply. </em>
92      * <p>
93      * @param reply The reply code to test.
94      * @return True if a reply code is a postive preliminary response, false
95      * if not.
96      ***/

97     public static boolean isPositivePreliminary(int reply)
98     {
99         return (reply >= 100 && reply < 200);
100     }
101
102     /***
103      * Determine if a reply code is a positive completion response. All
104      * codes beginning with a 2 are positive completion responses.
105      * The SMTP server will send a positive completion response on the final
106      * successful completion of a command.
107      * <p>
108      * @param reply The reply code to test.
109      * @return True if a reply code is a postive completion response, false
110      * if not.
111      ***/

112     public static boolean isPositiveCompletion(int reply)
113     {
114         return (reply >= 200 && reply < 300);
115     }
116
117     /***
118      * Determine if a reply code is a positive intermediate response. All
119      * codes beginning with a 3 are positive intermediate responses.
120      * The SMTP server will send a positive intermediate response on the
121      * successful completion of one part of a multi-part sequence of
122      * commands. For example, after a successful DATA command, a positive
123      * intermediate response will be sent to indicate that the server is
124      * ready to receive the message data.
125      * <p>
126      * @param reply The reply code to test.
127      * @return True if a reply code is a postive intermediate response, false
128      * if not.
129      ***/

130     public static boolean isPositiveIntermediate(int reply)
131     {
132         return (reply >= 300 && reply < 400);
133     }
134
135     /***
136      * Determine if a reply code is a negative transient response. All
137      * codes beginning with a 4 are negative transient responses.
138      * The SMTP server will send a negative transient response on the
139      * failure of a command that can be reattempted with success.
140      * <p>
141      * @param reply The reply code to test.
142      * @return True if a reply code is a negative transient response, false
143      * if not.
144      ***/

145     public static boolean isNegativeTransient(int reply)
146     {
147         return (reply >= 400 && reply < 500);
148     }
149
150     /***
151      * Determine if a reply code is a negative permanent response. All
152      * codes beginning with a 5 are negative permanent responses.
153      * The SMTP server will send a negative permanent response on the
154      * failure of a command that cannot be reattempted with success.
155      * <p>
156      * @param reply The reply code to test.
157      * @return True if a reply code is a negative permanent response, false
158      * if not.
159      ***/

160     public static boolean isNegativePermanent(int reply)
161     {
162         return (reply >= 500 && reply < 600);
163     }
164
165 }
166
Popular Tags