001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: /*
038: * @(#)DefaultFolder.java 1.8, 07/05/04
039: */
040:
041: package com.sun.mail.pop3;
042:
043: import javax.mail.*;
044:
045: /**
046: * The POP3 DefaultFolder. Only contains the "INBOX" folder.
047: *
048: * @version 1.8, 07/05/04
049: * @author Christopher Cotton
050: */
051: public class DefaultFolder extends Folder {
052:
053: DefaultFolder(POP3Store store) {
054: super (store);
055: }
056:
057: public String getName() {
058: return "";
059: }
060:
061: public String getFullName() {
062: return "";
063: }
064:
065: public Folder getParent() {
066: return null;
067: }
068:
069: public boolean exists() {
070: return true;
071: }
072:
073: public Folder[] list(String pattern) throws MessagingException {
074: Folder[] f = { getInbox() };
075: return f;
076: }
077:
078: public char getSeparator() {
079: return '/';
080: }
081:
082: public int getType() {
083: return HOLDS_FOLDERS;
084: }
085:
086: public boolean create(int type) throws MessagingException {
087: return false;
088: }
089:
090: public boolean hasNewMessages() throws MessagingException {
091: return false;
092: }
093:
094: public Folder getFolder(String name) throws MessagingException {
095: if (!name.equalsIgnoreCase("INBOX")) {
096: throw new MessagingException("only INBOX supported");
097: } else {
098: return getInbox();
099: }
100: }
101:
102: protected Folder getInbox() throws MessagingException {
103: return getStore().getFolder("INBOX");
104: }
105:
106: public boolean delete(boolean recurse) throws MessagingException {
107: throw new MethodNotSupportedException("delete");
108: }
109:
110: public boolean renameTo(Folder f) throws MessagingException {
111: throw new MethodNotSupportedException("renameTo");
112: }
113:
114: public void open(int mode) throws MessagingException {
115: throw new MethodNotSupportedException("open");
116: }
117:
118: public void close(boolean expunge) throws MessagingException {
119: throw new MethodNotSupportedException("close");
120: }
121:
122: public boolean isOpen() {
123: return false;
124: }
125:
126: public Flags getPermanentFlags() {
127: return new Flags(); // empty flags object
128: }
129:
130: public int getMessageCount() throws MessagingException {
131: return 0;
132: }
133:
134: public Message getMessage(int msgno) throws MessagingException {
135: throw new MethodNotSupportedException("getMessage");
136: }
137:
138: public void appendMessages(Message[] msgs)
139: throws MessagingException {
140: throw new MethodNotSupportedException("Append not supported");
141: }
142:
143: public Message[] expunge() throws MessagingException {
144: throw new MethodNotSupportedException("expunge");
145: }
146: }
|