Top Description Fields Constructors Methods
com.sun.mail.imap

public Class MessageCache

extends Object
Class Inheritance
Imports
java.io.PrintStream, java.util.*, java.util.logging.Level, javax.mail.*, com.sun.mail.util.PropUtil, .MailLogger

A cache of IMAPMessage objects along with the mapping from message number to IMAP sequence number. All operations on this object are protected by the messageCacheLock in IMAPFolder.

Field Summary

Modifier and TypeField and Description
private IMAPFolder
folder

The folder these messages belong to.

private MailLogger
private IMAPMessage[]
private int[]
private int
private static final int
SLOP

Grow the array by at least this much, to avoid constantly reallocating the array.

Constructor Summary

AccessConstructor and Description
pack-priv
MessageCache(IMAPFolder folder, IMAPStore store, int size)

Construct a new message cache of the indicated size.

pack-priv
MessageCache(int size, boolean debug)

Constructor for debugging and testing.

Method Summary

Modifier and TypeMethod and Description
public void
addMessages(int
the number of messges
count
,
int
sequence number of first message
newSeqNum
)

Add count messages to the cache.

private void
ensureCapacity(int newsize, int newSeqNum)

public void
expungeMessage(int
the sequence number of the message to expunge
seqnum
)

Expunge the message with the given sequence number.

public IMAPMessage

Returns:

the message
getMessage
(int
the message number
msgnum
)

Get the message object for the indicated message number.

public IMAPMessage

Returns:

the message
getMessageBySeqnum
(int
the sequence number of the message
seqnum
)

Get the message object for the indicated sequence number.

private int
msgnumOf(int seqnum)

Return the message number for the given sequence number.

public IMAPMessage[]

Returns:

the removed messages
removeExpungedMessages
()

Remove all the expunged messages from the array, returning a list of removed message objects.

public IMAPMessage[]

Returns:

the removed messages
removeExpungedMessages
(Message[]
the messages
msgs
)

Remove expunged messages in msgs from the array, returning a list of removed message objects.

public int

Returns:

the sequence number
seqnumOf
(int
the message number
msgnum
)

Return the sequence number for the given message number.

private void
shrink(int newend, int oldend)

Shrink the messages and seqnums arrays.

public int

Returns:

the size of the cache
size
()

Size of cache.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

folderback to summary
private IMAPFolder folder

The folder these messages belong to.

loggerback to summary
private MailLogger logger
messagesback to summary
private IMAPMessage[] messages
seqnumsback to summary
private int[] seqnums
sizeback to summary
private int size
SLOPback to summary
private static final int SLOP

Grow the array by at least this much, to avoid constantly reallocating the array.

Constructor Detail

MessageCacheback to summary
pack-priv MessageCache(IMAPFolder folder, IMAPStore store, int size)

Construct a new message cache of the indicated size.

MessageCacheback to summary
pack-priv MessageCache(int size, boolean debug)

Constructor for debugging and testing.

Method Detail

addMessagesback to summary
public void addMessages(int count, int newSeqNum)

Add count messages to the cache. newSeqNum is the sequence number of the first message added.

Parameters
count:int

the number of messges

newSeqNum:int

sequence number of first message

ensureCapacityback to summary
private void ensureCapacity(int newsize, int newSeqNum)
expungeMessageback to summary
public void expungeMessage(int seqnum)

Expunge the message with the given sequence number.

Parameters
seqnum:int

the sequence number of the message to expunge

getMessageback to summary
public IMAPMessage getMessage(int msgnum)

Get the message object for the indicated message number. If the message object hasn't been created, create it.

Parameters
msgnum:int

the message number

Returns:IMAPMessage

the message

getMessageBySeqnumback to summary
public IMAPMessage getMessageBySeqnum(int seqnum)

Get the message object for the indicated sequence number. If the message object hasn't been created, create it. Return null if there's no message with that sequence number.

Parameters
seqnum:int

the sequence number of the message

Returns:IMAPMessage

the message

msgnumOfback to summary
private int msgnumOf(int seqnum)

Return the message number for the given sequence number.

removeExpungedMessagesback to summary
public IMAPMessage[] removeExpungedMessages()

Remove all the expunged messages from the array, returning a list of removed message objects.

Returns:IMAPMessage[]

the removed messages

removeExpungedMessagesback to summary
public IMAPMessage[] removeExpungedMessages(Message[] msgs)

Remove expunged messages in msgs from the array, returning a list of removed message objects. All messages in msgs must be IMAPMessage objects from this folder.

Parameters
msgs:Message[]

the messages

Returns:IMAPMessage[]

the removed messages

seqnumOfback to summary
public int seqnumOf(int msgnum)

Return the sequence number for the given message number.

Parameters
msgnum:int

the message number

Returns:int

the sequence number

shrinkback to summary
private void shrink(int newend, int oldend)

Shrink the messages and seqnums arrays. newend is one past last valid element. oldend is one past the previous last valid element.

sizeback to summary
public int size()

Size of cache.

Returns:int

the size of the cache