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.util.ArrayList;
023    import java.util.Date;
024    
025    /**
026     * 
027     *
028     */
029    public class Message extends AbstractMessage {
030    
031        /**
032         * 
033         */
034        private static final long serialVersionUID = -101492974974136423L;
035        private long uid;
036        private ArrayList<IMAPFlag> flags;
037        private ArrayList<Tag> tags;
038        private Date rDate;
039        
040        public enum IMAPFlag {
041            SEEN, DELETED, RECENT, ANSWERED, JUNK, DRAFT, FLAGGED, USER
042        }
043    
044        
045    
046        public void setFlags(ArrayList<IMAPFlag> flags) {
047            this.flags = flags;
048        }
049    
050        public ArrayList<IMAPFlag> getFlags() {
051            return flags;
052        }
053        
054        public void setTags(ArrayList<Tag> tags) {
055            this.tags = tags;
056        }
057        
058        public ArrayList<Tag> getTags() {
059            return tags;
060        }
061        
062        public long getUid() {
063            return uid;
064        }
065    
066        public void setUid(long uid) {
067            this.uid = uid;
068        }
069        
070        
071        public void setReceivedDate(Date rDate) {
072            this.rDate = rDate;
073        }
074    
075        public Date getReceivedDate() {
076            return rDate == null ? new Date(): rDate;
077        }
078        
079    
080        public String toString() {
081            return String.valueOf(getUid());
082        }
083        
084        public boolean equals(Object obj) {
085            if (obj instanceof Message) {
086                if (((Message)obj).getUid() == getUid()) {
087                    return true;
088                }
089            }
090            return false;
091        }
092        
093        public int hashCode() {
094            return Long.valueOf(getUid()).hashCode();
095        }
096    }