|
Class grendel.storage.BerkeleyFolder
All Packages This Package Class Hierarchy Class Search Index
Class grendel.storage.BerkeleyFolder
java.lang.Object
|
+----javax.mail.Folder
|
+----grendel.storage.FolderBase
|
+----grendel.storage.BerkeleyFolder
class BerkeleyFolder
extends grendel.storage.FolderBase
implements java.io.FilenameFilter
{
// Fields 13
private static final String[] DAYS;
private static final String[] MONTHS;
static DecimalFormat TwoDigitNumFormat;
private Object disk_lock_object;
File fFile;
boolean fLoaded;
private boolean fLoading;
private boolean flags_dirty;
MailSummaryFile mailSummaryFile;
Folder parent;
Thread statusFlagsUpdateThread;
private boolean summary_dirty;
private long verify_file_tick;
// Constructors 3
protected BerkeleyFolder(BerkeleyFolder, File);
protected BerkeleyFolder(BerkeleyFolder, String);
BerkeleyFolder(Store, File);
// Methods 43
protected String TwoDigitNum(int);
public boolean accept(File, String);
void addMessage(Message) throws IOException, MessagingException;
public void appendMessages(Message[]) throws MessagingException;
public void close(boolean) throws MessagingException;
private InternetHeaders copyMessageBytes(Message, InputStream, RandomAccessFile) throws IOException;
public boolean create(int);
public boolean delete(boolean);
long deletedMessageBytes();
void ensureLoaded();
protected void ensureSummaryFileHeaderParsed();
public boolean exists();
public Message[] expunge() throws MessagingException;
public void fetch(Message[], FetchProfile);
synchronized void flushMozillaStatus() throws IOException;
File getFile();
public Folder getFolder(String);
public String getFullName();
public int getMessageCount();
public String getName();
public Folder getParent();
public char getSeparator();
public int getType();
public int getUndeletedMessageCount();
public int getUnreadMessageCount();
public boolean hasNewMessages();
public boolean isOpen();
public Folder[] list(String);
private synchronized void loadMessages();
void lockFolderFile();
protected void makeDummyEnvelope(ByteBuf);
public void open(int);
protected synchronized Message[] realExpunge() throws IOException;
public boolean renameTo(Folder);
void setFlagsDirty(boolean, Message, long);
void setSummaryDirty(boolean);
File summaryFileName();
File tempFolderName();
void unlockFolderFile();
protected void updateSummaryFile();
protected void updateSummaryMessageCounts(long, long, int);
protected boolean verifyFileDate(boolean);
synchronized void writeSummaryFile() throws IOException;
}
Fields
File fFile
Folder parent
boolean fLoaded
private boolean fLoading
private boolean summary_dirty
private boolean flags_dirty
MailSummaryFile mailSummaryFile
Thread statusFlagsUpdateThread
private long verify_file_tick
private Object disk_lock_object
private static final String[] MONTHS
private static final String[] DAYS
static DecimalFormat TwoDigitNumFormat
Constructors
BerkeleyFolder(Store s,
File f)
protected BerkeleyFolder(BerkeleyFolder parent,
String name)
protected BerkeleyFolder(BerkeleyFolder parent,
File f)
Methods
public char getSeparator()
- Overrides:
- getSeparator in class Folder
public int getType()
- Overrides:
- getType in class Folder
File getFile()
Returns the file name associated with this folder.
public String getName()
- Overrides:
- getName in class Folder
public String getFullName()
- Overrides:
- getFullName in class Folder
public Folder getParent()
- Overrides:
- getParent in class Folder
public boolean accept(File f,
String name)
- Implements:
- accept in interface FilenameFilter
public Folder[] list(String pattern)
- Overrides:
- list in class Folder
public Folder getFolder(String subfolder)
- Overrides:
- getFolder in class Folder
public boolean create(int type)
- Overrides:
- create in class Folder
public boolean exists()
- Overrides:
- exists in class Folder
public boolean hasNewMessages()
- Overrides:
- hasNewMessages in class Folder
public int getMessageCount()
Returns the total number of messages in the folder, or -1 if unknown.
This includes deleted and unread messages.
- Overrides:
- getMessageCount in class FolderBase
public int getUndeletedMessageCount()
Returns the number of non-deleted messages in the folder, or -1 if
unknown. This includes unread messages.
public int getUnreadMessageCount()
Returns the number of unread messages in the folder, or -1 if unknown.
This does not include unread messages that are also deleted.
- Overrides:
- getUnreadMessageCount in class Folder
long deletedMessageBytes()
Returns the number of bytes consumed by deleted but not expunged
messages in the folder, or -1 if unknown.
void ensureLoaded()
If the messages are not known, parse the underlying files.
If the folder file has changed on disk since it was parsed,
re-parse it (replacing the existing message objects with new
ones.)
- Overrides:
- ensureLoaded in class FolderBase
private synchronized void loadMessages()
void setSummaryDirty(boolean summary_dirty)
Assert whether the folder's summary file should be regenerated.
void setFlagsDirty(boolean flags_dirty,
Message message,
long old_flags)
Assert whether any messages have the FLAGS_DIRTY bit set in them.
A child message should call this on its parent when any persistent
flag value is changed. If a non-null message is provided, and
flags_dirty is true, then notify any observers that this message
has changed.
| Parameter | Description |
| flags_dirty | Whether the flags should currently be considered
to be dirty. |
| message | If flags_dirty, the Message (BerkeleyMessage) that
has become dirty. |
| old_flags | If message is non-null, the previous value of its
flags (Message.flags should be the new, dirty value.) |
protected void updateSummaryMessageCounts(long old_flags,
long new_flags,
int msglen)
If the deleted-ness or read-ness of a message has changed, flush
the new counts down into the summary object.
protected void ensureSummaryFileHeaderParsed()
protected boolean verifyFileDate(boolean force)
Returns false if the disk file has changed unexpectedly.
| Parameter | Description |
| force | If true, guarentee that the disk will be checked, and
the returned value will be accurate. If false, the
disk will not be checked more frequently than once
a second, so true might be returned without verification.
That is, if `force' is false, and this method returns
true, the disk might or might not be in sync. However,
regardless of the value of `force', if false is returned,
the disk is definitely out of sync. |
protected void updateSummaryFile()
Call this to inform the summary file module that the folder file
has just been modified. (The code managing the summary file may wish
to act on this information in some way. With our current summary file
format, failing to so notice it will cause the folder to be re-parsed
the next time, since we won't be able to tell the difference between
some *other* program modifying the file instead of us.)
Call this with the folder file still locked, to avoid a potential
race.
See Also:
MailSummaryFile, MailSummaryFileGrendel
File summaryFileName()
Returns the name of the mail summary file used for this folder.
This name is OS-dependent; it is assumed that the data within the
file will contain versioning information.
On all systems, the summary file resides in the same directory
as the folder file.
On Unix, the summary file for FOO would be
.FOO.summary (note leading dot.)
On Windows and Mac, the summary file for FOO.MBX would be
FOO.SNM.
File tempFolderName()
Returns the name of a non-existent file that can be used as a temporary
file for this folder. This name is OS-dependent.
On all systems, the summary file resides in the same directory
as the folder file, and has the same "base" name.
On Unix, the summary file for FOO would be
.FOO.ns_tmp (note leading dot.)
On Windows and Mac, the summary file for FOO.MBX would be
FOO.TMP.
synchronized void writeSummaryFile() throws IOException
Write a summary file for this folder.
See Also:
MailSummaryFile, MailSummaryFileGrendel
synchronized void flushMozillaStatus() throws IOException
This causes the X-Mozilla-Status headers in the folder file itself
to be updated. (Not to be confused with the summary file: this
modifies the folder.) If a changed message's bits in the
file include an X-Mozilla-Status header, it will be overwritten
(random-access.) If the header is not present, the message will be
unchanged (and in that situation, the flags will only live in the
summary file, not the folder itself; and if the summary file gets
blown away, the flags will be lost. That's why we try to have an
X-Mozilla-Status header on every message.)
public void appendMessages(Message[] msgs) throws MessagingException
- Overrides:
- appendMessages in class Folder
void addMessage(Message m) throws IOException, MessagingException
Add a message to the end of this folder.
The disk file will be updated.
public void fetch(Message[] msgs,
FetchProfile fp)
- Overrides:
- fetch in class Folder
public Message[] expunge() throws MessagingException
Remove all messages that are marked as deleted from the folder's file.
This is done by writing a new file, then renaming it.
- Overrides:
- expunge in class Folder
protected synchronized Message[] realExpunge() throws IOException
private InternetHeaders copyMessageBytes(Message m,
InputStream in,
RandomAccessFile out) throws IOException
void lockFolderFile()
On those systems which support locking of disk files, this causes
a lock to be acquired on the file associated with this folder.
It is imperative that a balanced unlockFolderFile() call be made:
be sure to only use this within try/finally.
void unlockFolderFile()
Releases the lock obtained by lockFolderFile().
protected String TwoDigitNum(int num)
protected void makeDummyEnvelope(ByteBuf buf)
public boolean delete(boolean value)
- Overrides:
- delete in class Folder
public boolean renameTo(Folder f)
- Overrides:
- renameTo in class Folder
public void open(int mode)
- Overrides:
- open in class Folder
public void close(boolean doExpunge) throws MessagingException
- Overrides:
- close in class Folder
public boolean isOpen()
- Overrides:
- isOpen in class Folder
All Packages This Package Class Hierarchy Class Search Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.4
|