public class MaildirFolder extends Object
Modifier and Type | Field and Description |
---|---|
static String |
ACL_FILE |
static String |
CUR |
static String |
NEW |
static String |
TMP |
static String |
UIDLIST_FILE |
static String |
VALIDITY_FILE |
Constructor and Description |
---|
MaildirFolder(String absPath,
MailboxPath path,
MailboxPathLocker locker)
Representation of a maildir folder containing the message folders
and some special files
|
Modifier and Type | Method and Description |
---|---|
long |
appendMessage(MailboxSession session,
String name)
Appends a message to the uidlist and returns its uid.
|
MaildirMessageName |
delete(MailboxSession session,
long uid)
Retrieves the file belonging to the given uid, deletes it and updates
the uid list.
|
boolean |
exists()
Tests whether the directory belonging to this
MaildirFolder exists |
MailboxACL |
getACL(MailboxSession session) |
File |
getCurFolder()
Returns the ./cur folder of this Maildir folder.
|
long |
getHighestModSeq() |
long |
getLastUid(MailboxSession session)
Returns the last uid used in this mailbox
|
MaildirMessageName |
getMessageNameByUid(MailboxSession session,
Long uid)
Searches the uid list for a certain uid and returns the according
MaildirMessageName |
File |
getNewFolder()
Returns the ./new folder of this Maildir folder.
|
SortedMap<Long,MaildirMessageName> |
getRecentMessages(MailboxSession session)
Creates a map of recent messages.
|
File |
getRootFile()
Returns the
File of this Maildir folder. |
File |
getTmpFolder()
Returns the ./tmp folder of this Maildir folder.
|
SortedMap<Long,MaildirMessageName> |
getUidMap(MailboxSession session,
FilenameFilter filter,
int limit)
Reads all uids from the uid list file which match the given filter
and returns as many of them as a sorted map as the limit specifies.
|
SortedMap<Long,MaildirMessageName> |
getUidMap(MailboxSession session,
FilenameFilter filter,
long from,
long to) |
SortedMap<Long,MaildirMessageName> |
getUidMap(MailboxSession session,
long from,
long to)
Reads all uids between the two boundaries from the folder and returns them as
a sorted map together with their corresponding
MaildirMessageName s. |
long |
getUidValidity()
Returns the uidValidity of this mailbox
|
void |
setACL(MailboxSession session,
MailboxACL acl) |
void |
setUidValidity(long uidValidity)
Sets the uidValidity for this mailbox and writes it to the file system
|
static String |
stripMetaFromName(String fileName)
Takes the name of a message file and returns only the base name.
|
String |
toString()
The absolute path of this folder.
|
void |
update(MailboxSession session,
long uid,
String messageName)
Updates an entry in the uid list.
|
public static final String VALIDITY_FILE
public static final String UIDLIST_FILE
public static final String ACL_FILE
public static final String CUR
public static final String NEW
public static final String TMP
public MaildirFolder(String absPath, MailboxPath path, MailboxPathLocker locker)
absPath
- The absolute path of the mailbox folderpublic File getRootFile()
File
of this Maildir folder.public boolean exists()
MaildirFolder
existsMaildirFolder
exists ; false otherwisepublic File getCurFolder()
./cur
folderpublic File getNewFolder()
./new
folderpublic File getTmpFolder()
./tmp
folderpublic long getLastUid(MailboxSession session) throws MailboxException
session
- MailboxException
public long getHighestModSeq() throws IOException
IOException
public long getUidValidity() throws IOException
IOException
public void setUidValidity(long uidValidity) throws IOException
uidValidity
- IOException
public MaildirMessageName getMessageNameByUid(MailboxSession session, Long uid) throws MailboxException
MaildirMessageName
session
- uid
- The uid to search forMaildirMessageName
that belongs to the uidIOException
- If the uidlist file cannot be found or readMailboxException
public SortedMap<Long,MaildirMessageName> getUidMap(MailboxSession session, long from, long to) throws MailboxException
MaildirMessageName
s.session
- from
- The lower uid limitto
- The upper uid limit. -1
disables the upper limitMap
whith all uids in the given range and associated MaildirMessageName
sMailboxException
- if there is a problem with the uid list filepublic SortedMap<Long,MaildirMessageName> getUidMap(MailboxSession session, FilenameFilter filter, long from, long to) throws MailboxException
MailboxException
public SortedMap<Long,MaildirMessageName> getUidMap(MailboxSession session, FilenameFilter filter, int limit) throws MailboxException
session
- filter
- The file names of all returned items match the filter.
The dir argument to FilenameFilter
.accept(dir, name) will always be null.limit
- The number of items; a limit smaller then 1 disables the limitMap
with all uids and associated MaildirMessageName
sMailboxException
- if there is a problem with the uid list filepublic SortedMap<Long,MaildirMessageName> getRecentMessages(MailboxSession session) throws MailboxException
session
- Map
with all uids and associated MaildirMessageName
s of recent messagesMailboxException
- If there is a problem with the uid list filepublic static String stripMetaFromName(String fileName)
fileName
- The name of the message filepublic long appendMessage(MailboxSession session, String name) throws MailboxException
session
- name
- The name of the message's fileIOException
MailboxException
public void update(MailboxSession session, long uid, String messageName) throws MailboxException
session
- uid
- messageName
- MailboxException
public MaildirMessageName delete(MailboxSession session, long uid) throws MailboxException
uid
- The uid of the message to deleteMaildirMessageName
of the deleted messageMailboxException
- If the file cannot be deleted of there is a problem with the uid listpublic String toString()
public MailboxACL getACL(MailboxSession session) throws MailboxException
MailboxException
public void setACL(MailboxSession session, MailboxACL acl) throws MailboxException
MailboxException
Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.