KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > newsletter > CmsSimpleNewsletterRecipient


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/newsletter/CmsSimpleNewsletterRecipient.java,v $
3  * Date : $Date: 2006/03/27 14:52:48 $
4  * Version: $Revision: 1.2 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (C) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.newsletter;
33
34 /**
35  * Simple implementation of interface {@link I_CmsNewsletterRecipient}, with
36  * {@link I_CmsNewsletterRecipient#isSubscriber(org.opencms.newsletter.I_CmsNewsletterContent)} always returning true.<p>
37  *
38  * @author Jan Baudisch
39  * @author Alexander Kandzior
40  * @author Achim Westermann
41  *
42  * @version $Revision: 1.2 $
43  *
44  * @since 6.0.2
45  *
46  */

47 public class CmsSimpleNewsletterRecipient implements I_CmsNewsletterRecipient {
48
49     /** The email address of this recipient. */
50     private String JavaDoc m_email;
51
52     /** The firstname of this recipient. */
53     private String JavaDoc m_firstname;
54
55     /** The lastname of this recipient. */
56     private String JavaDoc m_lastname;
57
58     /** The nicename of this recipient. */
59     private String JavaDoc m_name;
60
61     /**
62      * Creates a new CmsSimpleNewsletterRecipient.<p>
63      *
64      * @param email the email address to be sent
65      * @param name the nicename of the recipient
66      */

67     public CmsSimpleNewsletterRecipient(String JavaDoc email, String JavaDoc name) {
68
69         m_email = email;
70         m_name = name;
71     }
72
73     /**
74      * Creates a new CmsSimpleNewsletterRecipient.<p>
75      *
76      * @param email the email address to be sent
77      * @param firstname the firstname of the recipient
78      * @param lastname the newsletter recipient's lastname
79      */

80     public CmsSimpleNewsletterRecipient(String JavaDoc email, String JavaDoc firstname, String JavaDoc lastname) {
81
82         m_email = email;
83         m_firstname = firstname;
84         m_lastname = lastname;
85         m_name = firstname + ' ' + lastname;
86     }
87
88     /**
89      *
90      * @see java.lang.Object#equals(java.lang.Object)
91      */

92     public boolean equals(Object JavaDoc obj) {
93
94         if (!(obj instanceof CmsSimpleNewsletterRecipient)) {
95             return false;
96         }
97         CmsSimpleNewsletterRecipient recipient = (CmsSimpleNewsletterRecipient)obj;
98         if (getEmail() != recipient.getEmail()) {
99             return false;
100         }
101         if (!getName().equals(recipient.getName())) {
102             return false;
103         }
104         return true;
105     }
106
107     /**
108      * @see org.opencms.newsletter.I_CmsNewsletterRecipient#getEmail()
109      */

110     public String JavaDoc getEmail() {
111
112         return m_email;
113     }
114
115     /**
116      * @see org.opencms.newsletter.I_CmsNewsletterRecipient#getFirstname()
117      */

118     public String JavaDoc getFirstname() {
119
120         return m_firstname;
121     }
122
123     /**
124      * @see org.opencms.newsletter.I_CmsNewsletterRecipient#getFullName()
125      */

126     public String JavaDoc getFullName() {
127
128         return m_name;
129     }
130
131     /**
132      * @see org.opencms.newsletter.I_CmsNewsletterRecipient#getLastname()
133      */

134     public String JavaDoc getLastname() {
135
136         return m_lastname;
137     }
138
139     /**
140      * Returns the name of the recipient.<p>
141      *
142      * @return the name of the recipient.
143      */

144     public String JavaDoc getName() {
145
146         return m_name;
147     }
148
149     /**
150      *
151      * @see java.lang.Object#hashCode()
152      */

153     public int hashCode() {
154
155         return m_email.hashCode() + m_firstname.hashCode() + m_lastname.hashCode() + m_name.hashCode();
156     }
157
158     /**
159      * @see org.opencms.newsletter.I_CmsNewsletterRecipient#isSubscriber(org.opencms.newsletter.I_CmsNewsletterContent)
160      */

161     public boolean isSubscriber(I_CmsNewsletterContent content) {
162
163         return true;
164     }
165
166     /**
167      * Set the email address of this recepient.<p>
168      *
169      * @param email the email address of this recepient to set.
170      */

171     protected void setEmail(String JavaDoc email) {
172
173         m_email = email;
174     }
175 }
Popular Tags