⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javamail-1.1-changes.txt

📁 Java mail client (get all message on mails erver)
💻 TXT
📖 第 1 页 / 共 2 页
字号:
				JavaMail 1.1		============Following is a description of the new APIs that are beingintroduced in JavaMail 1.1Please send comments and feedback to javamail@sun.com(1) MessageContext==================In some cases it is desirable for the object representing the contentof a BodyPart to know something about the "context" in which it isoperating, e.g., what other data is contained in the same Multipartobject, who sent the message containing the data, etc.  This allowsfor more interesting content types that know more about the messagecontaining them and the mail system in general.Some uses of multipart/related might require these capabilities.For instance, the handler for a text/html body part contained in amultipart/related object might need to know about the containingobject in order to find the related image data needed to display theHTML document.There is one particular case in the current implementation wherethis need arises.  (This is a bug in the current release.)  Whenconstructing a MimeMessage object for a nested message containedin another message, the DataContentHandler needs the Sessionobject in order to construct the new MimeMessage object.To solve these problems we introduce a new class, a new interface,and a number of new methods.The MessageContext class provides the basic information about the"context" in which a content object is operating:/** * The context in which a piece of Message content is contained.  A * <code>MessageContext</code> object is returned by the * <code>getMessageContext</code> method of the * <code>MessageAware</code> interface.  <code>MessageAware</code> is * typically implemented by <code>DataSources</code> to allow a * <code>DataContentHandler</code> to pass on information about the * context in which a data content object is operating. * * @see javax.mail.MessageAware * @see javax.activation.DataSource * @see javax.activation.DataContentHandler */public class MessageContext {    /**     * Create a MessageContext object describing the context of the      * given Part.     */    public MessageContext(Part part)    /**     * Return the Part that contains the content.     *     * @return	the containing Part, or null if not known     */    public Part getPart()    /**     * Return the Message that contains the content.     * Follows the parent chain up through containing Multipart     * objects until it comes to a Message object, or null.     *     * @return	the containing Message, or null if not known     */    public Message getMessage()    /**     * Return the Session we're operating in.     *     * @return	the Session, or null if not known     */    public Session getSession()}A MessageContext object can be obtained by a DataContentHandler from aDataSource that also implements the MessageAware interface:/** * An interface optionally implemented by <code>DataSources</code> to * supply information to a <code>DataContentHandler</code> about the * message context in which the data content object is operating. * * @see javax.mail.MessageContext * @see javax.activation.DataSource * @see javax.activation.DataContentHandler */public interface MessageAware {    /**     * Return the message context.     */    public MessageContext getMessageContext();}This new interface and class provides the basic information needed bythe DataContentHandler to use in constructing more "interesting" objectsrepresenting a particular type of data.To allow navigation up the chain of components contained in a Message,we add the following methods.First, on BodyPart we add:    /**     * The <code>Multipart</code> object containing this      * <code>BodyPart</code>, if known.     */    protected Multipart parent;    /**     * Return the containing <code>Multipart</code> object,     * or <code>null</code> if not known.     */    public Multipart getParent()On Multipart we add:    /**     * The <code>Part</code> containing this <code>Multipart</code>,     * if known.     */    protected Part parent;    /**     * Return the <code>Part</code> that contains this     * (cod<code>Multipart</c object, or <code>null</code> if not known.     */    public Part getParent()    /**     * Set the parent of this <code>Multipart</code> to be the specified     * <code>Part</code>.  Normally called by the <code>Message</code>     * or <code>BodyPart</code> <code>setContent(Multipart)</code>     * method. <p>     *     * <code>parent</code> may be <code>null</code> if the     * <code>Multipart</code> is being removed from its containing     * <code>Part</code>.     */    public void setParent(Part parent)To enable this new functionality we change the implementations ofMimeBodyPart, MimeMessage, and MimeMultipart to maintain the "parent"links where possible.  We also change MimePartDataSource to implementthe MessageAware interface.===================================================================(2) MessageID=============The MimeMessage class requires a getMessageID() method.The client can now fetch it as a header, but since this is a "standard"RFC822 header, we want to provide an easier access method. An added benefit is that protocols like IMAP, which provide this infoas part of the ENVELOPE structure, can implement this method much moreefficiently. /**  * Returns the value of the "Message-ID" header field. Returns  * null if this field is unavailable or its value is absent. <p>  *  * The default implementation provided here uses the  * <code>getHeader()</code> method to return the value of the  * "Message-ID" field.  *  * @return 	Message-ID  * @exception	MessagingException, if the retrieval of this field  *		causes any exception.  * @see	javax.mail.search.MessageIDTerm  */  public String getMessageID() throws MessagingException;===================================================================(3) UIDFolder=============The following methods in the UIDFolder interface have certain problems.We are proposing changes that will fix these problems. These arebinary incompatible changes, but we think these changes are necessary forthis interface to work in a useful manner. We are also not aware ofanyone that has shipped a Store Provider that implements this interface,so we are hoping that the effect of this change is minimal (non-existent).(1) Message getMessageByUID(long uid)Description:	Get the Message corresponding to the given UID. If no suchmessage exists, the java.util.NoSuchElementException is thrown.Problem:	A disconnected client can have a stash of UIDs from aprevious session. Some of these UIDs may have been expunged from theserver, but the disconnected client does not know this. It is quitereasonable (and expected) for a disconnected client to use thismethod when reconnecting - to check whether a UID is valid or not atthe server.	Since failure is an expected result here, using aRunTimeException to indicate it, seems wrong and counter-intuitive forthe client.Solution:	Our solution is to allow this method to return null to indicatethat the requested UID is not valid anymore. Thus, this method will nolonger throw the java.util.NoSuchElementException.(2)  Message[] getMessagesByUID(long start, long end)Description:	Get the Messages corresponding to the given UID range. If anyUID is invalid, the java.util.NoSuchElementException is thrown.Problem:	Similar, but worse than (1). We think that disconnected clients(or clients that prefer to use UIDs) may issue 	getMessagesByUID(1, LASTUID) to get all the Messages at the server, especially when the client doesnot know the exact UIDs for this folder. In this case, we certainlydo not want this method to fail if some id in the given range is not a valid UID; rather we want it to return all available Messages fromthe server.Solution:	Our solution is to remove the NoSuchElementException exceptionand allow this method to return Message objects in the given range.(3) Message[] getMessagesByUID(long[] uids)Description:	Get the Messages corresponding to the given UID range. If anyUID is invalid, the java.util.NoSuchElementException is thrown.Problem:	Identical to (1).	A disconnected client can have a stash of UIDs from aprevious session. Some of these UIDs may have been expunged from theserver, but the disconnected client does not know this. It is quitereasonable (and expected) for a disconnected client to use thismethod when reconnecting - to check whether a set of UIDs are validor not at the server.	Since failure can be an expected result, using aRunTimeException to indicate it, seems wrong and counter-intuitive forthe client.Solution:	Our solution is to allow this method to return null entriesto indicate that a requested UID is not valid anymore. Thus, themessage array returned by this method can have null entries for theinvalid UIDs; and this method will no longer throw the java.util.NoSuchElementException.	Note that the size of the returned Message array is the sameas the size of the request array of UIDs, and that each entry in theMessage array corresponds to the same index entry in the UID array.===================================================================(4) InternetAddress===================The InternetAddress class needs the following protected field toproperly support encoding of the "personal name".	protected String encodedPersonal; // the encoded personal nameNo other API changes are associated with this. This is a binary compatible change to JavaMail 1.0. However, there isa potential problem for any existing InternetAddress subclasses, whichcan cause them to break. This typically will affect only providers,not clients.Details:-------The InternetAddress implementation will use this field to store theencoded personal name. 	The getPersonal() method will return the protected'personal' field; if this field is null, it will check the 'encodedPersonal'field and decode its value and return it.	The toString() method will use the protected 'encodedPersonal'field to create the RFC2047 compliant address string. If this field isnull, it will check the 'personal' field, encode that if necessary anduse it.This implies that, if an InternetAddress subclass changes either the 'personal' or 'encodedPersonal' fields,  it should set the otherto null to force its recomputation. Unfortunately, this also impliesthat existing subclasses of InternetAddress that directly set the'personal' field can break in certain situations.	We feel that the risk of this happening is minimal, since wedon't expect that our users have subclassed InternetAddress. Also, thisis necessary to properly support encoded personal names, so we feel thatthis has to be done.================================================================(5) MimeCharset================A utility method to convert java charsets into MIME charsets isneeded.The JDK supports a variety of charsets. The JDK has names for thesecharsets, unfortunately they dont always match to their MIME or IANAequivalents. It is necessary in some cases, (especially for providers) to map theJDK charset names into their MIME or IANA equivalents. This method doesthat.The API:-------This is a new static method to the javax.mail.internet.MimeUtility class	/**

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -