Skip to content

Package: DefaultFolder

DefaultFolder

nameinstructionbranchcomplexitylinemethod
DefaultFolder(IMAPStore)
M: 13 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
appendMessages(Message[])
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
delete(boolean)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
expunge()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getFolder(String)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getName()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getParent()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
hasNewMessages()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
list(String)
M: 40 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
listSubscribed(String)
M: 40 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
renameTo(Folder)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * Copyright (c) 1997, 2023 Oracle and/or its affiliates. All rights reserved.
3: *
4: * This program and the accompanying materials are made available under the
5: * terms of the Eclipse Public License v. 2.0, which is available at
6: * http://www.eclipse.org/legal/epl-2.0.
7: *
8: * This Source Code may also be made available under the following Secondary
9: * Licenses when the conditions for such availability set forth in the
10: * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
11: * version 2 with the GNU Classpath Exception, which is available at
12: * https://www.gnu.org/software/classpath/license.html.
13: *
14: * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15: */
16:
17: package org.eclipse.angus.mail.imap;
18:
19: import jakarta.mail.Folder;
20: import jakarta.mail.Message;
21: import jakarta.mail.MessagingException;
22: import jakarta.mail.MethodNotSupportedException;
23: import org.eclipse.angus.mail.iap.ProtocolException;
24: import org.eclipse.angus.mail.imap.protocol.IMAPProtocol;
25: import org.eclipse.angus.mail.imap.protocol.ListInfo;
26:
27: /**
28: * The default IMAP folder (root of the naming hierarchy).
29: *
30: * @author John Mani
31: */
32:
33: public class DefaultFolder extends IMAPFolder {
34:
35: protected DefaultFolder(IMAPStore store) {
36:         super("", UNKNOWN_SEPARATOR, store, null);
37:         exists = true; // of course
38:         type = HOLDS_FOLDERS; // obviously
39: }
40:
41: @Override
42: public synchronized String getName() {
43:         return fullName;
44: }
45:
46: @Override
47: public Folder getParent() {
48:         return null;
49: }
50:
51: @Override
52: public synchronized Folder[] list(final String pattern)
53:                                 throws MessagingException {
54:         ListInfo[] li = null;
55:
56:         li = (ListInfo[])doCommand(new ProtocolCommand() {
57:          @Override
58:          public Object doCommand(IMAPProtocol p) throws ProtocolException {
59:                 return p.list("", pattern);
60:          }
61:         });
62:
63:•        if (li == null)
64:          return new Folder[0];
65:
66:         IMAPFolder[] folders = new IMAPFolder[li.length];
67:•        for (int i = 0; i < folders.length; i++)
68:          folders[i] = ((IMAPStore)store).newIMAPFolder(li[i]);
69:         return folders;
70: }
71:
72: @Override
73: public synchronized Folder[] listSubscribed(final String pattern)
74:                                 throws MessagingException {
75:         ListInfo[] li = null;
76:
77:         li = (ListInfo[])doCommand(new ProtocolCommand() {
78:          @Override
79:          public Object doCommand(IMAPProtocol p) throws ProtocolException {
80:                 return p.lsub("", pattern);
81:          }
82:         });
83:
84:•        if (li == null)
85:          return new Folder[0];
86:
87:         IMAPFolder[] folders = new IMAPFolder[li.length];
88:•        for (int i = 0; i < folders.length; i++)
89:          folders[i] = ((IMAPStore)store).newIMAPFolder(li[i]);
90:         return folders;
91: }
92:
93: @Override
94: public boolean hasNewMessages() throws MessagingException {
95:         // Not applicable on DefaultFolder
96:         return false;
97: }
98:
99: @Override
100: public Folder getFolder(String name) throws MessagingException {
101:         return ((IMAPStore)store).newIMAPFolder(name, UNKNOWN_SEPARATOR);
102: }
103:
104: @Override
105: public boolean delete(boolean recurse) throws MessagingException {
106:         // Not applicable on DefaultFolder
107:         throw new MethodNotSupportedException("Cannot delete Default Folder");
108: }
109:
110: @Override
111: public boolean renameTo(Folder f) throws MessagingException {
112:         // Not applicable on DefaultFolder
113:         throw new MethodNotSupportedException("Cannot rename Default Folder");
114: }
115:
116: @Override
117: public void appendMessages(Message[] msgs) throws MessagingException {
118:         // Not applicable on DefaultFolder
119:         throw new MethodNotSupportedException("Cannot append to Default Folder");
120: }
121:
122: @Override
123: public Message[] expunge() throws MessagingException {
124:         // Not applicable on DefaultFolder
125:         throw new MethodNotSupportedException("Cannot expunge Default Folder");
126: }
127: }