|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.mail.Message
javax.mail.internet.MimeMessage
org.abstracthorizon.mercury.maildir.util.MessageBase
org.abstracthorizon.mercury.maildir.util.LazyParsingMessage
org.abstracthorizon.mercury.maildir.MaildirMessage
public class MaildirMessage
Maildir message representation.
Messages file name is defined in the following way:
FlagUtilities
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.mail.internet.MimeMessage |
---|
javax.mail.internet.MimeMessage.RecipientType |
Field Summary | |
---|---|
protected String |
baseName
Message's base name, name without info (flags) |
static int |
CREATE_FILE_RETRIES
Number of retries when creating new file |
protected File |
file
Message's file |
protected long |
fileSize
Cached file size or -1 |
static String |
FLAGS_SEPERATOR
Flags (info) separator |
protected static String |
host
Host name cache |
protected char |
infoSeparator
Cached info separator |
protected boolean |
isNew
Flag to show is file in new subdirectory or not |
protected MaildirFolderData |
maildirFolder
Cached link to maildir folder message belongs to. |
protected static Random |
randomGenerator
Random number generator |
Fields inherited from class org.abstracthorizon.mercury.maildir.util.LazyParsingMessage |
---|
inputStream, parsed |
Fields inherited from class javax.mail.internet.MimeMessage |
---|
content, contentStream, dh, flags, headers, modified, saved |
Fields inherited from class javax.mail.Message |
---|
expunged, folder, msgnum, session |
Fields inherited from interface javax.mail.Part |
---|
ATTACHMENT, INLINE |
Constructor Summary | |
---|---|
|
MaildirMessage(MaildirFolderData folder,
File file,
int msgnum)
Constructor that creates message object from the file. |
|
MaildirMessage(MaildirFolderData folder,
File file,
int msgnum,
boolean initialise)
Constructor that creates message object from the file. |
protected |
MaildirMessage(MaildirFolderData folder,
javax.mail.internet.MimeMessage message,
int msgnum)
Constructor that takes new message and creates a file. |
Method Summary | |
---|---|
boolean |
accept(File file,
String name)
Part of FilenameFilter interface. |
static String |
baseNameFromFile(File file)
Static method that obtains base name from the given file. |
protected void |
closeFile()
Closes all SharedInputStream impementations over this file. |
int |
compareTo(MaildirMessage o)
This method compares two messages by base name. |
protected void |
createFile(String flags)
Creates new file for the (new) message. |
protected String |
createFileName(String flags)
Creates file name, a file name composed of time, milliseconds, process id and random number, host name and flags (as part of file's info). |
protected boolean |
expunge()
Expunges the message. |
String |
getBaseName()
Returns cached base name |
File |
getFile()
Returns message's file. |
long |
getFileSize()
Return's cached file's size. |
Date |
getReceivedDate()
Returns file's date or null if file doesn't exist |
protected void |
initialise()
Initialises message. |
protected void |
parse(InputStream is)
Calls super parse method |
protected void |
parseImpl()
Check if message has already been parsed. |
void |
setFile(File file)
Sets message's file. |
void |
setFlags(javax.mail.Flags flags,
boolean set)
Sets flags to the message. |
protected void |
storeMessage(javax.mail.internet.MimeMessage message)
Stores mime message to the file. |
boolean |
synchronise()
Tries to find file with same base part as this file |
Methods inherited from class org.abstracthorizon.mercury.maildir.util.MessageBase |
---|
setMessageNumber |
Methods inherited from class javax.mail.internet.MimeMessage |
---|
createMimeMessage, getFlags, isSet, setText, updateMessageID |
Methods inherited from class javax.mail.Message |
---|
getFolder, getMessageNumber, setExpunged, setFlag |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CREATE_FILE_RETRIES
protected MaildirFolderData maildirFolder
protected File file
protected String baseName
protected char infoSeparator
protected long fileSize
protected boolean isNew
public static final String FLAGS_SEPERATOR
protected static final Random randomGenerator
protected static String host
Constructor Detail |
---|
protected MaildirMessage(MaildirFolderData folder, javax.mail.internet.MimeMessage message, int msgnum) throws javax.mail.MessagingException, IOException
folder
- folder message belongs to.message
- new message this message instance will be created based uponmsgnum
- message number
javax.mail.MessagingException
IOException
public MaildirMessage(MaildirFolderData folder, File file, int msgnum, boolean initialise) throws javax.mail.MessagingException
folder
- folder this message belongs tofile
- filemsgnum
- message numberinitialise
- should message be initialised or not
javax.mail.MessagingException
public MaildirMessage(MaildirFolderData folder, File file, int msgnum) throws javax.mail.MessagingException
folder
- folder this message belongs tofile
- filemsgnum
- message number
javax.mail.MessagingException
Method Detail |
---|
protected void initialise() throws javax.mail.MessagingException
SharedInputStream
implementation, which in turn (because of lazy implementation)
just stores that input stream.
javax.mail.MessagingException
public static String baseNameFromFile(File file)
file
- file
public File getFile() throws IOException
getFile
in interface FileProvider
IOException
public void setFile(File file) throws javax.mail.MessagingException
file
- file
javax.mail.MessagingException
- if there is a problem setting flagspublic String getBaseName()
protected void closeFile()
SharedInputStream
impementations over this file.
protected String createFileName(String flags) throws javax.mail.MessagingException
flags
- flags to be applied
javax.mail.MessagingException
protected void createFile(String flags) throws javax.mail.MessagingException
flags
- flags
javax.mail.MessagingException
- if file cannot be createdprotected void storeMessage(javax.mail.internet.MimeMessage message) throws javax.mail.MessagingException
message
- message to be stored
javax.mail.MessagingException
- if file cannot be writtenpublic long getFileSize()
getFileSize
in interface FileProvider
public boolean synchronise() throws javax.mail.MessagingException
true
if it succeded
javax.mail.MessagingException
public boolean accept(File file, String name)
FilenameFilter
interface.
accept
in interface FilenameFilter
file
- directory where filter is applied onname
- file name to be checked
true
if name start's with messages basenameprotected void parse(InputStream is) throws javax.mail.MessagingException
parse
in class LazyParsingMessage
is
- input stream
javax.mail.MessagingException
protected void parseImpl() throws javax.mail.MessagingException
parseImpl
in class LazyParsingMessage
javax.mail.MessagingException
protected boolean expunge()
true
if file can be deletedpublic Date getReceivedDate() throws javax.mail.MessagingException
null
if file doesn't exist
getReceivedDate
in class javax.mail.internet.MimeMessage
javax.mail.MessagingException
public void setFlags(javax.mail.Flags flags, boolean set) throws javax.mail.MessagingException
setFlags
in class javax.mail.internet.MimeMessage
flags
- flags that are appliedset
- are flags set or removed
javax.mail.MessagingException
public int compareTo(MaildirMessage o)
compareTo
in interface Comparable<MaildirMessage>
o
- message to be compared with
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |