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

java.lang.Object
   |
   +----grendel.storage.MailSummaryFile

abstract class  MailSummaryFile
     extends java.lang.Object
{
          // Fields 9
     protected long deleted_message_bytes;
     protected File file;
     protected long file_date;
     protected long file_size;
     protected BerkeleyFolder folder;
     protected Hashtable salvage;
     protected int total_message_count;
     protected int undeleted_message_count;
     protected int unread_message_count;

          // Constructors 1
     MailSummaryFile(BerkeleyFolder);

          // Methods 25
     protected boolean checkFolderDate(long);
     protected boolean checkFolderSize(long);
     long deletedMessageBytes();
     long folderDate();
     long folderSize();
     protected abstract void getMessageCounts();
     abstract long readSummaryFile(InputStream) throws IOException;
     protected synchronized long readUnsignedInteger(InputStream) throws IOException;
     protected synchronized long readUnsignedInteger(RandomAccessFile) throws IOException;
     protected synchronized int readUnsignedShort(InputStream) throws IOException;
     protected synchronized int readUnsignedShort(RandomAccessFile) throws IOException;
     protected void salvageMessage(BerkeleyMessage, Object);
     void salvageMessages();
     void setFolderDateAndSize(long, long);
     void setFolderMessageCounts(int, int, int, long);
     int totalMessageCount();
     int undeletedMessageCount();
     int unreadMessageCount();
     void updateSummaryFile() throws IOException;
     boolean writable();
     void writeSummaryFile() throws IOException;
     protected synchronized void writeUnsignedInteger(OutputStream, long) throws IOException;
     protected synchronized void writeUnsignedInteger(RandomAccessFile, long) throws IOException;
     protected synchronized void writeUnsignedShort(OutputStream, int) throws IOException;
     protected synchronized void writeUnsignedShort(RandomAccessFile, int) throws IOException;
}



Fields


folder

   protected BerkeleyFolder folder

The folder and associated disk file. The file might not exist.


file

   protected File file


file_date

   protected long file_date


file_size

   protected long file_size


total_message_count

   protected int total_message_count


undeleted_message_count

   protected int undeleted_message_count


unread_message_count

   protected int unread_message_count


deleted_message_bytes

   protected long deleted_message_bytes


salvage

   protected Hashtable salvage

For salvageMessages(). If the table is non-null, its keys will be MessageID objects, and the values will be opaque objects intended to be passed to salvageMessageSummary(). Subclasses are responsible for populating this table, if they are able.



Constructors


MailSummaryFile

   MailSummaryFile(BerkeleyFolder f) 



Methods


readSummaryFile

   abstract long readSummaryFile(InputStream sum)  throws IOException

Parses a summary file for the associated folder, and adds the described message objects to the folder. The given stream is assumed to have been opened, and positioned past any version-identifying header info. Returns the byte position at which parsing should resume (that is, the last byte position which the summary file summarizes.)



writable

   boolean writable() 

Whether this class knows how to write a summary file.



writeSummaryFile

   void writeSummaryFile()  throws IOException

Write a summary file for the associated folder. If a subclass provides an implementation for this method, it should also override writable().



folderDate

   long folderDate() 

Returns the date that the summary file expects to find on the folder's file. This is measured in the units of File.lastModified(). Set this expectation with setFolderDateAndSize().



folderSize

   long folderSize() 

Returns the size in bytes that the summary file expects of the folder's file. Set this expectation with setFolderDateAndSize().



totalMessageCount

   int totalMessageCount() 

Returns the total number of messages in the folder. This includes deleted and unread messages.



undeletedMessageCount

   int undeletedMessageCount() 

Returns the number of non-deleted messages in the folder. This includes unread messages.



unreadMessageCount

   int unreadMessageCount() 

Returns the number of unread messages in the folder. This does not include unread messages that are also deleted.



deletedMessageBytes

   long deletedMessageBytes() 

Returns the number of bytes consumed by deleted but not expunged messages in the folder.



getMessageCounts

   protected abstract void getMessageCounts() 

Read only enough of the file to fill in the values of total_message_count, undeleted_message_count, unread_message_count, and deleted_message_bytes.



setFolderDateAndSize

   void setFolderDateAndSize(long file_date, 
                             long file_size) 

Set the date and size of the corresponding folder-file. This date/time pair should correspond to the file at the time at which it was parsed, not the current time. The next time writeSummaryFile() is called, the new summary file will encode this date and size expectation.



setFolderMessageCounts

   void setFolderMessageCounts(int total_count, 
                               int undeleted_count, 
                               int unread_count, 
                               long deleted_bytes) 

Set the message counts (total, undeleted, and unread) of the corresponding folder-file. The next time writeSummaryFile() is called, the new summary file will include these numbers.

Parameter Description
total_count The total number of messages in the folder. This must match the number of elements returned by getMessages() at the time that writeSummaryFile() is called.
undeleted_count The total number of messages in the folder that are not marked as deleted. This also must match reality when writeSummaryFile() is called.
unread_count The total number of messages in the folder that are not marked as either read or deleted. Ditto writeSummaryFile().
deleted_bytes The total number of bytes consumed by messages that are marked as deleted. Ditto writeSummaryFile().



updateSummaryFile

   void updateSummaryFile()  throws IOException

Called when the folder's disk file has been appended to by *this* program. (As opposed to, an unexpected, unknown change by some other program.) This calls setFolderDateAndSize() with the current date and size of the folder file (as it appears on disk right now.)

If the number of messages has changed, you should have called setFolderMessageCounts() before calling this.



checkFolderDate

   protected boolean checkFolderDate(long summary_date) 

Compare the date of the folder disk file to a date (presumably) read from the summary file, and return true of they are equal.



checkFolderSize

   protected boolean checkFolderSize(long summary_size) 

Compare the size of the folder disk file to a size (presumably) read from the summary file, and return true of they are equal.



salvageMessages

   void salvageMessages() 

Call this if something has gone wrong when parsing the summary file, but after the folder file has been parsed. This might cause some additional information to be scavenged from the summary file and stored into the messages.

The idea here is that an out-of-date summary file cannot be trusted as far as byte-offsets and such goes, but if the summary file had stored some property of a message (such as whether it was deleted) then we might as well believe that, lacking any other source of information.

Note that one folder can contain multiple messages with the same ID, so this process is not totally foolproof. It is, however, better than nothing.



salvageMessage

   protected void salvageMessage(BerkeleyMessage m, 
                                 Object salvage_object) 


readUnsignedShort

   protected synchronized int readUnsignedShort(InputStream s)  throws IOException


readUnsignedInteger

   protected synchronized long readUnsignedInteger(InputStream s)  throws IOException


writeUnsignedShort

   protected synchronized void writeUnsignedShort(OutputStream s, 
                                                  int i)  throws IOException


writeUnsignedInteger

   protected synchronized void writeUnsignedInteger(OutputStream s, 
                                                    long i)  throws IOException


readUnsignedShort

   protected synchronized int readUnsignedShort(RandomAccessFile s)  throws IOException


readUnsignedInteger

   protected synchronized long readUnsignedInteger(RandomAccessFile s)  throws IOException


writeUnsignedShort

   protected synchronized void writeUnsignedShort(RandomAccessFile s, 
                                                  int i)  throws IOException


writeUnsignedInteger

   protected synchronized void writeUnsignedInteger(RandomAccessFile s, 
                                                    long i)  throws IOException


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.4