KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > james > imapserver > store > SimpleImapMessage


1 /***********************************************************************
2  * Copyright (c) 2000-2004 The Apache Software Foundation. *
3  * All rights reserved. *
4  * ------------------------------------------------------------------- *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you *
6  * may not use this file except in compliance with the License. You *
7  * may obtain a copy of the License at: *
8  * *
9  * http://www.apache.org/licenses/LICENSE-2.0 *
10  * *
11  * Unless required by applicable law or agreed to in writing, software *
12  * distributed under the License is distributed on an "AS IS" BASIS, *
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or *
14  * implied. See the License for the specific language governing *
15  * permissions and limitations under the License. *
16  ***********************************************************************/

17
18 package org.apache.james.imapserver.store;
19
20 import org.apache.avalon.framework.logger.AbstractLogEnabled;
21
22 import javax.mail.internet.MimeMessage JavaDoc;
23 import javax.mail.MessagingException JavaDoc;
24 import java.util.Date JavaDoc;
25
26 /**
27  * A mail message with all of the extra stuff that IMAP requires.
28  * This is just a placeholder object, while I work out what's really required. A common
29  * way of handling *all* messages needs to be available for James (maybe MailImpl?)
30  *
31  * @version $Revision: 1.2.2.3 $
32  */

33 public class SimpleImapMessage
34         extends AbstractLogEnabled implements ImapMessage
35 {
36     private MimeMessage JavaDoc mimeMessage;
37     private MessageFlags flags;
38     private Date JavaDoc internalDate;
39     private long uid;
40     private SimpleMessageAttributes attributes;
41
42     SimpleImapMessage( MimeMessage JavaDoc mimeMessage, MessageFlags flags,
43                  Date JavaDoc internalDate, long uid )
44     {
45         this.mimeMessage = mimeMessage;
46         this.flags = flags;
47         this.internalDate = internalDate;
48         this.uid = uid;
49     }
50
51     public MimeMessage JavaDoc getMimeMessage() {
52         return mimeMessage;
53     }
54
55     public MessageFlags getFlags() {
56         return flags;
57     }
58
59     public Date JavaDoc getInternalDate() {
60         return internalDate;
61     }
62
63     public long getUid() {
64         return uid;
65     }
66
67     public ImapMessageAttributes getAttributes() throws MailboxException
68     {
69         if ( attributes == null ) {
70             attributes = new SimpleMessageAttributes();
71             setupLogger( attributes );
72             try {
73                 attributes.setAttributesFor( mimeMessage );
74             }
75             catch ( MessagingException JavaDoc e ) {
76                 throw new MailboxException( "Could not parse mime message." );
77             }
78         }
79         return attributes;
80     }
81 }
82
Popular Tags