|
||||||||||
| 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.MaildirFolderData
public class MaildirFolderData
Folder data actually represents the model of the maildir folder. This class handles all model operations - all operations that are low level and deal with files and directories.
This folder data serves as central repository for messages over a directory. Each directory will have only one folder data for store. That is maintained in store itself
Messages that are present in folder data are later wrapped inside of folder. Pair of (message, file) is kept in folder data's cache. Cache for each directory is maintained as long as there are opened folders over that directory. After that time it is left to be collected throught weak reference. If folder over folder data is opened before reference is garbage collected it is reused.
| Nested Class Summary | |
|---|---|
protected static class |
MaildirFolderData.Data
Folders data class. |
| Field Summary | |
|---|---|
protected File |
base
Directory folder data is for |
protected String |
cachedFullName
Cached folder's full name |
protected String |
cachedName
Cached folder's name |
protected Reference<MaildirFolderData.Data> |
closedRef
Weak reference to data when there are no open folders |
protected File |
cur
Cur subdirectory |
protected MaildirFolderData.Data |
data
Folder's data |
protected int |
delay
Amount of time between two accesses. |
protected int |
delayFactor
Delay factor - amount of time needed for reading directory vs delay. |
protected long |
lastAccess
Last time folder data was accessed or 0 if no open folders |
static String |
NO_SUBFOLDERS_FILENAME
This constant defines a filename of a zero length flag file that denotes no subfolders are suppose to be created for this folder |
protected File |
nw
New subdirectory |
protected int |
openCount
Count of open folders. |
protected WeakHashMap<javax.mail.Folder,Object> |
openedFolders
List of open folders |
protected javax.mail.Flags |
permanentFlags
Permanent flags cache |
protected boolean |
rootFolder
Flag to denote is this root folder or not |
static javax.mail.Flags |
rootPermanentFlags
Permanent flags for root are user defined "\\Noselect" |
protected MaildirStore |
store
Maildir store |
protected File |
tmp
Tmp subdirectory |
protected int |
type
Type of the folder. |
| Fields inherited from class javax.mail.Folder |
|---|
HOLDS_FOLDERS, HOLDS_MESSAGES, mode, READ_ONLY, READ_WRITE |
| Constructor Summary | |
|---|---|
MaildirFolderData(MaildirStore store,
File file)
Constructor |
|
| Method Summary | |
|---|---|
protected void |
addMessages(MaildirFolder folder,
List<MaildirMessage> messages)
This method adds messages to the folder. |
protected void |
appendMessages(MaildirFolder folder,
javax.mail.Message[] messages)
Appends messages to the folder. |
void |
appendMessages(javax.mail.Message[] messages)
Appends messages to the maildir data. |
protected void |
checkDirs()
This method checks if new, cur and tmp directories exist. |
void |
close(boolean arg0)
This method is only to satisfy Folder interface. |
protected void |
close(MaildirFolder folder)
This method is called with folder that is closing. |
boolean |
create(int type)
Creates folder. |
protected MaildirMessage |
createExistingMaildirMessage(File file,
int num)
This method creates new maildir message object for existing file in folder data's directory. |
protected List<MessageBase> |
createFolderMessages()
This method creates collection structure for storing messages in the folder. |
protected MaildirMessage |
createNewMaildirMessage(javax.mail.internet.MimeMessage message,
int num)
This method creates new maildir message for folder data (not folder). |
boolean |
delete(boolean recursive)
Deletes folder. |
protected boolean |
deleteAll(File file)
Utility method that deletes all subdirectories and files from given directory. |
boolean |
exists()
Returns true if folder exists. |
javax.mail.Message[] |
expunge()
This method is only to satisfy Folder interface. |
protected List<? extends javax.mail.Message> |
expunge(MaildirFolder folder,
boolean explicit)
Expunges messages for given folder. |
protected boolean |
expungeMessage(MaildirMessage message)
Expunges one message |
protected File |
getCurDir()
Returns folder's cur directory |
javax.mail.Folder |
getFolder(String arg0)
This method is only to satisfy Folder interface. |
File |
getFolderFile()
Returns folder's directory |
protected List<MaildirMessage> |
getFolderMessages(MaildirFolder folder)
Returns folder's messages for given folder. |
String |
getFullName()
Returns folder's full name (path and name) |
long |
getLastAccessed()
Returns when this folder data is last accessd |
MaildirStore |
getMaildirStore()
Returns maildir store |
javax.mail.Message |
getMessage(int i)
This method is only to satisfy Folder interface. |
int |
getMessageCount()
Returns message count. |
String |
getName()
Returns folder's name |
protected File |
getNewDir()
Returns folder's new directory |
int |
getNewMessageCount()
Returns new message count. |
javax.mail.Folder |
getParent()
This method is only to satisfy Folder interface. |
String |
getParentFolderName()
Returns folder parent's name |
javax.mail.Flags |
getPermanentFlags()
This method is only to satisfy Folder interface. |
char |
getSeparator()
Returns "/" |
String |
getSubFolderName(String name)
Returns name for given subfolder. |
protected File |
getTmpDir()
Returns folder's tmp directory |
int |
getType()
Returns folder's type. |
boolean |
hasNewMessages()
This method is only to satisfy Folder interface. |
boolean |
isOpen()
This method is only to satisfy Folder interface. |
protected boolean |
isRootFolder()
Returns true if it is root folder |
javax.mail.Folder[] |
list(String arg0)
This method is only to satisfy Folder interface. |
String[] |
listNames(String pattern)
Lists subfolder names. |
protected void |
obtainMessages()
This method reads directory and creates messages for given folder. |
void |
open(int arg0)
This method is only to satisfy Folder interface. |
protected void |
open(MaildirFolder folder)
This method is called by folder that is being opened. |
protected void |
removeMessages(MaildirFolder folder,
Collection<? extends javax.mail.internet.MimeMessage> messages)
This method removes folder messages. |
boolean |
renameTo(javax.mail.Folder folder)
This method is only to satisfy Folder interface. |
MaildirFolderData |
renameTo(MaildirFolderData folderData)
Renames folder to given folder data |
static void |
renumerateMessages(int from,
List<? extends MessageBase> messages)
Renumerates given list of maildir message objects |
protected void |
setFolderFile(File file)
Sets folder's directory |
| Methods inherited from class javax.mail.Folder |
|---|
addConnectionListener, addFolderListener, addMessageChangedListener, addMessageCountListener, copyMessages, fetch, finalize, getDeletedMessageCount, getMessages, getMessages, getMessages, getMode, getStore, getUnreadMessageCount, getURLName, isSubscribed, list, listSubscribed, listSubscribed, notifyConnectionListeners, notifyFolderListeners, notifyFolderRenamedListeners, notifyMessageAddedListeners, notifyMessageChangedListeners, notifyMessageRemovedListeners, 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 |
|---|
public static final String NO_SUBFOLDERS_FILENAME
public static final javax.mail.Flags rootPermanentFlags
protected javax.mail.Flags permanentFlags
protected MaildirStore store
protected File base
protected boolean rootFolder
protected int type
Folder.HOLDS_FOLDERS and Folder.HOLDS_MESSAGES.
protected File tmp
protected File cur
protected File nw
protected String cachedFullName
protected String cachedName
protected long lastAccess
protected int delay
protected int delayFactor
protected WeakHashMap<javax.mail.Folder,Object> openedFolders
protected MaildirFolderData.Data data
protected Reference<MaildirFolderData.Data> closedRef
protected int openCount
| Constructor Detail |
|---|
public MaildirFolderData(MaildirStore store,
File file)
store - storefile - directory| Method Detail |
|---|
public MaildirStore getMaildirStore()
public File getFolderFile()
protected void setFolderFile(File file)
file - folder's directorypublic long getLastAccessed()
protected boolean isRootFolder()
true if it is root folder
true if it is root folderprotected File getNewDir()
protected File getCurDir()
protected File getTmpDir()
public String getName()
getName in class javax.mail.Folderpublic String getFullName()
getFullName in class javax.mail.Folderpublic String getParentFolderName()
public boolean exists()
throws javax.mail.MessagingException
true if folder exists. This method checks if folder's directory exist.
exists in class javax.mail.Foldertrue if folder exists
javax.mail.MessagingException
public String[] listNames(String pattern)
throws javax.mail.MessagingException
pattern - pattern
javax.mail.MessagingExceptionpublic char getSeparator()
getSeparator in class javax.mail.Folderpublic String getSubFolderName(String name)
name - name of subfolder
public boolean create(int type)
throws javax.mail.MessagingException
create in class javax.mail.Foldertype - See Folder.HOLDS_FOLDERS and Folder.HOLDS_MESSAGES.
true if subfolder is successfully created.
javax.mail.MessagingException - in case of a problem while creating folder.
public boolean delete(boolean recursive)
throws javax.mail.MessagingException
delete in class javax.mail.Folderrecursive - if true deletes all subfolders as well.
true if operation was successful.
javax.mail.MessagingException - in case of an error while deleting folderprotected boolean deleteAll(File file)
file - directory to be deleted
true if operation was successful.
public int getType()
throws javax.mail.MessagingException
getType in class javax.mail.FolderFolder.HOLDS_FOLDERS and Folder.HOLDS_MESSAGES.
javax.mail.MessagingException - never.
public MaildirFolderData renameTo(MaildirFolderData folderData)
throws javax.mail.MessagingException
folderData - folder data
true if folder was successfully renamed
javax.mail.MessagingException - thrown in case when there is a problem renaming folder
protected void checkDirs()
throws javax.mail.MessagingException
javax.mail.MessagingException - in case subdirectories cannot be created.
public int getMessageCount()
throws javax.mail.MessagingException
getMessageCount in class javax.mail.Folderjavax.mail.MessagingException - never
public int getNewMessageCount()
throws javax.mail.MessagingException
getNewMessageCount in class javax.mail.Folderjavax.mail.MessagingException - never
protected void open(MaildirFolder folder)
throws javax.mail.MessagingException
createExistingMaildirMessage(File, int)).
folder - folder that asked opening
javax.mail.MessagingException - thrown if an error is encountered while creating messages
javax.mail.MessagingException - thrown if an error is encountered while creating messagesprotected void close(MaildirFolder folder)
folder - folder that is closed
protected void appendMessages(MaildirFolder folder,
javax.mail.Message[] messages)
throws javax.mail.MessagingException
folder - folder that initiated appending messagesmessages - array of messages
javax.mail.MessagingException - thrown while creating new message.
public void appendMessages(javax.mail.Message[] messages)
throws javax.mail.MessagingException
appendMessages in class javax.mail.Foldermessages - messages to be appended
javax.mail.MessagingException
protected List<? extends javax.mail.Message> expunge(MaildirFolder folder,
boolean explicit)
throws javax.mail.MessagingException
folder - folderexplicit - should folder be notified of messages
javax.mail.MessagingException - thrown in javax.mail.Message.getFlags() method
public javax.mail.Message[] expunge()
throws javax.mail.MessagingException
expunge in class javax.mail.Foldernull
javax.mail.MessagingExceptionprotected List<MaildirMessage> getFolderMessages(MaildirFolder folder)
folder -
protected void obtainMessages()
throws javax.mail.MessagingException
javax.mail.MessagingException
protected void addMessages(MaildirFolder folder,
List<MaildirMessage> messages)
throws javax.mail.MessagingException
folder - folder where messages should be added without being notified. All others will be notified. If null supplied then all will be notified.messages - messages to be added
javax.mail.MessagingException
protected void removeMessages(MaildirFolder folder,
Collection<? extends javax.mail.internet.MimeMessage> messages)
throws javax.mail.MessagingException
folder - folder that initiated call. That folder will be excluded from removal
and method folder.removeMessages must be called separatelymessages - messages to be removed
javax.mail.MessagingExceptionprotected List<MessageBase> createFolderMessages()
ArrayList
protected boolean expungeMessage(MaildirMessage message)
message - message to be expunged
true if expunge succed
public static void renumerateMessages(int from,
List<? extends MessageBase> messages)
from - first number for renumeration to start withmessages - maildir message objects
protected MaildirMessage createNewMaildirMessage(javax.mail.internet.MimeMessage message,
int num)
throws IOException,
javax.mail.MessagingException
message - message whose content will be copied to new messagenum - message number
IOException
javax.mail.MessagingException
protected MaildirMessage createExistingMaildirMessage(File file,
int num)
throws IOException,
javax.mail.MessagingException
file - file message object is going to be creatednum - message number
IOException
javax.mail.MessagingException
public javax.mail.Folder getParent()
throws javax.mail.MessagingException
getParent in class javax.mail.Foldernull
javax.mail.MessagingException
public javax.mail.Folder[] list(String arg0)
throws javax.mail.MessagingException
list in class javax.mail.Folderarg0 -
null
javax.mail.MessagingException
public boolean hasNewMessages()
throws javax.mail.MessagingException
hasNewMessages in class javax.mail.FoldergetMessageCount() > 0
javax.mail.MessagingException
public javax.mail.Folder getFolder(String arg0)
throws javax.mail.MessagingException
getFolder in class javax.mail.Folderarg0 -
null
javax.mail.MessagingException
public boolean renameTo(javax.mail.Folder folder)
throws javax.mail.MessagingException
renameTo in class javax.mail.Folderfolder -
renameTo(MaildirFolderData) method.
javax.mail.MessagingException
public void open(int arg0)
throws javax.mail.MessagingException
open in class javax.mail.Folderarg0 -
javax.mail.MessagingException
public void close(boolean arg0)
throws javax.mail.MessagingException
close in class javax.mail.Folderarg0 -
javax.mail.MessagingExceptionpublic boolean isOpen()
isOpen in class javax.mail.Folder openCount > 0public javax.mail.Flags getPermanentFlags()
getPermanentFlags in class javax.mail.FolderrootPermanentFlags if root folder or permanentFlags otherwise
public javax.mail.Message getMessage(int i)
throws javax.mail.MessagingException
getMessage in class javax.mail.Folderi - index
javax.mail.MessagingException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||