001    /****************************************************************
002     * Licensed to the Apache Software Foundation (ASF) under one   *
003     * or more contributor license agreements.  See the NOTICE file *
004     * distributed with this work for additional information        *
005     * regarding copyright ownership.  The ASF licenses this file   *
006     * to you under the Apache License, Version 2.0 (the            *
007     * "License"); you may not use this file except in compliance   *
008     * with the License.  You may obtain a copy of the License at   *
009     *                                                              *
010     *   http://www.apache.org/licenses/LICENSE-2.0                 *
011     *                                                              *
012     * Unless required by applicable law or agreed to in writing,   *
013     * software distributed under the License is distributed on an  *
014     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
015     * KIND, either express or implied.  See the License for the    *
016     * specific language governing permissions and limitations      *
017     * under the License.                                           *
018     ****************************************************************/
019    
020    package org.apache.hupa.shared.data;
021    
022    import java.io.Serializable;
023    import java.util.ArrayList;
024    
025    public class AbstractMessage implements Serializable{
026        
027        /**
028         * 
029         */
030        private static final long serialVersionUID = 5208272852772006815L;
031        private String from;
032        private String subject;
033        private String replyto;
034        private ArrayList<String> to;
035        private ArrayList<String> cc;
036        private boolean hasAttachment;
037        
038        public String toString() {
039            StringBuffer toList = new StringBuffer("");
040            if (to != null)
041                for (String s: to)
042                    toList.append(s).append(" ");
043    
044            StringBuffer ccList = new StringBuffer("");
045            if (cc != null)
046                for (String s: cc)
047                    ccList.append(s).append(" ");
048    
049            return "From='" + from 
050                 + "' To='" + toList.toString()
051                 + "' CC='" + ccList.toString()
052                 + "' ReplyTo='" + (replyto == null ? "": replyto)
053                 + "' Subject='" + subject
054                 + "' Attachments=" + hasAttachment;
055        }
056    
057        
058        public boolean hasAttachment() {
059            return hasAttachment;
060        }
061        
062        public void setHasAttachments(boolean hasAttachments) {
063            this.hasAttachment = hasAttachments;
064        }
065        
066        /**
067         * Set the From: header field
068         * 
069         * @param from
070         */
071        public void setFrom(String from) {
072            this.from = from;
073        }
074    
075        /**
076         * Return the From: header field
077         * 
078         * @return from
079         */
080        public String getFrom() {
081            return from;
082        }
083    
084    
085        public void setCc(ArrayList<String> cc) {
086            this.cc = cc;
087        }
088    
089        public ArrayList<String> getCc() {
090            return cc;
091        }
092    
093        /**
094         * Set the Subject: header field
095         * 
096         * @param subject
097         */
098        public void setSubject(String subject) {
099            this.subject = subject;
100        }
101    
102        /**
103         * Return the Subject: header field
104         * 
105         * @return subject
106         */
107        public String getSubject() {
108            return subject;
109        }
110    
111        public ArrayList<String> getTo() {
112            return to;
113        }
114    
115        public void setTo(ArrayList<String> to) {
116            this.to = to;
117        }
118        
119        public String getReplyto() {
120            return replyto;
121        }
122    
123        public void setReplyto(String replyto) {
124            this.replyto = replyto;
125        }
126    
127    
128    }