Source Code Cross Referenced for Email.java in  » Web-Framework » rife-1.6.1 » com » uwyn » rife » mail » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » rife 1.6.1 » com.uwyn.rife.mail 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
003:         * Distributed under the terms of either:
004:         * - the common development and distribution license (CDDL), v1.0; or
005:         * - the GNU Lesser General Public License, v2.1 or later
006:         * $Id: Email.java 3634 2007-01-08 21:42:24Z gbevin $
007:         */
008:        package com.uwyn.rife.mail;
009:
010:        import com.uwyn.rife.site.ConstrainedBean;
011:        import com.uwyn.rife.site.ConstrainedProperty;
012:        import com.uwyn.rife.site.Validation;
013:
014:        /**
015:         * Contains the details of an email message that will be sent through the mail
016:         * queue.
017:         *
018:         * @author Geert Bevin (gbevin[remove] at uwyn dot com)
019:         * @version $Revision: 3634 $
020:         * @since 1.0
021:         */
022:        public class Email extends
023:                Validation<ConstrainedBean, ConstrainedProperty> {
024:            private int mId = -1;
025:            private String mFromAddress = null;
026:            private String mToAddresses = null;
027:            private String mSubject = null;
028:            private String mBody = null;
029:            private String mCcAddresses = null;
030:            private String mBccAddresses = null;
031:
032:            private boolean mQueueFlag = false;
033:
034:            protected void activateValidation() {
035:                addConstraint(new ConstrainedProperty("id").notNull(true)
036:                        .identifier(true));
037:                addConstraint(new ConstrainedProperty("fromAddress").notNull(
038:                        true).notEmpty(true).maxLength(255));
039:                addConstraint(new ConstrainedProperty("toAddresses").notNull(
040:                        true).notEmpty(true).maxLength(255));
041:                addConstraint(new ConstrainedProperty("subject").notNull(true)
042:                        .notEmpty(true).maxLength(255));
043:                addConstraint(new ConstrainedProperty("body").notNull(true)
044:                        .notEmpty(true));
045:                addConstraint(new ConstrainedProperty("ccAddresses")
046:                        .maxLength(255));
047:                addConstraint(new ConstrainedProperty("bccAddresses")
048:                        .maxLength(255));
049:            }
050:
051:            /**
052:             * Creates a new instance.
053:             *
054:             * @since 1.0
055:             */
056:            public Email() {
057:            }
058:
059:            /**
060:             * Sets the id.
061:             *
062:             * @param id the id
063:             * @return the <code>Email</code> instance
064:             */
065:            public Email id(int id) {
066:                mId = id;
067:
068:                return this ;
069:            }
070:
071:            /**
072:             * Sets the id of this instance.
073:             *
074:             * @param id the id
075:             */
076:            public void setId(int id) {
077:                mId = id;
078:            }
079:
080:            /**
081:             * Retrieves the id of this instance.
082:             *
083:             * @return the requested id
084:             */
085:            public int getId() {
086:                return mId;
087:            }
088:
089:            /**
090:             * Sets the <code>from</code> email address.
091:             *
092:             * @param from an email address
093:             * @return the <code>Email</code> instance
094:             */
095:            public Email from(String from) {
096:                mFromAddress = from;
097:
098:                return this ;
099:            }
100:
101:            /**
102:             * Sets the <code>from</code> email address.
103:             *
104:             * @param from an email address
105:             */
106:            public void setFromAddress(String from) {
107:                mFromAddress = from;
108:            }
109:
110:            /**
111:             * Retrieves the <code>from</code> email address.
112:             *
113:             * @return a String
114:             */
115:            public String getFromAddress() {
116:                return mFromAddress;
117:            }
118:
119:            /**
120:             * Adds a <code>to</code> email address.
121:             *
122:             * @param toAddress an email address
123:             * @return the <code>Email</code> instance
124:             */
125:            public Email to(String toAddress) {
126:                addTo(toAddress);
127:                return this ;
128:            }
129:
130:            /**
131:             * Adds a <code>to</code> email address.
132:             *
133:             * @param toAddress an email address
134:             */
135:            public void addTo(String toAddress) {
136:                if (null == mToAddresses) {
137:                    mToAddresses = toAddress;
138:                } else {
139:                    mToAddresses += "," + toAddress;
140:                }
141:            }
142:
143:            /**
144:             * Sets the <code>to</code> email addresses. This replaces all
145:             * previous ones.
146:             * <p>The email addresses need to be separated by commas.
147:             *
148:             * @param toAddresses the email addresses, separated by commas
149:             * @return the <code>Email</code> instance
150:             */
151:            public Email toAddresses(String toAddresses) {
152:                setToAddresses(toAddresses);
153:                return this ;
154:            }
155:
156:            /**
157:             * Sets the <code>to</code> email addresses. This replaces all
158:             * previous ones.
159:             * <p>The email addresses need to be separated by commas.
160:             *
161:             * @param toAddresses the email addresses, separated by commas
162:             */
163:            public void setToAddresses(String toAddresses) {
164:                mToAddresses = toAddresses;
165:            }
166:
167:            /**
168:             * Retrieves the <code>to</code> email addresses.
169:             *
170:             * @return the <code>to</code> email addresses, separated by commas
171:             */
172:            public String getToAddresses() {
173:                return mToAddresses;
174:            }
175:
176:            /**
177:             * Sets the subject.
178:             *
179:             * @param subject the subject
180:             * @return the <code>Email</code> instance
181:             */
182:            public Email subject(String subject) {
183:                mSubject = subject;
184:
185:                return this ;
186:            }
187:
188:            /**
189:             * Sets the subject .
190:             *
191:             * @param subject the subject
192:             */
193:            public void setSubject(String subject) {
194:                mSubject = subject;
195:            }
196:
197:            /**
198:             * Retrieves the subject.
199:             *
200:             * @return the subject
201:             */
202:            public String getSubject() {
203:                return mSubject;
204:            }
205:
206:            /**
207:             * Sets the body.
208:             *
209:             * @param body the body
210:             * @return the <code>Email</code> instance
211:             */
212:            public Email body(String body) {
213:                mBody = body;
214:
215:                return this ;
216:            }
217:
218:            /**
219:             * Sets the body.
220:             *
221:             * @param body the body
222:             */
223:            public void setBody(String body) {
224:                mBody = body;
225:            }
226:
227:            /**
228:             * Retrieves the body.
229:             *
230:             * @return the body
231:             */
232:            public String getBody() {
233:                return mBody;
234:            }
235:
236:            /**
237:             * Adds a <code>cc</code> email address.
238:             *
239:             * @param ccAddress an email address
240:             * @return the <code>Email</code> instance
241:             */
242:            public Email cc(String ccAddress) {
243:                addCc(ccAddress);
244:                return this ;
245:            }
246:
247:            /**
248:             * Adds a <code>cc</code> email address.
249:             *
250:             * @param ccAddress an email address
251:             */
252:            public void addCc(String ccAddress) {
253:                if (null == mCcAddresses) {
254:                    mCcAddresses = ccAddress;
255:                } else {
256:                    mCcAddresses += "," + ccAddress;
257:                }
258:            }
259:
260:            /**
261:             * Sets the <code>cc</code> email addresses. This replaces all
262:             * previous ones.
263:             * <p>The email addresses need to be separated by commas.
264:             *
265:             * @param ccAddresses the email addresses, separated by commas
266:             * @return the <code>Email</code> instance
267:             */
268:            public Email ccAddresses(String ccAddresses) {
269:                setCcAddresses(ccAddresses);
270:                return this ;
271:            }
272:
273:            /**
274:             * Sets the <code>cc</code> email addresses. This replaces all
275:             * previous ones.
276:             * <p>The email addresses need to be separated by commas.
277:             *
278:             * @param ccAddresses the email addresses, separated by commas
279:             */
280:            public void setCcAddresses(String ccAddresses) {
281:                mCcAddresses = ccAddresses;
282:            }
283:
284:            /**
285:             * Retrieves the <code>cc</code> email addresses.
286:             *
287:             * @return the <code>cc</code> email addresses, separated by commas
288:             */
289:            public String getCcAddresses() {
290:                return mCcAddresses;
291:            }
292:
293:            /**
294:             * Adds a <code>bcc</code> email address.
295:             *
296:             * @param bccAddress an email address
297:             * @return the <code>Email</code> instance
298:             */
299:            public Email bcc(String bccAddress) {
300:                addBcc(bccAddress);
301:                return this ;
302:            }
303:
304:            /**
305:             * Adds a <code>bcc</code> email address.
306:             *
307:             * @param bccAddress an email address
308:             */
309:            public void addBcc(String bccAddress) {
310:                if (null == mBccAddresses) {
311:                    mBccAddresses = bccAddress;
312:                } else {
313:                    mBccAddresses += "," + bccAddress;
314:                }
315:            }
316:
317:            /**
318:             * Sets the <code>bcc</code> email addresses. This replaces all
319:             * previous ones.
320:             * <p>The email addresses need to be separated by commas.
321:             *
322:             * @param bccAddresses the email addresses, separated by commas
323:             * @return the <code>Email</code> instance
324:             */
325:            public Email bccAddresses(String bccAddresses) {
326:                setBccAddresses(bccAddresses);
327:                return this ;
328:            }
329:
330:            /**
331:             * Sets the <code>bcc</code> email addresses. This replaces all
332:             * previous ones.
333:             * <p>The email addresses need to be separated by commas.
334:             *
335:             * @param bccAddresses the email addresses, separated by commas
336:             */
337:            public void setBccAddresses(String bccAddresses) {
338:                mBccAddresses = bccAddresses;
339:            }
340:
341:            /**
342:             * Retrieves the <code>bcc</code> email addresses.
343:             *
344:             * @return the bcc email addresses, separated by commas
345:             */
346:            public String getBccAddresses() {
347:                return mBccAddresses;
348:            }
349:
350:            /**
351:             * Retrieves the queue flag, this is only for internal use.
352:             *
353:             * @return <code>true</code> if the message is queued; and
354:             * <p><code>false</code> otherwise
355:             */
356:            public boolean getQueueFlag() {
357:                return mQueueFlag;
358:            }
359:
360:            /**
361:             * Sets the queue flag, this is only for internal use.
362:             *
363:             * @param queueFlag the queue flag
364:             */
365:            public void setQueueFlag(boolean queueFlag) {
366:                mQueueFlag = queueFlag;
367:            }
368:
369:            public int hashCode() {
370:                int result;
371:
372:                result = 0;
373:                result = 29 * result
374:                        + (mFromAddress != null ? mFromAddress.hashCode() : 0);
375:                result = 29 * result
376:                        + (mToAddresses != null ? mToAddresses.hashCode() : 0);
377:                result = 29 * result
378:                        + (mSubject != null ? mSubject.hashCode() : 0);
379:                result = 29 * result + (mBody != null ? mBody.hashCode() : 0);
380:                result = 29 * result
381:                        + (mCcAddresses != null ? mCcAddresses.hashCode() : 0);
382:                result = 29
383:                        * result
384:                        + (mBccAddresses != null ? mBccAddresses.hashCode() : 0);
385:
386:                return result;
387:            }
388:
389:            public boolean equals(Object other) {
390:                if (null == other) {
391:                    return false;
392:                }
393:
394:                if (other == this ) {
395:                    return true;
396:                }
397:
398:                if (!(other instanceof  Email)) {
399:                    return false;
400:                }
401:
402:                Email other_email = (Email) other;
403:
404:                if (other_email.getFromAddress() != null
405:                        || getFromAddress() != null) {
406:                    if (null == other_email.getFromAddress()
407:                            || null == getFromAddress()) {
408:                        return false;
409:                    }
410:                    if (!other_email.getFromAddress().equals(getFromAddress())) {
411:                        return false;
412:                    }
413:                }
414:
415:                if (other_email.getToAddresses() != null
416:                        || getToAddresses() != null) {
417:                    if (null == other_email.getToAddresses()
418:                            || null == getToAddresses()) {
419:                        return false;
420:                    }
421:                    if (!other_email.getToAddresses().equals(getToAddresses())) {
422:                        return false;
423:                    }
424:                }
425:
426:                if (other_email.getSubject() != null || getSubject() != null) {
427:                    if (null == other_email.getSubject()
428:                            || null == getSubject()) {
429:                        return false;
430:                    }
431:                    if (!other_email.getSubject().equals(getSubject())) {
432:                        return false;
433:                    }
434:                }
435:
436:                if (other_email.getBody() != null || getBody() != null) {
437:                    if (null == other_email.getBody() || null == getBody()) {
438:                        return false;
439:                    }
440:                    if (!other_email.getBody().equals(getBody())) {
441:                        return false;
442:                    }
443:                }
444:
445:                if (other_email.getCcAddresses() != null
446:                        || getCcAddresses() != null) {
447:                    if (null == other_email.getCcAddresses()
448:                            || null == getCcAddresses()) {
449:                        return false;
450:                    }
451:                    if (!other_email.getCcAddresses().equals(getCcAddresses())) {
452:                        return false;
453:                    }
454:                }
455:
456:                if (other_email.getBccAddresses() != null
457:                        || getBccAddresses() != null) {
458:                    if (null == other_email.getBccAddresses()
459:                            || null == getBccAddresses()) {
460:                        return false;
461:                    }
462:                    if (!other_email.getBccAddresses()
463:                            .equals(getBccAddresses())) {
464:                        return false;
465:                    }
466:                }
467:
468:                return true;
469:            }
470:
471:            public String toString() {
472:                return "Email{" + "mId=" + mId + ", mFromAddress="
473:                        + mFromAddress + ", mToAddresses=" + mToAddresses
474:                        + ", mSubject=" + mSubject + ", mBody=" + mBody
475:                        + ", mCcAddresses=" + mCcAddresses + ", mBccAddresses="
476:                        + mBccAddresses + "}";
477:            }
478:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.