|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.mail.Folder
org.abstracthorizon.mercury.maildir.MaildirFolder
public class MaildirFolder
This class implements folder from javax.mail API.
Maildir folder is a direct subdirectory in the base structure of maildir "account".
Full path of the maildir folder is contained in subdirectory's name. Components of that path
are divided with forward slash ("/"). This implementation allows that subdirectory
to start with a dot or without it. That is selectable under maildir.leadingDot
property
supplied in a session while obtaining the store. See MaildirStore
.
Note: subdirectories tmp, new and cur are used for "root" folder
and cannot be used for names. Thus if maildir.leadingDot
property contains "false
"
as a value then "tmp", "new" or "cur" are not permited file names.
On some platforms where file system do recognise different cases "New" will be still
allowed while "new" won't.
Maildir folder subdirectory contains three sub-subdirectories: tmp, new and cur
RECENT
flag set. Messages in this
implementation can have exclusively RECENT
flag set or any of other flags. When RECENT
is set all other flags are removed. RECENT
flag is implicit - if message is in this
directory then flag is set and if it is not then it is reset.RECENT
flag set. They can
have no or any flag but RECENT
. Note: user defined flags are not permitted. Implementation
doesn't prevent them but these flags will exist only while message object instance exists in memory.
Messages are files that contain RFC-822 messages as they are output with MimeMessage.writeTo
method
(or received by SMTP). Message file name is described in MaildirMessage
class.
This implementation always permits messages to be written to the folder even if folder is "root" folder. If subfolders are not allowed a zero length file of a name ".nosubfolders" will be written in subdirectory and that would prevent new subfolders of being created. Existing subfolders won't be affected. Note: this implementation does not write any other files or alters the folder's directoy in any way..
Note: if subdirectory of folder's name exist this implementation will try to create tmp, new and cur subdirectories in it. Failure to do so will lead in an exception being thrown.
Field Summary | |
---|---|
protected javax.mail.Message[] |
cacheArray
|
protected MaildirFolderData |
folderData
Folder data. |
protected HashMap<javax.mail.internet.MimeMessage,MessageWrapper> |
map
Map that maps folder data messages to folder messages. |
protected List<MessageBase> |
messages
Since folder must have messages ordered as at the time when it is opened this is the list that contains it. |
protected boolean |
opened
Flag if folder is opened or not |
protected MaildirStore |
store
Maildir store reference |
Fields inherited from class javax.mail.Folder |
---|
HOLDS_FOLDERS, HOLDS_MESSAGES, mode, READ_ONLY, READ_WRITE |
Constructor Summary | |
---|---|
protected |
MaildirFolder(MaildirStore store,
MaildirFolderData folderData)
Constructor. |
Method Summary | |
---|---|
protected MessageWrapper |
addMessage(javax.mail.internet.MimeMessage msg,
int num)
Adds message to folder's internal storage. |
protected void |
addMessages(List<MaildirMessage> messages,
boolean notify)
Adds messages to the folder. |
void |
appendMessages(javax.mail.Message[] messages)
Appends messages. |
void |
close(boolean expunge)
Closes the folder. |
boolean |
create(int type)
Creates folder. |
boolean |
delete(boolean recursive)
Removes the folder. |
boolean |
exists()
Return's true if folder exists. |
javax.mail.Message[] |
expunge()
Expunges deleted messages. |
javax.mail.Folder |
getFolder(String name)
Returns subfolder. |
protected MaildirFolderData |
getFolderData()
Returns folder data. |
List<MessageBase> |
getFolderMessages()
Returns folder messages. |
String |
getFullName()
Returns folder's full name. |
MaildirStore |
getMaildirStore()
Returns maildir store |
javax.mail.Message |
getMessage(int msgNum)
Returns message with supplied message number |
int |
getMessageCount()
Returns total number of messages for this folder |
javax.mail.Message[] |
getMessages()
Returns all messages for this folder. |
String |
getName()
Returns folder's name. |
int |
getNewMessageCount()
Returns total number of new messages for this folder |
javax.mail.Folder |
getParent()
Obtains parent folder from the store. |
javax.mail.Flags |
getPermanentFlags()
Returns permanent flags. |
char |
getSeparator()
Returns separator char |
int |
getType()
Returns the type of the folder |
protected boolean |
hasMessage(javax.mail.internet.MimeMessage msg)
Returns true if message is contained in this folder. |
boolean |
hasNewMessages()
Returns true if there are new messages in this folder |
boolean |
isOpen()
Returns true if folder is open |
javax.mail.Folder[] |
list(String pattern)
Returns array of folders by given pattern |
protected void |
notifyMessageAddedListeners(javax.mail.Message[] msgs)
Notifies if new messages are added to the folder |
protected void |
notifyMessageChangedListeners(int type,
javax.mail.Message msg)
Notifies that message is changed. |
protected void |
notifyMessageRemovedListeners(boolean removed,
javax.mail.Message[] msgs)
Notifies when messages are removed from this folder. |
void |
open(int mode)
Opens the folder. |
protected MessageWrapper |
removeMessage(javax.mail.internet.MimeMessage msg)
This medhod removes message. |
protected List<? extends javax.mail.internet.MimeMessage> |
removeMessages(Collection<? extends javax.mail.internet.MimeMessage> messages,
boolean explicit)
Removes messages from folder's representation. |
boolean |
renameTo(javax.mail.Folder folder)
Renames the folder to given folder |
protected void |
setFolderMessages(List<MessageBase> messages)
Sets folder messages. |
Methods inherited from class javax.mail.Folder |
---|
addConnectionListener, addFolderListener, addMessageChangedListener, addMessageCountListener, copyMessages, fetch, finalize, getDeletedMessageCount, getMessages, getMessages, getMode, getStore, getUnreadMessageCount, getURLName, isSubscribed, list, listSubscribed, listSubscribed, notifyConnectionListeners, notifyFolderListeners, notifyFolderRenamedListeners, removeConnectionListener, removeFolderListener, removeMessageChangedListener, removeMessageCountListener, search, search, setFlags, setFlags, setFlags, setSubscribed, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected MaildirStore store
protected boolean opened
protected MaildirFolderData folderData
MaildirFolderData
is implementing
all important operations on Maildir folders. This is first layer that should be
extended by developer.
This field is reference to instance of MaildirFolderData
or
any subclass of it.
protected List<MessageBase> messages
protected HashMap<javax.mail.internet.MimeMessage,MessageWrapper> map
protected javax.mail.Message[] cacheArray
Constructor Detail |
---|
protected MaildirFolder(MaildirStore store, MaildirFolderData folderData)
store
- maildir storefolderData
- folder dataMethod Detail |
---|
public MaildirStore getMaildirStore()
public List<MessageBase> getFolderMessages()
protected void setFolderMessages(List<MessageBase> messages)
messages
- folder messagesprotected MaildirFolderData getFolderData()
public String getName()
getName
in class javax.mail.Folder
public String getFullName()
getFullName
in class javax.mail.Folder
public javax.mail.Folder getParent() throws javax.mail.MessagingException
null
getParent
in class javax.mail.Folder
javax.mail.MessagingException
public boolean exists() throws javax.mail.MessagingException
true
if folder exists.
exists
in class javax.mail.Folder
true
if folder exists.
javax.mail.MessagingException
public javax.mail.Folder[] list(String pattern) throws javax.mail.MessagingException
list
in class javax.mail.Folder
pattern
- pattern to be used for filtering folders
javax.mail.MessagingException
public char getSeparator() throws javax.mail.MessagingException
getSeparator
in class javax.mail.Folder
javax.mail.MessagingException
public javax.mail.Folder getFolder(String name) throws javax.mail.MessagingException
getFolder
in class javax.mail.Folder
name
- name of sub folder
javax.mail.MessagingException
public boolean create(int type) throws javax.mail.MessagingException
true
if folder is successfully created. Only cases
it can return false
are when this is root folder, parent doesn't exist
and creation of it failed or creation of needed directories failed. Note: tmp,
new and cur directories must be created or an exception will be thrown.
create
in class javax.mail.Folder
type
- See Folder.HOLDS_FOLDERS
and Folder.HOLDS_MESSAGES
.
true
if folder is successfully created.
javax.mail.MessagingException
public boolean delete(boolean recursive) throws javax.mail.MessagingException
false
if it is root folder or
when deleting any files in this folder or any subfolders in case of recursive having
true
passed to it fails.
delete
in class javax.mail.Folder
recursive
- true
means that all subfolders must be removed
javax.mail.MessagingException
public int getType() throws javax.mail.MessagingException
getType
in class javax.mail.Folder
javax.mail.MessagingException
public boolean renameTo(javax.mail.Folder folder) throws javax.mail.MessagingException
renameTo
in class javax.mail.Folder
folder
- folder details to be used when renaming
true if rename was successful
- Throws:
javax.mail.MessagingException
- thrown if folder is not opened
public void open(int mode) throws javax.mail.MessagingException
open
in class javax.mail.Folder
mode
- mode folder to be opened in.
javax.mail.MessagingException
- thrown if folder is not opened or does not existpublic void close(boolean expunge) throws javax.mail.MessagingException
close
in class javax.mail.Folder
expunge
- if folder are not expunged
javax.mail.MessagingException
- if folder is not openedpublic void appendMessages(javax.mail.Message[] messages) throws javax.mail.MessagingException
appendMessages
in class javax.mail.Folder
messages
- messages to be appended
javax.mail.MessagingException
- if folder doesn't existpublic javax.mail.Message[] expunge() throws javax.mail.MessagingException
expunge
in class javax.mail.Folder
javax.mail.MessagingException
- if folder is not openedprotected void addMessages(List<MaildirMessage> messages, boolean notify) throws javax.mail.MessagingException
MaildirFolderData
messages
- messages to be addednotify
- should folder listeners be notified for new messages to be added
javax.mail.MessagingException
protected List<? extends javax.mail.internet.MimeMessage> removeMessages(Collection<? extends javax.mail.internet.MimeMessage> messages, boolean explicit) throws javax.mail.MessagingException
messages
- messages to be removedexplicit
- when notifying pass if messages removed because of explicit expunge method called
javax.mail.MessagingException
protected MessageWrapper addMessage(javax.mail.internet.MimeMessage msg, int num) throws javax.mail.MessagingException
msg
- folder data messagenum
- message number
javax.mail.MessagingException
protected MessageWrapper removeMessage(javax.mail.internet.MimeMessage msg) throws javax.mail.MessagingException
msg
- message to be removed
javax.mail.MessagingException
protected boolean hasMessage(javax.mail.internet.MimeMessage msg) throws javax.mail.MessagingException
true
if message is contained in this folder.
msg
- folder data's message or folder's message
true
if message is contained in this folder.
javax.mail.MessagingException
public boolean isOpen()
true
if folder is open
isOpen
in class javax.mail.Folder
true
if folder is openpublic javax.mail.Flags getPermanentFlags()
getPermanentFlags
in class javax.mail.Folder
protected void notifyMessageChangedListeners(int type, javax.mail.Message msg)
notifyMessageChangedListeners
in class javax.mail.Folder
type
- type of changemsg
- message that is changedprotected void notifyMessageAddedListeners(javax.mail.Message[] msgs)
notifyMessageAddedListeners
in class javax.mail.Folder
msgs
- messages that are addedprotected void notifyMessageRemovedListeners(boolean removed, javax.mail.Message[] msgs)
notifyMessageRemovedListeners
in class javax.mail.Folder
removed
- if messages are removedmsgs
- messages that are removedpublic boolean hasNewMessages() throws javax.mail.MessagingException
true
if there are new messages in this folder
hasNewMessages
in class javax.mail.Folder
true
if there are new messages in this folder
javax.mail.MessagingException
public int getMessageCount() throws javax.mail.MessagingException
getMessageCount
in class javax.mail.Folder
javax.mail.MessagingException
public int getNewMessageCount() throws javax.mail.MessagingException
getNewMessageCount
in class javax.mail.Folder
javax.mail.MessagingException
public javax.mail.Message getMessage(int msgNum) throws javax.mail.MessagingException
getMessage
in class javax.mail.Folder
msgNum
- number of message that is requested
javax.mail.MessagingException
- if folder is not openedpublic javax.mail.Message[] getMessages() throws javax.mail.MessagingException
getMessages
in class javax.mail.Folder
javax.mail.MessagingException
- if folder is not opened
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |