Expunge 导致 Message 对象在被删除的消息之后重新编号
Expunge causes the renumbering of Message objects subsequent to the expunged messages
来自 javamail MailFolder class doc 我读到这个:
Note that a Message's message number can change within a session if
the containing Folder is expunged using the expunge method. Clients
that use message numbers as references to messages should be aware of
this and should be prepared to deal with situation (probably by
flushing out existing message number references and reloading them).
Because of this complexity, it is better for clients to use Message
objects as references to messages, rather than message numbers.
Expunged Message objects still have to be pruned, but other Message
objects in that folder are not affected by the expunge.
我想知道如果 Message 对象发生变化,我如何使用 Message 对象作为对消息的引用,我的意思是即使我在删除之前存储 Message 对象引用,一旦 MessageCount REMOVED 事件到来,对象引用就不同于之前存的那个
我问这个是因为我在使用消息编号作为已删除消息的参考时遇到了问题...所以我正在考虑为每个 REMOVED 事件完全重建 Map of。
我不太喜欢这种方法,因为我认为它在巨大的邮箱中可能会很慢……但我看不到使用 messageNumber 的好处……
谢谢
来自 javamail MailFolder class doc 我读到这个:
Note that a Message's message number can change within a session if the containing Folder is expunged using the expunge method. Clients that use message numbers as references to messages should be aware of this and should be prepared to deal with situation (probably by flushing out existing message number references and reloading them). Because of this complexity, it is better for clients to use Message objects as references to messages, rather than message numbers. Expunged Message objects still have to be pruned, but other Message objects in that folder are not affected by the expunge.
我想知道如果 Message 对象发生变化,我如何使用 Message 对象作为对消息的引用,我的意思是即使我在删除之前存储 Message 对象引用,一旦 MessageCount REMOVED 事件到来,对象引用就不同于之前存的那个
我问这个是因为我在使用消息编号作为已删除消息的参考时遇到了问题...所以我正在考虑为每个 REMOVED 事件完全重建 Map of。 我不太喜欢这种方法,因为我认为它在巨大的邮箱中可能会很慢……但我看不到使用 messageNumber 的好处……
谢谢