KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jsmtpd > core > mail > Rcpt


1 /*
2  *
3  * Jsmtpd, Java SMTP daemon
4  * Copyright (C) 2005 Jean-Francois POUX, jf.poux@laposte.net
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  *
20  */

21 package org.jsmtpd.core.mail;
22
23 import java.io.Serializable JavaDoc;
24
25 /**
26  * Holds the delivery status of a mail RCPT
27  * @author Jean-Francois POUX
28  */

29 public class Rcpt implements Serializable JavaDoc {
30
31     private EmailAddress emailAddress = null;
32     private int deliveryAttempts = STATUS_PENDING;
33     private int status;
34     private String JavaDoc lastError="";
35     
36     public Rcpt(EmailAddress e) {
37         emailAddress = e;
38     }
39     
40     public Rcpt (Rcpt original) {
41         setEmailAddress(new EmailAddress(original.getEmailAddress()));
42         deliveryAttempts = original.getDeliveryAttempts();
43         status = original.getStatus();
44         lastError=new String JavaDoc (original.getLastError());
45     }
46     
47     public EmailAddress getEmailAddress() {
48         return emailAddress;
49     }
50
51     public void setEmailAddress(EmailAddress e) {
52         emailAddress = e;
53     }
54
55     /**
56      *
57      * @return number of attempts failed to deliver the mail
58      */

59     public int getDeliveryAttempts() {
60         return deliveryAttempts;
61     }
62
63     /**
64      *
65      * @return the RCPT is consired delivered when :
66      * Successufully delivered
67      * Fatal delivery error (in that case the server will genere a new mail to inform of the error)
68      */

69     public boolean isDelivered() {
70         if (status == STATUS_DELIVERED || status == STATUS_ERROR_FATAL)
71             return true;
72         return false;
73     }
74
75     public void setDelivered(int status) {
76         this.status = status;
77         deliveryAttempts++;
78     }
79
80     public String JavaDoc getLastError() {
81         return lastError;
82     }
83     public void setLastError(String JavaDoc lastError) {
84         this.lastError = lastError;
85     }
86     
87     public static final int STATUS_PENDING = 0;
88     public static final int STATUS_ERROR_NOT_FATAL = 1;
89     public static final int STATUS_ERROR_FATAL = 2;
90     public static final int STATUS_DELIVERED = 3;
91     
92     
93     public int getStatus() {
94         return status;
95     }
96
97     @Override JavaDoc
98     public String JavaDoc toString() {
99         if (emailAddress==null)
100             return "null adress";
101         return this.emailAddress.toString();
102     }
103 }
Popular Tags