001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *     http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    
018    package org.apache.geronimo.javamail.store.imap.connection;
019    
020    import java.util.Date;
021    
022    import javax.mail.MessagingException;
023    
024    import javax.mail.internet.InternetAddress;
025    
026    
027    public class IMAPEnvelope extends IMAPFetchDataItem {
028        // the following are various fields from the FETCH ENVELOPE structure.  These
029        // should be self-explanitory.
030        public Date date;
031        public String subject;
032        public InternetAddress[] from;
033        public InternetAddress[] sender;
034        public InternetAddress[] replyTo;
035        public InternetAddress[] to;
036        public InternetAddress[] cc;
037        public InternetAddress[] bcc;
038    
039        public String inReplyTo;
040        public String messageID;
041    
042    
043        /**
044         * Parse an IMAP FETCH ENVELOPE response into the component pieces.
045         * 
046         * @param source The tokenizer for the response we're processing.
047         */
048        public IMAPEnvelope(IMAPResponseTokenizer source) throws MessagingException {
049            super(ENVELOPE);
050    
051            // these should all be a parenthetical list 
052            source.checkLeftParen(); 
053            // the following fields are all positional
054            // The envelope date is defined in the spec as being an "nstring" value, which 
055            // means it is either a string value or NIL.  
056            date = source.readDateOrNil(); 
057            subject = source.readStringOrNil();
058            from = source.readAddressList();
059            sender = source.readAddressList();
060            replyTo = source.readAddressList();
061            to = source.readAddressList();
062            cc = source.readAddressList();
063            bcc = source.readAddressList();
064            inReplyTo = source.readStringOrNil();
065            messageID = source.readStringOrNil();
066    
067            // make sure we have a correct close on the field.
068            source.checkRightParen();
069        }
070    }