1 /**
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. 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.imap.connection;
19
20 import java.util.Date;
21
22 import javax.mail.MessagingException;
23
24 import javax.mail.internet.InternetAddress;
25
26
27 public class IMAPEnvelope extends IMAPFetchDataItem {
28 // the following are various fields from the FETCH ENVELOPE structure. These
29 // should be self-explanitory.
30 public Date date;
31 public String subject;
32 public InternetAddress[] from;
33 public InternetAddress[] sender;
34 public InternetAddress[] replyTo;
35 public InternetAddress[] to;
36 public InternetAddress[] cc;
37 public InternetAddress[] bcc;
38
39 public String inReplyTo;
40 public String messageID;
41
42
43 /**
44 * Parse an IMAP FETCH ENVELOPE response into the component pieces.
45 *
46 * @param source The tokenizer for the response we're processing.
47 */
48 public IMAPEnvelope(IMAPResponseTokenizer source) throws MessagingException {
49 super(ENVELOPE);
50
51 // these should all be a parenthetical list
52 source.checkLeftParen();
53 // the following fields are all positional
54 // The envelope date is defined in the spec as being an "nstring" value, which
55 // means it is either a string value or NIL.
56 date = source.readDateOrNil();
57 subject = source.readStringOrNil();
58 from = source.readAddressList();
59 sender = source.readAddressList();
60 replyTo = source.readAddressList();
61 to = source.readAddressList();
62 cc = source.readAddressList();
63 bcc = source.readAddressList();
64 inReplyTo = source.readStringOrNil();
65 messageID = source.readStringOrNil();
66
67 // make sure we have a correct close on the field.
68 source.checkRightParen();
69 }
70 }