1 5 package org.exoplatform.services.communication.message.impl; 6 7 import java.util.Date ; 8 9 import org.apache.commons.lang.StringUtils; 10 import org.exoplatform.services.communication.message.MessageHeader; 11 12 13 22 public class MessageHeaderImpl implements MessageHeader { 23 private String id_; 24 25 private String folderId_; 26 27 private String mailMessageId_; 28 29 private String from_ = ""; 30 31 private String flags_ = ""; 32 33 private String subject_ = ""; 34 35 private Date receivedDate_; 36 37 public MessageHeaderImpl() { 38 } 39 40 43 public String getId() { 44 return id_; 45 } 46 47 public void setId(String value) { 48 id_ = value; 49 } 50 51 54 public String getFolderId() { 55 return folderId_; 56 } 57 58 public void setFolderId(String value) { 59 folderId_ = value; 60 } 61 62 65 public String getMailMessageId() { 66 return mailMessageId_; 67 } 68 69 public void setMailMessageId(String value) { 70 mailMessageId_ = value; 71 } 72 73 public String getFrom() { 74 return from_; 75 } 76 77 public void setFrom(String value) { 78 from_ = value; 79 } 80 81 84 public String getSender() { 85 return from_; 86 } 87 88 public void setSender(String value) { 89 from_ = value; 90 } 91 92 95 public String getFlags() { 96 return flags_; 97 } 98 99 public void setFlags(String value) { 100 flags_ = value; 101 } 102 103 106 public String getSubject() { 107 return subject_; 108 } 109 110 public void setSubject(String value) { 111 subject_ = value; 112 } 113 114 117 public Date getReceivedDate() { 118 return receivedDate_; 119 } 120 121 public void setReceivedDate(Date value) { 122 receivedDate_ = value; 123 } 124 125 public boolean isNew() { 126 return !hasFlag(MessageHeader.SEEN_FLAG); 127 } 128 129 public boolean hasFlag(String flag) { 130 if(flags_ == null) return false ; 131 return flags_.indexOf(flag) >= 0 ; 132 } 133 134 public void addFlag(String flag) { 135 if(flags_ == null || flags_.length() == 0) { 136 flags_ = flag ; 137 } else if(flags_.indexOf(flag) < 0){ 138 flags_ = "," + flag ; 139 } 140 } 141 142 public void removeFlag(String flag) { 143 String [] flags = StringUtils.split(flags_, ','); 144 StringBuffer b = new StringBuffer () ; 145 for (int i = 0; i < flags.length; i++) { 146 if (!flags[i].equals(flag)) { 147 if(i == 0) b.append(flags[i]) ; 148 else b.append(',').append(flags[i]) ; 149 } 150 } 151 flags_ = b.toString() ; 152 } 153 154 public String [] getFlagsAsArray(){ 155 return StringUtils.split(flags_, ','); 156 } 157 } | Popular Tags |