KickJava   Java API By Example, From Geeks To Geeks.

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


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  * @(#)DefaultFolder.java 1.11 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 javax.mail.*;
31 import javax.mail.internet.*;
32 import com.sun.mail.util.*;
33 import com.sun.mail.iap.*;
34 import com.sun.mail.imap.protocol.*;
35
36 /**
37  * This class
38  *
39  * @version 1.2, 97/12/08
40  * @author John Mani
41  */

42
43 public class DefaultFolder extends IMAPFolder {
44     
45     protected DefaultFolder(IMAPStore store) {
46     super("", UNKNOWN_SEPARATOR , store);
47     exists = true; // of course
48
type = HOLDS_FOLDERS; // obviously
49
}
50
51     public String JavaDoc getName() {
52     return fullName;
53     }
54
55     public Folder getParent() {
56     return null;
57     }
58
59     public Folder[] list(final String JavaDoc pattern) throws MessagingException {
60     ListInfo[] li = null;
61
62     li = (ListInfo[])doCommand(new ProtocolCommand() {
63         public Object JavaDoc doCommand(IMAPProtocol p) throws ProtocolException {
64         return p.list("", pattern);
65         }
66     });
67
68     if (li == null)
69         return new Folder[0];
70
71     IMAPFolder[] folders = new IMAPFolder[li.length];
72     for (int i = 0; i < folders.length; i++)
73         folders[i] = new IMAPFolder(li[i], (IMAPStore)store);
74     return folders;
75     }
76
77     public Folder[] listSubscribed(final String JavaDoc pattern)
78                 throws MessagingException {
79     ListInfo[] li = null;
80
81     li = (ListInfo[])doCommand(new ProtocolCommand() {
82         public Object JavaDoc doCommand(IMAPProtocol p) throws ProtocolException {
83         return p.lsub("", pattern);
84         }
85     });
86
87     if (li == null)
88         return new Folder[0];
89
90     IMAPFolder[] folders = new IMAPFolder[li.length];
91     for (int i = 0; i < folders.length; i++)
92         folders[i] = new IMAPFolder(li[i], (IMAPStore)store);
93     return folders;
94     }
95
96     public boolean hasNewMessages() throws MessagingException {
97     // Not applicable on DefaultFolder
98
return false;
99     }
100
101     public Folder getFolder(String JavaDoc name) throws MessagingException {
102     return new IMAPFolder(name, UNKNOWN_SEPARATOR, (IMAPStore)store);
103     }
104
105     public boolean delete(boolean recurse) throws MessagingException {
106     // Not applicable on DefaultFolder
107
throw new MethodNotSupportedException("Cannot delete Default Folder");
108     }
109
110     public boolean renameTo(Folder f) throws MessagingException {
111     // Not applicable on DefaultFolder
112
throw new MethodNotSupportedException("Cannot rename Default Folder");
113     }
114
115     public void appendMessages(Message[] msgs) throws MessagingException {
116     // Not applicable on DefaultFolder
117
throw new MethodNotSupportedException("Cannot append to Default Folder");
118     }
119
120     public Message[] expunge() throws MessagingException {
121     // Not applicable on DefaultFolder
122
throw new MethodNotSupportedException("Cannot expunge Default Folder");
123     }
124 }
125
Popular Tags