View Javadoc

1   /**
2    *
3    * Copyright 2003-2005 The Apache Software Foundation
4    *
5    *  Licensed under the Apache License, Version 2.0 (the "License");
6    *  you may not use this file except in compliance with the License.
7    *  You 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 implied.
14   *  See the License for the specific language governing permissions and
15   *  limitations under the License.
16   */
17  
18  package org.apache.geronimo.javamail.store.pop3.message;
19  
20  import javax.mail.Message;
21  import javax.mail.MessagingException;
22  import javax.mail.Session;
23  import javax.mail.internet.MimeMessage.RecipientType;
24  
25  import org.apache.geronimo.javamail.store.pop3.POP3Connection;
26  import org.apache.geronimo.javamail.store.pop3.POP3Folder;
27  
28  /**
29   * Fctory class to create POP3Messages based on the fetch profile
30   * 
31   * @version $Rev: 432884 $ $Date: 2006-08-19 14:53:20 -0700 (Sat, 19 Aug 2006) $
32   */
33  public final class POP3MessageFactory {
34  
35      /**
36       * Creates a basic method with no items, the items will be loaded on demand
37       * 
38       * @param folder
39       * @param session
40       * @param pop3Con
41       * @param msgNum
42       * @return
43       */
44      public static Message createMessage(POP3Folder folder, Session session, POP3Connection pop3Con, int msgNum) {
45          return new POP3Message(folder, msgNum, session, pop3Con);
46      }
47  
48      /**
49       * Created in response to <cpde>FetchProfile.ENVELOPE</code>
50       */
51      public static Message createMessageWithEvelope(POP3Message msg) throws MessagingException {
52          msg.getAllHeaders();
53          msg.getSender();
54          msg.getSentDate();
55          msg.getSubject();
56          msg.getReplyTo();
57          msg.getReceivedDate();
58          msg.getRecipients(RecipientType.TO);
59  
60          return msg;
61      }
62  
63      /**
64       * Created in response to <code>FetchProfile.CONTENT_INFO</code>
65       */
66      public static Message createMessageWithContentInfo(POP3Message msg) throws MessagingException {
67          msg.getContentType();
68          msg.getDisposition();
69          msg.getDescription();
70          msg.getSize();
71          msg.getLineCount();
72  
73          return msg;
74      }
75  
76      /**
77       * Created in response to <code>FetchProfile.FLAGS</code>
78       */
79      public static Message createMessageWithFlags(POP3Message msg) throws MessagingException {
80          msg.getFlags();
81          return msg;
82      }
83  
84  }