KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > mail > pop3 > 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.7, 05/08/29
24  *
25  * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
26  */

27
28 package com.sun.mail.pop3;
29
30 import javax.mail.*;
31
32 /**
33  * The POP3 DefaultFolder. Only contains the "INBOX" folder.
34  *
35  * @version 1.7, 05/08/29
36  * @author Christopher Cotton
37  */

38 public class DefaultFolder extends Folder {
39
40     DefaultFolder(POP3Store store) {
41     super(store);
42     }
43
44     public String JavaDoc getName() {
45     return "";
46     }
47
48     public String JavaDoc getFullName() {
49     return "";
50     }
51
52     public Folder getParent() {
53     return null;
54     }
55
56     public boolean exists() {
57     return true;
58     }
59
60     public Folder[] list(String JavaDoc pattern) throws MessagingException {
61     Folder[] f = { getInbox() };
62     return f;
63     }
64
65     public char getSeparator() {
66     return '/';
67     }
68
69     public int getType() {
70     return HOLDS_FOLDERS;
71     }
72
73     public boolean create(int type) throws MessagingException {
74     return false;
75     }
76
77     public boolean hasNewMessages() throws MessagingException {
78     return false;
79     }
80
81     public Folder getFolder(String JavaDoc name) throws MessagingException {
82     if (!name.equalsIgnoreCase("INBOX")) {
83         throw new MessagingException("only INBOX supported");
84     } else {
85         return getInbox();
86     }
87     }
88
89     protected Folder getInbox() throws MessagingException {
90     return getStore().getFolder("INBOX");
91     }
92     
93
94     public boolean delete(boolean recurse) throws MessagingException {
95     throw new MethodNotSupportedException("delete");
96     }
97
98     public boolean renameTo(Folder f) throws MessagingException {
99     throw new MethodNotSupportedException("renameTo");
100     }
101
102     public void open(int mode) throws MessagingException {
103     throw new MethodNotSupportedException("open");
104     }
105
106     public void close(boolean expunge) throws MessagingException {
107     throw new MethodNotSupportedException("close");
108     }
109
110     public boolean isOpen() {
111     return false;
112     }
113
114     public Flags getPermanentFlags() {
115     return new Flags(); // empty flags object
116
}
117
118     public int getMessageCount() throws MessagingException {
119     return 0;
120     }
121
122     public Message getMessage(int msgno) throws MessagingException {
123     throw new MethodNotSupportedException("getMessage");
124     }
125
126     public void appendMessages(Message[] msgs) throws MessagingException {
127     throw new MethodNotSupportedException("Append not supported");
128     }
129
130     public Message[] expunge() throws MessagingException {
131     throw new MethodNotSupportedException("expunge");
132     }
133 }
134
Popular Tags