You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



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


fFile

   File fFile


parent

   Folder parent


fLoaded

   boolean fLoaded


fLoading

   private boolean fLoading


summary_dirty

   private boolean summary_dirty


flags_dirty

   private boolean flags_dirty


mailSummaryFile

   MailSummaryFile mailSummaryFile


statusFlagsUpdateThread

   Thread statusFlagsUpdateThread


verify_file_tick

   private long verify_file_tick


disk_lock_object

   private Object disk_lock_object


MONTHS

   private static final String[] MONTHS


DAYS

   private static final String[] DAYS


TwoDigitNumFormat

   static DecimalFormat TwoDigitNumFormat



Constructors


BerkeleyFolder

   BerkeleyFolder(Store s, 
                  File f) 


BerkeleyFolder

   protected BerkeleyFolder(BerkeleyFolder parent, 
                            String name) 


BerkeleyFolder

   protected BerkeleyFolder(BerkeleyFolder parent, 
                            File f) 



Methods


getSeparator

   public char getSeparator() 
Overrides:
getSeparator in class Folder


getType

   public int getType() 
Overrides:
getType in class Folder


getFile

   File getFile() 

Returns the file name associated with this folder.



getName

   public String getName() 
Overrides:
getName in class Folder


getFullName

   public String getFullName() 
Overrides:
getFullName in class Folder


getParent

   public Folder getParent() 
Overrides:
getParent in class Folder


accept

   public boolean accept(File f, 
                         String name) 
Implements:
accept in interface FilenameFilter


list

   public Folder[] list(String pattern) 
Overrides:
list in class Folder


getFolder

   public Folder getFolder(String subfolder) 
Overrides:
getFolder in class Folder


create

   public boolean create(int type) 
Overrides:
create in class Folder


exists

   public boolean exists() 
Overrides:
exists in class Folder


hasNewMessages

   public boolean hasNewMessages() 
Overrides:
hasNewMessages in class Folder


getMessageCount

   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


getUndeletedMessageCount

   public int getUndeletedMessageCount() 

Returns the number of non-deleted messages in the folder, or -1 if unknown. This includes unread messages.



getUnreadMessageCount

   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


deletedMessageBytes

   long deletedMessageBytes() 

Returns the number of bytes consumed by deleted but not expunged messages in the folder, or -1 if unknown.



ensureLoaded

   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


loadMessages

   private synchronized void loadMessages() 


setSummaryDirty

   void setSummaryDirty(boolean summary_dirty) 

Assert whether the folder's summary file should be regenerated.



setFlagsDirty

   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.)



updateSummaryMessageCounts

   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.



ensureSummaryFileHeaderParsed

   protected void ensureSummaryFileHeaderParsed() 


verifyFileDate

   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.



updateSummaryFile

   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



summaryFileName

   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.



tempFolderName

   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.



writeSummaryFile

   synchronized void writeSummaryFile()  throws IOException

Write a summary file for this folder.

See Also: MailSummaryFile, MailSummaryFileGrendel



flushMozillaStatus

   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.)



appendMessages

   public void appendMessages(Message[] msgs)  throws MessagingException
Overrides:
appendMessages in class Folder


addMessage

   void addMessage(Message m)  throws IOException, MessagingException

Add a message to the end of this folder. The disk file will be updated.



fetch

   public void fetch(Message[] msgs, 
                     FetchProfile fp) 
Overrides:
fetch in class Folder


expunge

   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


realExpunge

   protected synchronized Message[] realExpunge()  throws IOException


copyMessageBytes

   private InternetHeaders copyMessageBytes(Message m, 
                                            InputStream in, 
                                            RandomAccessFile out)  throws IOException


lockFolderFile

   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.



unlockFolderFile

   void unlockFolderFile() 

Releases the lock obtained by lockFolderFile().



TwoDigitNum

   protected String TwoDigitNum(int num) 


makeDummyEnvelope

   protected void makeDummyEnvelope(ByteBuf buf) 


delete

   public boolean delete(boolean value) 
Overrides:
delete in class Folder


renameTo

   public boolean renameTo(Folder f) 
Overrides:
renameTo in class Folder


open

   public void open(int mode) 
Overrides:
open in class Folder


close

   public void close(boolean doExpunge)  throws MessagingException
Overrides:
close in class Folder


isOpen

   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