1 21 22 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 42 43 public class DefaultFolder extends IMAPFolder { 44 45 protected DefaultFolder(IMAPStore store) { 46 super("", UNKNOWN_SEPARATOR , store); 47 exists = true; type = HOLDS_FOLDERS; } 50 51 public String getName() { 52 return fullName; 53 } 54 55 public Folder getParent() { 56 return null; 57 } 58 59 public Folder[] list(final String pattern) throws MessagingException { 60 ListInfo[] li = null; 61 62 li = (ListInfo[])doCommand(new ProtocolCommand() { 63 public Object 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 pattern) 78 throws MessagingException { 79 ListInfo[] li = null; 80 81 li = (ListInfo[])doCommand(new ProtocolCommand() { 82 public Object 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 return false; 99 } 100 101 public Folder getFolder(String name) throws MessagingException { 102 return new IMAPFolder(name, UNKNOWN_SEPARATOR, (IMAPStore)store); 103 } 104 105 public boolean delete(boolean recurse) throws MessagingException { 106 throw new MethodNotSupportedException("Cannot delete Default Folder"); 108 } 109 110 public boolean renameTo(Folder f) throws MessagingException { 111 throw new MethodNotSupportedException("Cannot rename Default Folder"); 113 } 114 115 public void appendMessages(Message[] msgs) throws MessagingException { 116 throw new MethodNotSupportedException("Cannot append to Default Folder"); 118 } 119 120 public Message[] expunge() throws MessagingException { 121 throw new MethodNotSupportedException("Cannot expunge Default Folder"); 123 } 124 } 125 | Popular Tags |