0N/A
0N/A JavaMail 1.4
0N/A ============
0N/A
0N/A (Updated August 15, 2005)
0N/A
0N/AFollowing is a description of the new APIs that are being
0N/Aintroduced in JavaMail 1.4. The numbers in parentheses
0N/Aare bug numbers; you can find more information about the
0N/Abug reports at:
0N/A
0N/A http://bugs.sun.com/bugdatabase/index.jsp
0N/A
0N/APlease send comments and feedback to javamail@sun.com.
0N/A
0N/AMany of these changes expand JavaMail's conformance with Internet
0N/Astandards, or make JavaMail more tolerant of messages that don't
0N/Aquite conform to the standards. "Be liberal in what you receive
0N/Aand conservative in what you send."
0N/A
0N/AJavaMail 1.4 will also require at least J2SE 1.4. This allows
0N/AJavaMail to take advantage of features of more modern J2SE releases.
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A1. Add MimePart.setText(text, charset, subtype) method (6300765)
0N/A----------------------------------------------------------------
0N/A
0N/AThe setText method is a convenience method used to set the content
0N/Afor a text/plain part. With the increased use of HTML and XML in
0N/Amail messages, it would be useful to have a convenience method to
0N/Aset content of those types as well. To support this usage we add
0N/Aa new method to the MimePart interface:
0N/A
0N/A /**
0N/A * Convenience method that sets the given String as this part's
0N/A * content, with a primary MIME type of "text" and the specified
0N/A * MIME subtype. The given Unicode string will be charset-encoded
0N/A * using the specified charset. The charset is also used to set
0N/A * the "charset" parameter.
0N/A *
0N/A * @param text the text content to set
0N/A * @param charset the charset to use for the text
0N/A * @param subtype the MIME subtype to use (e.g., "html")
0N/A * @exception MessagingException if an error occurs
0N/A * @since JavaMail 1.4
0N/A */
0N/A public void setText(String text, String charset, String subtype)
0N/A throws MessagingException;
0N/A
0N/AThe MimeMessage and MimeBodyPart classes, which implement the
0N/AMimePart interface, will be updated to provide implementations
0N/Aof the new method.
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A2. Add mail.mime.encodefilename and decodefilename properties (6300768)
0N/A-----------------------------------------------------------------------
0N/A
0N/AAccording to the MIME spec (RFC 2047), filenames included in the
0N/Afilename parameter of the Content-Disposition header may not
0N/Ainclude MIME "encoded-words", and thus may contain only US-ASCII
0N/Acharacters. However, many mailers violate this spec requirement
0N/Aand use standard MIME encoding techniques to store non-ASCII
0N/Afilenames in this filename parameter.
0N/A
0N/AIf the mail.mime.encodefilename System property is set to "true".
0N/Athe MimeMessage and MimeBodyPart setFileName methods will use the
0N/AMimeUtility.encodeText method to encode the filename.
0N/A
0N/AIf the mail.mime.decodefilename System property is set to "true".
0N/Athe MimeMessage and MimeBodyPart getFileName methods will use the
0N/AMimeUtility.decodeText method to decode the filename.
0N/A
0N/ABoth of these properties default to "false".
0N/A
0N/AThe following text is added to the MimeMessage and MimeBodyPart
0N/AsetFileName methods:
0N/A
0N/A * If the <code>mail.mime.encodefilename</code> System property
0N/A * is set to true, the {@link MimeUtility#encodeText
0N/A * MimeUtility.encodeText method will be used to encode the
0N/A * filename. While such encoding is not supported by the MIME
0N/A * spec, many mailers use this technique to support non-ASCII
0N/A * characters in filenames. The default value of this property
0N/A * is false.
0N/A
0N/AThe following text is added to the MimeMessage and MimeBodyPart
0N/AgetFileName methods:
0N/A
0N/A * If the <code>mail.mime.encodefilename</code> System property
0N/A * is set to true, the {@link MimeUtility#decodeText
0N/A * MimeUtility.decodeText method will be used to decode the
0N/A * filename. While such encoding is not supported by the MIME
0N/A * spec, many mailers use this technique to support non-ASCII
0N/A * characters in filenames. The default value of this property
0N/A * is false.
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A3. Add Service.connect(user, password) (6300771)
0N/A------------------------------------------------
0N/A
0N/AThis convenience method uses the host already known to the Service
0N/A(Transport or Store). Equivalent to connect(null, user, password).
0N/A
0N/A /**
0N/A * Connect to the current host using the specified username
0N/A * and password. This method is equivalent to calling the
0N/A * <code>connect(host, user, password)</code> method with null
0N/A * for the host name.
0N/A *
0N/A * @param user the user name
0N/A * @param password this user's password
0N/A * @exception AuthenticationFailedException for authentication failures
0N/A * @exception MessagingException for other failures
0N/A * @exception IllegalStateException if the service is already connected
0N/A * @see javax.mail.event.ConnectionEvent
0N/A * @see javax.mail.Session#setPasswordAuthentication
0N/A * @see #connect(java.lang.String, java.lang.String, java.lang.String)
0N/A * @since JavaMail 1.4
0N/A */
0N/A public void connect(String user, String password) throws MessagingException
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A4. Add mail.mime.multipart.ignoremissingendboundary System property (4971381)
0N/A-----------------------------------------------------------------------------
0N/A
0N/AThe current implementation of the MimeMultipart class will
0N/Aignore a missing end boundary line; if EOF is reached when
0N/Aparsing the content before seeing an end boundary line, the
0N/Alast part of the multipart is terminated and no error is
0N/Areturned.
0N/A
0N/ASome users have requested a way to force the multipart
0N/Aparsing to more strictly enforce the MIME specification.
0N/ATo support this we we introduce a new System property:
0N/A
0N/A mail.mime.multipart.ignoremissingendboundary
0N/A
0N/AIf this property is set to "false" MimeMultipart will throw a
0N/AMessagingException when parsing a multipart that does not
0N/Ainclude the proper end boundary line.
0N/A
0N/AThis property is already supported as part of the JavaMail
0N/Aimplementation. This change makes the property a part of the
0N/Astandard API.
0N/A
0N/A * The <code>mail.mime.multipart.ignoremissingendboundary</code>
0N/A * System property may be set to <code>false</code> to cause a
0N/A * <code>MessagingException</code> to be thrown if the multipart
0N/A * data does not end with the required end boundary line. If this
0N/A * property is set to <code>true</code> or not set, missing end
0N/A * boundaries are not considered an error and the final body part
0N/A * ends at the end of the data. <p>
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A5. Add MimeMultipart.isComplete() method (6300811)
0N/A--------------------------------------------------
0N/A
0N/AAs described above, parsing of a MIME multipart may terminate
0N/Awithout an error, even though no final boundary line was seen.
0N/AThis method will return true if the final boundary line was
0N/Aseen. This will allow applications to successfully parse
0N/Amal-formed messages, while also being able to tell that they
0N/Awere mal-formed.
0N/A
0N/A /**
0N/A * Return true if the final boundary line for this
0N/A * multipart was seen. When parsing multipart content,
0N/A * this class will (by default) terminate parsing with
0N/A * no error if the end of input is reached before seeing
0N/A * the final multipart boundary line. In such a case,
0N/A * this method will return false. (If the System property
0N/A * "mail.mime.multipart.ignoremissingendboundary" is set to
0N/A * false, parsing such a message will instead throw a
0N/A * MessagingException.)
0N/A *
0N/A * @return true if the final boundary line was seen
0N/A * @since JavaMail 1.4
0N/A */
0N/A public boolean isComplete() throws MessagingException
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A6. Add mail.mime.multipart.ignoremissingboundaryparameter property (6300814)
0N/A----------------------------------------------------------------------------
0N/A
0N/AThe following property is already supported as part of the JavaMail
0N/Aimplementation. This change makes the property a part of the
0N/Astandard API.
0N/A
0N/A * The <code>mail.mime.multipart.ignoremissingboundaryparameter</code>
0N/A * System property may be set to <code>false</code> to cause a
0N/A * <code>MessagingException</code> to be thrown if the Content-Type
0N/A * of the MimeMultipart does not include a <code>boundary</code> parameter.
0N/A * If this property is set to <code>true</code> or not set, the multipart
0N/A * parsing code will look for a line that looks like a bounary line and
0N/A * use that as the boundary separating the parts.
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A7. Add MimeMultipart getPreamble and setPreamble methods (6300828)
0N/A------------------------------------------------------------------
0N/A
0N/AIn a MIME multipart message, it's possible to include text between
0N/Athe headers and the first boundary line. This text is called the
0N/Apreamble. It may include instructions for users of non-MIME
0N/Acompliant software. The getPreamble method allows access to this
0N/Atext when available. (Note that IMAP servers provide no convenient
0N/Aaccess to this text.) The setPreamble method allows an application
0N/Ato set the preamble for a message being constructed.
0N/A
0N/A /**
0N/A * Get the preamble text, if any, that appears before the
0N/A * first body part of this multipart. Some protocols,
0N/A * such as IMAP, will not allow access to the preamble text.
0N/A *
0N/A * @return the preamble text, or null if no preamble
0N/A * @since JavaMail 1.4
0N/A */
0N/A public String getPreamble() throws MessagingException
0N/A
0N/A /**
0N/A * Set the preamble text to be included before the first
0N/A * body part. Applications should generally not include
0N/A * any preamble text. In some cases it may be helpful to
0N/A * include preamble text with instructions for users of
0N/A * pre-MIME software.
0N/A *
0N/A * @param preamble the preamble text
0N/A * @since JavaMail 1.4
0N/A */
0N/A public void setPreamble(String preamble) throws MessagingException
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A8. Add MimeMessage.updateMessageID() protected method (6300831)
0N/A---------------------------------------------------------------
0N/A
0N/ASome applications want more control over the data that's used
0N/Ato create the Message-ID for a message. This method allows
0N/Aan application to provide a simple subclass of MimeMessage
0N/Athat overrides the Message-ID algorithm.
0N/A
0N/A /**
0N/A * Update the Message-ID header. This method is called
0N/A * by the <code>updateHeaders</code> and allows a subclass
0N/A * to override only the algorithm for choosing a Message-ID.
0N/A *
0N/A * @since JavaMail 1.4
0N/A */
0N/A protected void updateMessageID() throws MessagingException
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A9. Add MimeMessage.createMimeMessage() protected method (6300833)
0N/A-----------------------------------------------------------------
0N/A
0N/AThe MimeMessage.reply method creates and returns a new MimeMessage.
0N/ASubclasses of MimeMessage may need the reply method to create a new
0N/Amessage of the appropriate subclass. This method allows subclasses
0N/Ato control the class created in this case.
0N/A
0N/A /**
0N/A * Create and return a MimeMessage object. The reply method
0N/A * uses this method to create the MimeMessage object that it
0N/A * will return. Subclasses can override this method to return
0N/A * a subclass of MimeMessage. This implementation simply constructs
0N/A * and returns a MimeMessage object using the supplied Session.
0N/A *
0N/A * @param session the Session to use for the new message
0N/A * @return the new MimeMessage object
0N/A * @since JavaMail 1.4
0N/A */
0N/A protected MimeMessage createMimeMessage(Session session)
0N/A throws MessagingException
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A10. Make the "part" field of MimePartDataSource protected (6300834)
0N/A-------------------------------------------------------------------
0N/A
0N/ASubclasses of MimePartDataSource may need access to the "part"
0N/Afield in order to implement the getInputStream method. The
0N/Apart field is currently private, this change will make it protected.
0N/A
0N/A /**
0N/A * The MimePart that provides the data for this DataSource.
0N/A *
0N/A * @since JavaMail 1.4
0N/A */
0N/A protected MimePart part;
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A11. Folder.getSeparator should not require the folder to exist (6301381)
0N/A------------------------------------------------------------------------
0N/A
0N/AIMAP folders are able to determine the separator character without
0N/Aknowing whether the folder exists. Checking whether the folder
0N/Aexists in order to throw FolderNotFoundException introduces additional
0N/Aoverhead. Because other methods often need to know the separator
0N/Acharacter, this overhead can be noticable. The specification of this
0N/Amethod is changed as follows:
0N/A
0N/A /**
0N/A * Return the delimiter character that separates this Folder's pathname
0N/A * from the names of immediate subfolders. This method can be invoked
0N/A * on a closed Folder.
0N/A *
0N/A * @exception FolderNotFoundException if the implementation
0N/A * requires the folder to exist, but it does not
0N/A * @return Hierarchy separator character
0N/A */
0N/A public abstract char getSeparator() throws MessagingException;
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A12. Add PreencodedMimeBodyPart class (6301386)
0N/A----------------------------------------------
0N/A
0N/AIn some cases an application will have data that has already
0N/Abeen encoded using (for example) base64 encoding. There should
0N/Abe an easy way to attach such data to a message without the need
0N/Ato decode it and reencode it. This class provides such support.
0N/A
0N/A/**
0N/A * A MimeBodyPart that handles data that has already been encoded.
0N/A * This class is useful when constructing a message and attaching
0N/A * data that has already been encoded (for example, using base64
0N/A * encoding). The data may have been encoded by the application,
0N/A * or may have been stored in a file or database in encoded form.
0N/A * The encoding is supplied when this object is created. The data
0N/A * is attached to this object in the usual fashion, by using the
0N/A * <code>setText</code>, <code>setContent</code>, or
0N/A * <code>setDataHandler</code> methods.
0N/A *
0N/A * @since JavaMail 1.4
0N/A */
0N/A
0N/Apublic class PreencodedMimeBodyPart extends MimeBodyPart {
0N/A /**
0N/A * Create a PreencodedMimeBodyPart that assumes the data is
0N/A * encoded using the specified encoding. The encoding must
0N/A * be a MIME supported Content-Transfer-Encoding.
0N/A */
0N/A public PreencodedMimeBodyPart(String encoding)
0N/A}
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A13. Add MimeBodyPart attachFile and saveFile methods (6301390)
0N/A--------------------------------------------------------------
0N/A
0N/AIt's very common for applications to create messages with files
0N/Aas attachments, and to receive attachments and save them in files.
0N/ATo simplify this usable, we add several convenience methods to the
0N/AMimeBodyPart class:
0N/A
0N/A /**
0N/A * Use the specified file to provide the data for this part.
0N/A * The simple file name is used as the file name for this
0N/A * part and the data in the file is used as the data for this
0N/A * part. The encoding will be chosen appropriately for the
0N/A * file data.
0N/A *
0N/A * @param file the File object to attach
0N/A * @exception IOException errors related to accessing the file
0N/A * @exception MessagingException message related errors
0N/A * @since JavaMail 1.4
0N/A */
0N/A public void attachFile(File file) throws IOException, MessagingException
0N/A
0N/A /**
0N/A * Use the specified file to provide the data for this part.
0N/A * The simple file name is used as the file name for this
0N/A * part and the data in the file is used as the data for this
0N/A * part. The encoding will be chosen appropriately for the
0N/A * file data.
0N/A *
0N/A * @param file the name of the file to attach
0N/A * @exception IOException errors related to accessing the file
0N/A * @exception MessagingException message related errors
0N/A * @since JavaMail 1.4
0N/A */
0N/A public void attachFile(String file) throws IOException, MessagingException
0N/A
0N/A /**
0N/A * Save the contents of this part in the specified file. The content
0N/A * is decoded and saved, without any of the MIME headers.
0N/A *
0N/A * @param file the File object to write to
0N/A * @exception IOException errors related to accessing the file
0N/A * @exception MessagingException message related errors
0N/A * @since JavaMail 1.4
0N/A */
0N/A public void saveFile(File file) throws IOException, MessagingException
0N/A
0N/A /**
0N/A * Save the contents of this part in the specified file. The content
0N/A * is decoded and saved, without any of the MIME headers.
0N/A *
0N/A * @param file the name of the file to write to
0N/A * @exception IOException errors related to accessing the file
0N/A * @exception MessagingException message related errors
0N/A * @since JavaMail 1.4
0N/A */
0N/A public void saveFile(String file) throws IOException, MessagingException
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A14. Add MimeUtility fold and unfold methods (6302118)
0N/A--------------------------------------------------------------
0N/A
0N/AWhen dealing with long header lines, it's often necessary to fold
0N/Athe lines to avoid exceeding line length limitations. When retrieving
0N/Athe data from such headers, the folding needs to be undone. The JavaMail
0N/Aimplementation includes private fold and unfold methods for this purpose.
0N/AThese methods should be made public.
0N/A
0N/A /**
0N/A * Fold a string at linear whitespace so that each line is no longer
0N/A * than 76 characters, if possible. If there are more than 76
0N/A * non-whitespace characters consecutively, the string is folded at
0N/A * the first whitespace after that sequence. The parameter
0N/A * <code>used</code> indicates how many characters have been used in
0N/A * the current line; it is usually the length of the header name. <p>
0N/A *
0N/A * Note that line breaks in the string aren't escaped; they probably
0N/A * should be.
0N/A *
0N/A * @param used characters used in line so far
0N/A * @param s the string to fold
0N/A * @return the folded string
0N/A */
0N/A public static String fold(int used, String s)
0N/A
0N/A /**
0N/A * Unfold a folded header. Any line breaks that aren't escaped and
0N/A * are followed by whitespace are removed.
0N/A *
0N/A * @param s the string to unfold
0N/A * @return the unfolded string
0N/A */
0N/A public static String unfold(String s)
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A15. Allow more control over headers in InternetHeaders object (6302832)
0N/A-----------------------------------------------------------------------
0N/A
0N/ASome applications, such as mail server applications, need more control
0N/Aover the order of headers in the InternetHeaders class. To support
0N/Asuch usage, we allow such applications to subclass InternetHeaders
0N/Aand access the List of headers directly. InternetHeaders exposes a
0N/Aprotected field:
0N/A
0N/A protected List headers;
0N/A
0N/AThe elements of the list are objects of a new protected final class
0N/AInternetHeaders.InternetHeader that extends the javax.mail.Header class.
0N/ATo allow the InternetHeader class to make use of the Header class, we
0N/Amake the following fields of Header protected:
0N/A
0N/A /**
0N/A * The name of the header.
0N/A *
0N/A * @since JavaMail 1.4
0N/A */
0N/A protected String name;
0N/A
0N/A /**
0N/A * The value of the header.
0N/A *
0N/A * @since JavaMail 1.4
0N/A */
0N/A protected String value;
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A16. Allow applications to dynamically register new protocol providers (6302835)
0N/A-----------------------------------------------------------------------
0N/A
0N/ASome applications would like to register new protocol providers at runtime
0N/Arather than depending on the JavaMail configuration files and resources.
0N/ATo support such usage we make the constructor for the Provider class
0N/Apublic:
0N/A
0N/A /**
0N/A * Create a new provider of the specified type for the specified
0N/A * protocol. The specified class implements the provider.
0N/A *
0N/A * @param type Type.STORE or Type.TRANSPORT
0N/A * @param protocol valid protocol for the type
0N/A * @param classname class name that implements this protocol
0N/A * @param vendor optional string identifying the vendor (may be null)
0N/A * @param version optional implementation version string (may be null)
0N/A * @since JavaMail 1.4
0N/A */
0N/A public Provider(Type type, String protocol, String classname,
0N/A String vendor, String version)
0N/A
0N/AWe also add a new method to Session to allow registering such Providers:
0N/A
0N/A /**
0N/A * Add a provider to the session.
0N/A *
0N/A * @param provider the provider to add
0N/A * @since JavaMail 1.4
0N/A */
0N/A public void addProvider(Provider provider)
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A17. Allow applications to dynamically register address type mappings (4377727)
0N/A------------------------------------------------------------------------------
0N/A
0N/AAlong with the above item, some applications will want to dynamically
0N/Acontrol the mapping from address type to protocol. This could also
0N/Abe used to change the default internet protocol from "smtp" to "smtps".
0N/AWe add the following method to Session:
0N/A
0N/A /**
0N/A * Set the default transport protocol to use for addresses of
0N/A * the specified type. Normally the default is set by the
0N/A * <code>javamail.default.address.map</code> or
0N/A * <code>javamail.address.map</code> files or resources.
0N/A *
0N/A * @param addresstype type of address
0N/A * @param protocol name of protocol
0N/A * @see #getTransport(Address)
0N/A * @since JavaMail 1.4
0N/A */
0N/A public void setProtocolForAddress(String addresstype, String protocol)
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A18. ParameterList class should support non US-ASCII parameters (4107342)
0N/A------------------------------------------------------------------------
0N/A
0N/ARFC 2231 describes a method for encoding non-ASCII parameters in MIME
0N/Aheaders. We introduce the following System properties to control
0N/Aencoding and decoding such parameters.
0N/A
0N/AIf the mail.mime.encodeparameters System property is set to "true".
0N/Anon-ASCII parameters will be encoded per RFC 2231.
0N/A
0N/AIf the mail.mime.decodeparameters System property is set to "true".
0N/Aparameters encoded per RFC 2231 will be decoded.
0N/A
0N/ABoth of these properties default to "false".
0N/A
0N/ANote that RFC 2231 also describes a technique for splitting long
0N/Aparameter values across multiple parameters. We do not plan to
0N/Asupport such parameter continuations.
0N/A
0N/ATo allow specifying the charset to use for a parameter, we add
0N/Athe following method to ParameterList:
0N/A
0N/A /**
0N/A * Set a parameter. If this parameter already exists, it is
0N/A * replaced by this new value. If the
0N/A * <code>mail.mime.encodeparameters</code> System property
0N/A * is true, and the parameter value is non-ASCII, it will be
0N/A * encoded with the specified charset.
0N/A *
0N/A * @param name name of the parameter.
0N/A * @param value value of the parameter.
0N/A * @param charset charset of the parameter value.
0N/A * @since JavaMail 1.4
0N/A */
0N/A public void set(String name, String value, String charset)
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A19. Standard interface for Stores that support quotas (6304051)
0N/A---------------------------------------------------------------
0N/A
0N/ASome IMAP stores support quotas. To allow applications to make
0N/Ause of quota support without depending on IMAP-specific APIs,
0N/Awe provide a QuotaAwareStore interface that Stores, such as the
0N/AIMAP Store, can implement. We also provide a Quota class to
0N/Arepresent a set of quotas for a quota root.
0N/A
0N/Apackage javax.mail;
0N/A
0N/A/**
0N/A * An interrface implemented by Stores that support quotas.
0N/A * The {@link #getQuota getQuota} and {@link #setQuota setQuota} methods
0N/A * support the quota model defined by the IMAP QUOTA extension.
0N/A * Refer to <A HREF="http://www.ietf.org/rfc/rfc2087.txt">RFC 2087</A>
0N/A * for more information. <p>
0N/A *
0N/A * @since JavaMail 1.4
0N/A */
0N/Apublic interface QuotaAwareStore {
0N/A /**
0N/A * Get the quotas for the named quota root.
0N/A * Quotas are controlled on the basis of a quota root, not
0N/A * (necessarily) a folder. The relationship between folders
0N/A * and quota roots depends on the server. Some servers
0N/A * might implement a single quota root for all folders owned by
0N/A * a user. Other servers might implement a separate quota root
0N/A * for each folder. A single folder can even have multiple
0N/A * quota roots, perhaps controlling quotas for different
0N/A * resources.
0N/A *
0N/A * @param root the name of the quota root
0N/A * @return array of Quota objects
0N/A * @exception MessagingException if the server doesn't support the
0N/A * QUOTA extension
0N/A */
0N/A Quota[] getQuota(String root) throws MessagingException;
0N/A
0N/A /**
0N/A * Set the quotas for the quota root specified in the quota argument.
0N/A * Typically this will be one of the quota roots obtained from the
0N/A * <code>getQuota</code> method, but it need not be.
0N/A *
0N/A * @param quota the quota to set
0N/A * @exception MessagingException if the server doesn't support the
0N/A * QUOTA extension
0N/A */
0N/A void setQuota(Quota quota) throws MessagingException;
0N/A}
0N/A
0N/Apackage javax.mail;
0N/A
0N/A/**
0N/A * This class represents a set of quotas for a given quota root.
0N/A * Each quota root has a set of resources, represented by the
0N/A * <code>Quota.Resource</code> class. Each resource has a name
0N/A * (for example, "STORAGE"), a current usage, and a usage limit.
0N/A * See RFC 2087.
0N/A *
0N/A * @since JavaMail 1.4
0N/A */
0N/A
0N/Apublic class Quota {
0N/A
0N/A /**
0N/A * An individual resource in a quota root.
0N/A *
0N/A * @since JavaMail 1.4
0N/A */
0N/A public static class Resource {
0N/A /** The name of the resource. */
0N/A public String name;
0N/A /** The current usage of the resource. */
0N/A public long usage;
0N/A /** The usage limit for the resource. */
0N/A public long limit;
0N/A
0N/A /**
0N/A * Construct a Resource object with the given name,
0N/A * usage, and limit.
0N/A *
0N/A * @param name the resource name
0N/A * @param usage the current usage of the resource
0N/A * @param limit the usage limit for the resource
0N/A */
0N/A public Resource(String name, long usage, long limit)
0N/A }
0N/A
0N/A /**
0N/A * The name of the quota root.
0N/A */
0N/A public String quotaRoot;
0N/A
0N/A /**
0N/A * The set of resources associated with this quota root.
0N/A */
0N/A public Quota.Resource[] resources;
0N/A
0N/A /**
0N/A * Create a Quota object for the named quotaroot with no associated
0N/A * resources.
0N/A *
0N/A * @param quotaRoot the name of the quota root
0N/A */
0N/A public Quota(String quotaRoot)
0N/A
0N/A /**
0N/A * Set a resource limit for this quota root.
0N/A *
0N/A * @param name the name of the resource
0N/A * @param limit the resource limit
0N/A */
0N/A public void setResourceLimit(String name, long limit)
0N/A}
0N/A
0N/A===================================================================
0N/A
0N/A20. Add ByteArrayDataSource class (4623517)
0N/A-------------------------------------------
0N/A
0N/AThe ByteArrayDataSource has been included in the JavaMail demo
0N/Asource code for quite some time. Quite a few applications need
0N/Aa class of this sort. It's time to add it as a standard API.
0N/ATo avoid conflicting with applications that have used the demo
0N/Aversion, we put this version in a new javax.mail.util package.
0N/A
0N/Apackage javax.mail.util;
0N/A
0N/A/**
0N/A * A DataSource backed by a byte array. The byte array may be
0N/A * passed in directly, or may be initialized from an InputStream
0N/A * or a String.
0N/A *
0N/A * @since JavaMail 1.4
0N/A */
0N/Apublic class ByteArrayDataSource implements DataSource {
0N/A /**
0N/A * Create a ByteArrayDataSource with data from the
0N/A * specified byte array and with the specified MIME type.
0N/A */
0N/A public ByteArrayDataSource(byte[] data, String type)
0N/A
0N/A /**
0N/A * Create a ByteArrayDataSource with data from the
0N/A * specified InputStream and with the specified MIME type.
0N/A * The InputStream is read completely and the data is
0N/A * stored in a byte array.
0N/A */
0N/A public ByteArrayDataSource(InputStream is, String type) throws IOException
0N/A
0N/A /**
0N/A * Create a ByteArrayDataSource with data from the
0N/A * specified String and with the specified MIME type.
0N/A * The MIME type should include a <code>charset</code>
0N/A * parameter specifying the charset to be used for the
0N/A * string. If the parameter is not included, the
0N/A * default charset is used.
0N/A */
0N/A public ByteArrayDataSource(String data, String type) throws IOException
0N/A
0N/A /**
0N/A * Return an InputStream for the data.
0N/A * Note that a new stream is returned each time
0N/A * this method is called.
0N/A */
0N/A public InputStream getInputStream() throws IOException
0N/A
0N/A /**
0N/A * Return an OutputStream for the data.
0N/A * Writing the data is not supported; an <code>IOException</code>
0N/A * is always thrown.
0N/A */
0N/A public OutputStream getOutputStream() throws IOException
0N/A
0N/A /**
0N/A * Get the MIME content type of the data.
0N/A */
0N/A public String getContentType()
0N/A
0N/A /**
0N/A * Get the name of the data.
0N/A * By default, an empty string ("") is returned.
0N/A */
0N/A public String getName()
0N/A
0N/A /**
0N/A * Set the name of the data.
0N/A */
0N/A public void setName(String name)
0N/A}
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A21. Add SharedByteArrayInputStream class (6304189)
0N/A--------------------------------------------------
0N/A
0N/AThe SharedInputStream interface allows the JavaMail implementation to
0N/Aefficiently process data when parsing messages, without needing to
0N/Amake many copies of the data. This class is an implementation of the
0N/ASharedInputStream interface that uses a byte array as the backing store.
0N/A
0N/Apackage javax.mail.util;
0N/A
0N/A/**
0N/A * A ByteArrayInputStream that implements the SharedInputStream interface,
0N/A * allowing the underlying byte array to be shared between multiple readers.
0N/A *
0N/A * @since JavaMail 1.4
0N/A */
0N/Apublic class SharedByteArrayInputStream extends ByteArrayInputStream
0N/A implements SharedInputStream {
0N/A /**
0N/A * Position within shared buffer that this stream starts at.
0N/A */
0N/A protected int start;
0N/A
0N/A /**
0N/A * Create a SharedByteArrayInputStream representing the entire
0N/A * byte array.
0N/A */
0N/A public SharedByteArrayInputStream(byte[] buf)
0N/A
0N/A /**
0N/A * Create a SharedByteArrayInputStream representing the part
0N/A * of the byte array from <code>offset</code> for <code>length</code>
0N/A * bytes.
0N/A */
0N/A public SharedByteArrayInputStream(byte[] buf, int offset, int length)
0N/A
0N/A /**
0N/A * Return the current position in the InputStream, as an
0N/A * offset from the beginning of the InputStream.
0N/A *
0N/A * @return the current position
0N/A */
0N/A public long getPosition()
0N/A
0N/A /**
0N/A * Return a new InputStream representing a subset of the data
0N/A * from this InputStream, starting at <code>start</code> (inclusive)
0N/A * up to <code>end</code> (exclusive). <code>start</code> must be
0N/A * non-negative. If <code>end</code> is -1, the new stream ends
0N/A * at the same place as this stream. The returned InputStream
0N/A * will also implement the SharedInputStream interface.
0N/A *
0N/A * @param start the starting position
0N/A * @param end the ending position + 1
0N/A * @return the new stream
0N/A */
0N/A public InputStream newStream(long start, long end)
0N/A}
0N/A
0N/A
0N/A===================================================================
0N/A
0N/A22. Add SharedFileInputStream class (6304193)
0N/A---------------------------------------------
0N/A
0N/AFinally, SharedFileInputStream is an implementation of the
0N/ASharedInputStream interface that uses a file as the backing store.
0N/A
0N/Apackage javax.mail.util;
0N/A
0N/A/**
0N/A * A <code>SharedFileInputStream</code> is a
0N/A * <code>BufferedInputStream</code> that buffers
0N/A * data from the file and supports the <code>mark</code>
0N/A * and <code>reset</code> methods. It also supports the
0N/A * <code>newStream</code> method that allows you to create
0N/A * other streams that represent subsets of the file.
0N/A * A <code>RandomAccessFile</code> object is used to
0N/A * access the file data.
0N/A *
0N/A * @since JavaMail 1.4
0N/A */
0N/Apublic class SharedFileInputStream extends BufferedInputStream
0N/A implements SharedInputStream {
0N/A
0N/A /**
0N/A * The file containing the data.
0N/A * Shared by all related SharedFileInputStream instances.
0N/A */
0N/A protected RandomAccessFile in;
0N/A
0N/A /**
0N/A * The normal size of the read buffer.
0N/A */
0N/A protected int bufsize;
0N/A
0N/A /**
0N/A * The file offset that corresponds to the first byte in
0N/A * the read buffer.
0N/A */
0N/A protected long bufpos;
0N/A
0N/A /**
0N/A * The file offset of the start of data in this subset of the file.
0N/A */
0N/A protected long start = 0;
0N/A
0N/A /**
0N/A * The amount of data in this subset of the file.
0N/A */
0N/A protected long datalen;
0N/A
0N/A /**
0N/A * Creates a <code>SharedFileInputStream</code>
0N/A * for the file.
0N/A *
0N/A * @param file the file
0N/A */
0N/A public SharedFileInputStream(File file) throws IOException
0N/A
0N/A /**
0N/A * Creates a <code>SharedFileInputStream</code>
0N/A * for the named file.
0N/A *
0N/A * @param file the file
0N/A */
0N/A public SharedFileInputStream(String file) throws IOException
0N/A
0N/A /**
0N/A * Creates a <code>SharedFileInputStream</code>
0N/A * with the specified buffer size.
0N/A *
0N/A * @param file the file
0N/A * @param size the buffer size.
0N/A * @exception IllegalArgumentException if size <= 0.
0N/A */
0N/A public SharedFileInputStream(File file, int size) throws IOException
0N/A
0N/A /**
0N/A * Creates a <code>SharedFileInputStream</code>
0N/A * with the specified buffer size.
0N/A *
0N/A * @param file the file
0N/A * @param size the buffer size.
0N/A * @exception IllegalArgumentException if size <= 0.
0N/A */
0N/A public SharedFileInputStream(String file, int size) throws IOException
0N/A
0N/A /**
0N/A * See the general contract of the <code>read</code>
0N/A * method of <code>InputStream</code>.
0N/A *
0N/A * @return the next byte of data, or <code>-1</code> if the end of the
0N/A * stream is reached.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A public int read() throws IOException
0N/A
0N/A /**
0N/A * Reads bytes from this stream into the specified byte array,
0N/A * starting at the given offset.
0N/A *
0N/A * <p> This method implements the general contract of the corresponding
0N/A * <code>{@link java.io.InputStream#read(byte[], int, int) read}</code>
0N/A * method of the <code>{@link java.io.InputStream}</code> class.
0N/A *
0N/A * @param b destination buffer.
0N/A * @param off offset at which to start storing bytes.
0N/A * @param len maximum number of bytes to read.
0N/A * @return the number of bytes read, or <code>-1</code> if the end of
0N/A * the stream has been reached.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A public int read(byte b[], int off, int len) throws IOException
0N/A
0N/A /**
0N/A * See the general contract of the <code>skip</code>
0N/A * method of <code>InputStream</code>.
0N/A *
0N/A * @param n the number of bytes to be skipped.
0N/A * @return the actual number of bytes skipped.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A public long skip(long n) throws IOException
0N/A
0N/A /**
0N/A * Returns the number of bytes that can be read from this input
0N/A * stream without blocking.
0N/A *
0N/A * @return the number of bytes that can be read from this input
0N/A * stream without blocking.
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A public int available() throws IOException
0N/A
0N/A /**
0N/A * See the general contract of the <code>mark</code>
0N/A * method of <code>InputStream</code>.
0N/A *
0N/A * @param readlimit the maximum limit of bytes that can be read before
0N/A * the mark position becomes invalid.
0N/A * @see #reset()
0N/A */
0N/A public void mark(int readlimit)
0N/A
0N/A /**
0N/A * See the general contract of the <code>reset</code>
0N/A * method of <code>InputStream</code>.
0N/A * <p>
0N/A * If <code>markpos</code> is <code>-1</code>
0N/A * (no mark has been set or the mark has been
0N/A * invalidated), an <code>IOException</code>
0N/A * is thrown. Otherwise, <code>pos</code> is
0N/A * set equal to <code>markpos</code>.
0N/A *
0N/A * @exception IOException if this stream has not been marked or
0N/A * if the mark has been invalidated.
0N/A * @see #mark(int)
0N/A */
0N/A public void reset() throws IOException
0N/A
0N/A /**
0N/A * Tests if this input stream supports the <code>mark</code>
0N/A * and <code>reset</code> methods. The <code>markSupported</code>
0N/A * method of <code>SharedFileInputStream</code> returns
0N/A * <code>true</code>.
0N/A *
0N/A * @return a <code>boolean</code> indicating if this stream type supports
0N/A * the <code>mark</code> and <code>reset</code> methods.
0N/A * @see java.io.InputStream#mark(int)
0N/A * @see java.io.InputStream#reset()
0N/A */
0N/A public boolean markSupported()
0N/A
0N/A /**
0N/A * Closes this input stream and releases any system resources
0N/A * associated with the stream.
0N/A *
0N/A * @exception IOException if an I/O error occurs.
0N/A */
0N/A public void close() throws IOException
0N/A
0N/A /**
0N/A * Return the current position in the InputStream, as an
0N/A * offset from the beginning of the InputStream.
0N/A *
0N/A * @return the current position
0N/A */
0N/A public long getPosition()
0N/A
0N/A /**
0N/A * Return a new InputStream representing a subset of the data
0N/A * from this InputStream, starting at <code>start</code> (inclusive)
0N/A * up to <code>end</code> (exclusive). <code>start</code> must be
0N/A * non-negative. If <code>end</code> is -1, the new stream ends
0N/A * at the same place as this stream. The returned InputStream
0N/A * will also implement the SharedInputStream interface.
0N/A *
0N/A * @param start the starting position
0N/A * @param end the ending position + 1
0N/A * @return the new stream
0N/A */
0N/A public InputStream newStream(long start, long end)
0N/A
0N/A /**
0N/A * Force this stream to close.
0N/A */
0N/A protected void finalize() throws Throwable
0N/A}