KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > communication > message > impl > MessageImpl


1 /*******************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. * Please look
3  * at license.txt in info directory for more license detail. *
4  ******************************************************************************/

5 package org.exoplatform.services.communication.message.impl;
6
7 import java.util.*;
8 import org.exoplatform.services.communication.message.Attachment;
9 import org.exoplatform.services.communication.message.Message;
10 /**
11  * Fri, May 30, 2003 @ @author: Tuan Nguyen @version: $Id: Message.java,v 1.2
12  * 2004/08/27 02:43:29 tuan08 Exp $ @since: 0.0 @email: tuan08@yahoo.com
13  * Author : Benjamin Mestrallet
14  * benjamin.mestrallet@exoplatform.com
15  * @hibernate.class table="EXO_MESSAGE"
16  * @hibernate.cache usage="read-write"
17  **/

18 public class MessageImpl extends MessageHeaderImpl implements Message {
19   private String JavaDoc receiver = "";
20   private String JavaDoc CC = "";
21   private String JavaDoc BCC = "";
22   private String JavaDoc body = "";
23   private List attachments;
24
25   public String JavaDoc getTo() { return receiver;}
26   public void setTo(String JavaDoc value) { receiver = value; }
27   
28   /**
29    * @hibernate.property
30    **/

31   public String JavaDoc getReceiver() { return receiver;}
32   public void setReceiver(String JavaDoc value) { receiver = value; }
33   
34   /**
35    * @hibernate.property
36    **/

37   public String JavaDoc getCC() { return CC; }
38   public void setCC(String JavaDoc value) { CC = value; }
39
40   /**
41    * @hibernate.property
42    **/

43   public String JavaDoc getBCC() { return BCC; }
44   public void setBCC(String JavaDoc value) { BCC = value; }
45
46   /**
47    * @hibernate.property
48    **/

49   public String JavaDoc getBody() { return body; }
50   public void setBody(String JavaDoc value) { body = value; }
51
52   public void addAttachment(Attachment attachment) {
53     if(attachments == null) attachments = new ArrayList() ;
54     attachments.add(attachment) ;
55   }
56   
57   public List getAttachment() { return attachments; }
58   
59   public MessageImpl cloneMessage() {
60     MessageImpl newMessage = new MessageImpl() ;
61     newMessage.setFolderId(getFolderId()) ;
62     newMessage.setMailMessageId(getMailMessageId()) ;
63     newMessage.setFrom(getFrom()) ;
64     newMessage.setTo(getTo());
65     newMessage.setCC(getCC()) ;
66     newMessage.setBCC(getBCC()) ;
67     newMessage.setFlags(getFlags());
68     newMessage.setSender(getSender()) ;
69     newMessage.setBody(getBody()) ;
70     newMessage.setSubject(getSubject()) ;
71     newMessage.setReceivedDate(getReceivedDate()) ;
72     if(attachments != null) {
73       for(int i = 0; i < attachments.size(); i++) {
74         AttachmentImpl attachment = (AttachmentImpl) attachments.get(i) ;
75         newMessage.addAttachment(attachment.cloneAttachment()) ;
76       }
77     }
78     return newMessage ;
79   }
80 }
Popular Tags