001: /*
002: * Copyright (C) 2003 Erik Swenson - erik@oreports.com
003: *
004: * This program is free software; you can redistribute it and/or modify it under the terms of the
005: * GNU General Public License as published by the Free Software Foundation; either version 2 of the
006: * License, or (at your option) any later version.
007: *
008: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
009: * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
010: * the GNU General Public License for more details.
011: *
012: * You should have received a copy of the GNU General Public License along with this program; if
013: * not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
014: * 02111-1307, USA.
015: *
016: */
017:
018: package org.efs.openreports.objects;
019:
020: import java.io.Serializable;
021: import java.util.ArrayList;
022: import java.util.StringTokenizer;
023:
024: import org.efs.openreports.util.ByteArrayDataSource;
025:
026: public class MailMessage implements Serializable {
027: private static final long serialVersionUID = -5816798771288286268L;
028:
029: private String sender;
030: private String subject;
031: private String text;
032: private String bounceAddress;
033:
034: private ArrayList<String> recipients = new ArrayList<String>();
035: private ArrayList<String> attachments = new ArrayList<String>();
036: private ArrayList<ByteArrayDataSource> htmlImageDataSources = new ArrayList<ByteArrayDataSource>();
037:
038: private ByteArrayDataSource byteArrayDataSource;
039:
040: public MailMessage() {
041: }
042:
043: public String getSender() {
044: return sender;
045: }
046:
047: public void setSender(String sender) {
048: this .sender = sender;
049: }
050:
051: public ArrayList<String> getRecipients() {
052: return recipients;
053: }
054:
055: public void setRecipients(ArrayList<String> recipients) {
056: this .recipients = recipients;
057: }
058:
059: public String getSubject() {
060: return subject;
061: }
062:
063: public void setSubject(String subject) {
064: this .subject = subject;
065: }
066:
067: public String getText() {
068: return text;
069: }
070:
071: public void setText(String text) {
072: this .text = text;
073: }
074:
075: public ByteArrayDataSource getByteArrayDataSource() {
076: return byteArrayDataSource;
077: }
078:
079: public void setByteArrayDataSource(
080: ByteArrayDataSource byteArrayDataSource) {
081: this .byteArrayDataSource = byteArrayDataSource;
082: }
083:
084: public ArrayList<String> getAttachments() {
085: return attachments;
086: }
087:
088: public void addAttachment(String fileName) {
089: attachments.add(fileName);
090: }
091:
092: public void addRecepient(String recipient) {
093: recipients.add(recipient);
094: }
095:
096: public String formatRecipients(String delimiter) {
097: String addresses = "";
098:
099: for (int i = 0; i < recipients.size(); i++) {
100: addresses += recipients.get(i) + delimiter;
101: }
102:
103: return addresses.substring(0, addresses.length() - 1);
104: }
105:
106: public void parseRecipients(String value) {
107: StringTokenizer st = new StringTokenizer(value, "\t\n\r\f;,|");
108:
109: recipients = new ArrayList<String>();
110:
111: while (st.hasMoreElements()) {
112: recipients.add(st.nextToken());
113: }
114: }
115:
116: public ArrayList<ByteArrayDataSource> getHtmlImageDataSources() {
117: return htmlImageDataSources;
118: }
119:
120: public void addHtmlImageDataSources(
121: ArrayList<ByteArrayDataSource> htmlImageDataSources) {
122: this .htmlImageDataSources.addAll(htmlImageDataSources);
123: }
124:
125: public String getBounceAddress() {
126: return bounceAddress;
127: }
128:
129: public void setBounceAddress(String bounceAddress) {
130: this.bounceAddress = bounceAddress;
131: }
132:
133: }
|