View Javadoc
1 /* 2 * PROJECT : emailEJB 3 * 4 * COPYRIGHT : Copyright (C) 1999-2003 Tim Stephenson 5 * 6 * contact me at gpl@enableit.org. 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 */ 22 package org.enableit.tools.email.interfaces; 23 24 import java.io.Serializable; 25 import java.util.ArrayList; 26 import java.util.List; 27 28 /*** 29 * A <code>JavaBean</code> encapsulating the configuration of an email to be 30 * sent. 31 * @author Tim Stephenson 32 */ 33 public class EmailConfigBean extends Object implements Serializable { 34 35 /*** 36 * A <code>String</code> of the email addresses to send to, 37 * comma-separated. 38 */ 39 private String to; 40 41 /*** The subject line of the email. */ 42 private String subject; 43 44 /*** Text to place in the body of the email. */ 45 private String message; 46 47 /*** The address the email will appear to be from. */ 48 private String from; 49 50 /*** <code>List</code> of <code>Attachments</code>. */ 51 private List attachmentList; 52 53 /*** 54 * Default constructor. 55 */ 56 public EmailConfigBean() { 57 attachmentList = new ArrayList() ; 58 } 59 60 /*** 61 * Constructor setting the basics (but not attachments) in one go. 62 * @param to Target email address(es). If more than one use comma to 63 * separate. 64 * @param from Message 'from' address. If supplied this overrides the 65 * default in the JNDI context. 66 * @param subject Subject for the mail message. 67 * @param message Body text for the mail message. 68 */ 69 public EmailConfigBean(String to, String from, 70 String subject, String message) { 71 this() ; 72 setTo(to) ; 73 setFrom(from) ; 74 setSubject(subject) ; 75 setMessage(message) ; 76 } 77 78 /*** 79 * @return <code>String</code> of the 'to' email addresses, comma-separated 80 */ 81 public String getTo() { 82 return to; 83 } 84 85 /*** @param newTo <code>String</code> of the 'to' email addresses */ 86 public void setTo(String newTo) { 87 to = newTo; 88 } 89 90 /*** 91 * Adds a new addressee. 92 * @param toAddress Extra email address to add. 93 */ 94 public void addTo(String toAddress) { 95 to += (", " + toAddress) ; 96 } 97 98 /*** @return Subject for the email */ 99 public String getSubject() { 100 return subject; 101 } 102 103 /*** @param newSubject Subject for the email */ 104 public void setSubject(String newSubject) { 105 subject = newSubject; 106 } 107 108 /*** @return Text for the message body */ 109 public String getMessage() { 110 return message; 111 } 112 113 /*** @param newMessage Text for the message body */ 114 public void setMessage(String newMessage) { 115 message = newMessage; 116 } 117 118 /*** @return The From address for the email. */ 119 public String getFrom() { 120 return from; 121 } 122 123 /*** @param newFrom The From address for the email. */ 124 public void setFrom(String newFrom) { 125 from = newFrom; 126 } 127 128 /*** 129 * @return <code>List</code> of either <code>Objects</code> or 130 * <code>java.net.URLs</code> to send to the 'to' email addresses 131 * as attachments. 132 */ 133 public List getAttachmentList() { 134 return attachmentList; 135 } 136 137 /*** 138 * Adds a new attachment. 139 * @param attachment The <code>Attachment</code> to add to the 140 * list for sending. 141 */ 142 public void addAttachment(Attachment attachment) { 143 attachmentList.add(attachment) ; 144 } 145 146 }

This page was automatically generated by Maven