KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > mail > imap > IMAPNestedMessage


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21
22 /*
23  * @(#)IMAPNestedMessage.java 1.4 05/08/29
24  *
25  * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
26  */

27
28 package com.sun.mail.imap;
29
30 import java.io.*;
31 import javax.mail.*;
32 import com.sun.mail.imap.protocol.*;
33
34 /**
35  * This class implements a nested IMAP message
36  *
37  * @author John Mani
38  */

39
40 public class IMAPNestedMessage extends IMAPMessage {
41     private IMAPMessage msg; // the enclosure of this nested message
42

43     /**
44      * Package private constructor. <p>
45      *
46      * Note that nested messages have no containing folder, nor
47      * a message number.
48      */

49     IMAPNestedMessage(IMAPMessage m, BODYSTRUCTURE b, ENVELOPE e, String JavaDoc sid) {
50     super(m._getSession());
51     msg = m;
52     bs = b;
53     envelope = e;
54     sectionId = sid;
55     }
56
57     /*
58      * Get the enclosing message's Protocol object. Overrides
59      * IMAPMessage.getProtocol().
60      */

61     protected IMAPProtocol getProtocol() throws FolderClosedException {
62     return msg.getProtocol();
63     }
64
65     /*
66      * Get the enclosing message's messageCacheLock. Overrides
67      * IMAPMessage.getMessageCacheLock().
68      */

69     protected Object JavaDoc getMessageCacheLock() {
70     return msg.getMessageCacheLock();
71     }
72
73     /*
74      * Get the enclosing message's sequence number. Overrides
75      * IMAPMessage.getSequenceNumber().
76      */

77     protected int getSequenceNumber() {
78     return msg.getSequenceNumber();
79     }
80
81     /*
82      * Check whether the enclosing message is expunged. Overrides
83      * IMAPMessage.checkExpunged().
84      */

85     protected void checkExpunged() throws MessageRemovedException {
86     msg.checkExpunged();
87     }
88
89     /*
90      * Check whether the enclosing message is expunged. Overrides
91      * Message.isExpunged().
92      */

93     public boolean isExpunged() {
94     return msg.isExpunged();
95     }
96
97     /*
98      * Get the enclosing message's fetchBlockSize.
99      */

100     protected int getFetchBlockSize() {
101     return msg.getFetchBlockSize();
102     }
103
104     /*
105      * IMAPMessage uses RFC822.SIZE. We use the "size" field from
106      * our BODYSTRUCTURE.
107      */

108     public int getSize() throws MessagingException {
109     return bs.size;
110     }
111
112     /*
113      * Disallow setting flags on nested messages
114      */

115     public synchronized void setFlags(Flags flag, boolean set)
116             throws MessagingException {
117     // Cannot set FLAGS on a nested IMAP message
118
throw new MethodNotSupportedException(
119         "Cannot set flags on this nested message");
120     }
121 }
122
Popular Tags