KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > ristretto > smtp > SMTPResponse


1 /* ***** BEGIN LICENSE BLOCK *****
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * The contents of this file are subject to the Mozilla Public License Version
5  * 1.1 (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS" basis,
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11  * for the specific language governing rights and limitations under the
12  * License.
13  *
14  * The Original Code is Ristretto Mail API.
15  *
16  * The Initial Developers of the Original Code are
17  * Timo Stich and Frederik Dietz.
18  * Portions created by the Initial Developers are Copyright (C) 2004
19  * All Rights Reserved.
20  *
21  * Contributor(s):
22  *
23  * Alternatively, the contents of this file may be used under the terms of
24  * either the GNU General Public License Version 2 or later (the "GPL"), or
25  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26  * in which case the provisions of the GPL or the LGPL are applicable instead
27  * of those above. If you wish to allow use of your version of this file only
28  * under the terms of either the GPL or the LGPL, and not to allow others to
29  * use your version of this file under the terms of the MPL, indicate your
30  * decision by deleting the provisions above and replace them with the notice
31  * and other provisions required by the GPL or the LGPL. If you do not delete
32  * the provisions above, a recipient may use your version of this file under
33  * the terms of any one of the MPL, the GPL or the LGPL.
34  *
35  * ***** END LICENSE BLOCK ***** */

36 package org.columba.ristretto.smtp;
37
38
39 /**
40  * Represents a reponse from a SMTP server.
41  * This response is normally obtained by calling SMTPInputStream.readSingleLineResponse().
42  *
43  * @see SMTPInputStream
44  *
45  * @author Timo Stich <tstich@users.sourceforge.net>
46  */

47 public class SMTPResponse {
48
49     private int code;
50     private String JavaDoc message;
51     private String JavaDoc domain;
52     private boolean hasSuccessor;
53     
54     /**
55      * Constructs a SMTPResponse.
56      *
57      * @param code the return code
58      * @param hasSuccessor true if there is another reponse to read from the server
59      * @param message the human readable message
60      */

61     public SMTPResponse(int code, boolean hasSuccessor, String JavaDoc message) {
62         this.code = code;
63         this.message = message;
64         this.hasSuccessor = hasSuccessor;
65     }
66     
67     /**
68      * Constructs a SMTPResponse.
69      *
70      * @param code the return code
71      * @param hasSuccessor true if there is another reponse to read from the server
72      * @param message the human readable message
73      * @param domain the domain of the server
74      */

75     public SMTPResponse(int code, boolean hasSuccessor, String JavaDoc message, String JavaDoc domain) {
76         this.code = code;
77         this.message = message;
78         this.hasSuccessor = hasSuccessor;
79         this.domain = domain;
80     }
81
82     /**
83      * @return Returns the code.
84      */

85     public int getCode() {
86         return code;
87     }
88
89     /**
90      * @param code The code to set.
91      */

92     public void setCode(int code) {
93         this.code = code;
94     }
95
96     /**
97      * @return Returns the message.
98      */

99     public String JavaDoc getMessage() {
100         return message;
101     }
102
103     /**
104      * @param message The message to set.
105      */

106     public void setMessage(String JavaDoc message) {
107         this.message = message;
108     }
109
110     /**
111      * @return Returns the domain.
112      */

113     public String JavaDoc getDomain() {
114         return domain;
115     }
116
117     /**
118      * @param domain The domain to set.
119      */

120     public void setDomain(String JavaDoc domain) {
121         this.domain = domain;
122     }
123
124     /**
125      * @return Returns the hasSuccessor.
126      */

127     public boolean isHasSuccessor() {
128         return hasSuccessor;
129     }
130
131     /**
132      * @param hasSuccessor The hasSuccessor to set.
133      */

134     public void setHasSuccessor(boolean hasSuccessor) {
135         this.hasSuccessor = hasSuccessor;
136     }
137     
138     
139     /**
140      * Is the reponse an error response?
141      * True if the return code is >= 400.
142      *
143      * @return true if the response is an error response.
144      */

145     public boolean isERR() {
146         return code >= 400;
147     }
148
149     /**
150      * Is the reponse an ok response?
151      * True if the return code is < 400.
152      *
153      * @return true if the response is an ok response.
154      */

155     public boolean isOK() {
156         return code < 400;
157     }
158    }
159
Popular Tags