1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022
|
JavaMail 1.2
============
Following is a description of the new APIs that are being
introduced in JavaMail 1.2. The numbers in parentheses
are bug numbers; you can find more information about the
bug reports at:
http://developer.java.sun.com/developer/bugParade/index.html
Please send comments and feedback to javamail@sun.com.
===================================================================
1. New protected field and methods (4129743)
--------------------------------------------
To simplify creating subclasses of MimeMessage, the following
field and method that were previously private are now protected:
/**
* A flag indicating whether the message has been modified.
* If the message has not been modified, any data in the
* <code>content</code> array is assumed to be valid and is used
* directly in the <code>writeTo</code> method. This flag is
* set to true when an empty message is created or when the
* <code>saveChanges</code> method is called.
*/
protected boolean modified = false;
/**
* Parse the InputStream setting the <code>headers</code> and
* <code>content</code> fields appropriately. Also resets the
* <code>modified</code> flag. <p>
*
* This method is intended for use by subclasses that need to
* control when the InputStream is parsed.
*
* @param is The message input stream
* @exception MessagingException
*/
protected void parse(InputStream is) throws MessagingException
The javadocs for the following exsting methods have been updated to
describe the use of the modified flag:
/**
* Default constructor. An empty message object is created.
* The <code>headers</code> field is set to an empty InternetHeaders
* object. The <code>flags</code> field is set to an empty Flags
* object. The <code>modified</code> flag is set to true.
*/
public MimeMessage(Session session)
/**
* Output the message as an RFC 822 format stream, without
* specified headers. If the <code>modified</code> flag is not
* set and the <code>content</code> array is not null, the
* <code>content</code> array is written directly, after
* writing the appropriate message headers.
*
* @exception javax.mail.MessagingException
* @exception IOException if an error occurs writing to the stream
* or if an error is generated by the
* javax.activation layer.
* @see javax.activation.DataHandler#writeTo
*/
public void writeTo(OutputStream os, String[] ignoreList)
throws IOException, MessagingException
/**
* Updates the appropriate header fields of this message to be
* consistent with the message's contents. If this message is
* contained in a Folder, any changes made to this message are
* committed to the containing folder. <p>
*
* If any part of a message's headers or contents are changed,
* <code>saveChanges</code> must be called to ensure that those
* changes are permanent. Otherwise, any such modifications may or
* may not be saved, depending on the folder implementation. <p>
*
* Messages obtained from folders opened READ_ONLY should not be
* modified and saveChanges should not be called on such messages. <p>
*
* This method sets the <code>modified</code> flag to true and then
* calls the <code>updateHeaders<code> method.
*
* @exception IllegalWriteException if the underlying
* implementation does not support modification
* @exception IllegalStateException if this message is
* obtained from a READ_ONLY folder.
* @exception MessagingException
*/
public void saveChanges() throws MessagingException
The following method is added to MimeMessage:
/**
* Create and return an InternetHeaders object that loads the
* headers from the given InputStream. Subclasses can override
* this method to return a subclass of InternetHeaders, if
* necessary. This implementation simply constructs and returns
* an InternetHeaders object.
*
* @param is the InputStream to read the headers from
* @exception MessagingException
*/
protected InternetHeaders createInternetHeaders(InputStream is)
throws MessagingException
Likewise, to simplify creating subclasses of MimeMultipart, the parse
method is made protected:
/**
* Parse the InputStream from our DataSource, constructing the
* appropriate MimeBodyParts. The <code>parsed</code> flag is
* set to true, and if true on entry nothing is done. This
* method is called by all other methods that need data for
* the body parts, to make sure the data has been parsed.
*/
protected synchronized void parse() throws MessagingException
and the following protected methods are added:
/**
* Create and return an InternetHeaders object that loads the
* headers from the given InputStream. Subclasses can override
* this method to return a subclass of InternetHeaders, if
* necessary. This implementation simply constructs and returns
* an InternetHeaders object.
*
* @param is the InputStream to read the headers from
* @exception MessagingException
*/
protected InternetHeaders createInternetHeaders(InputStream is)
throws MessagingException
/**
* Create and return a MimeBodyPart object to represent a
* body part parsed from the InputStream. Subclasses can override
* this method to return a subclass of MimeBodyPart, if
* necessary. This implementation simply constructs and returns
* a MimeBodyPart object.
*
* @param headers the headers for the body part
* @param content the content ofthe body part
* @exception MessagingException
*/
protected MimeBodyPart createMimeBodyPart(InternetHeaders headers,
byte[] content) throws MessagingException
/**
* Create and return a MimeBodyPart object to represent a
* body part parsed from the InputStream. Subclasses can override
* this method to return a subclass of MimeBodyPart, if
* necessary. This implementation simply constructs and returns
* a MimeBodyPart object.
*
* @param is InputStream containing the body part
* @exception MessagingException
*/
protected MimeBodyPart createMimeBodyPart(InputStream is)
throws MessagingException
===================================================================
2. MimeMessage and MimeBodyPart getRawInputStream method (4124840)
------------------------------------------------------------------
In some cases it is desirable to get the data for a body part
before JavaMail attempts to decode it. This is particularly important
if the Content-Transfer-Encoding header is incorrect. (For example,
some mail software is known to use "7-bit" instead of the MIME
defined "7bit".) Access to this data is currently provided
through the protected getContentStream method. Since simply
making this method public has the potential to cause a source
incompatibility for any subclasses that declare this method as
protected, we instead add a new public method that calls this
protected method:
/**
* Return an InputStream to the raw data with any Content-Transfer-Encoding
* intact. This method is useful if the "Content-Transfer-Encoding"
* header is incorrect or corrupt, which would prevent the
* <code>getInputStream</code> method or <code>getContent</code> method
* from returning the correct data. In such a case the application may
* use this method and attempt to decode the raw data itself. <p>
*
* This implementation simply calls the <code>getContentStream</code>
* method.
*
* @see #getInputStream
* @see #getContentStream
*/
public InputStream getRawInputStream() throws MessagingException
===================================================================
3. ReadOnlyFolderException (4163360)
------------------------------------
A new MessagingException subclass to indicate a read-only folder
is needed.
Currently, if a client attempts to open a folder in read-write mode
and the folder is read-only, a MessagingException is thrown. This
exception type does not indicate that the anomaly was caused due to
the lack of write-permissions.
/**
* This exception is thrown when an attempt is made to open a folder
* with read-write access when the folder is marked read-only. <p>
*/
public class ReadOnlyFolderException extends MessagingException {
/**
* Constructor.
* @param folder the Folder
*/
public ReadOnlyFolderException(Folder folder)
/**
* Constructor.
* @param folder the Folder
* @param message the detailed error message
*/
public ReadOnlyFolderException(Folder folder, String message)
/**
* Returns the Folder object.
*/
public Folder getFolder()
}
===================================================================
4. InternetAddress implements Cloneable (4181144)
-------------------------------------------------
To simplify copying of InternetAddress objects, the InternetAddress
class will implement the Cloneable interface and will provide a
public clone method.
public class InternetAddress extends Address implements Cloneable {
/**
* Return a copy of this InternetAddress object.
*/
public Object clone()
}
===================================================================
5. MimeMessage copy constructor (4107752)
-----------------------------------------
When forwarding or saving a message retrieved from a Store, it is
sometimes desirable to be able to modify the message first. Since
most Stores do not allow their Message objects to be modified, the
message must first be copied. To simplify copying a MimeMessage,
we introduce a copy constructor that allows a new MimeMessage to
be created and initialized with a copy of another MimeMessage.
/**
* Constructs a new MimeMessage with content initialized form the
* <code>source</code> MimeMessage. The new message is independent
* of the original. <p>
*
* @param source the message to copy content from
* @exception MessagingException
*/
public MimeMessage(MimeMessage source) throws MessagingException
===================================================================
6. AuthenticationFailedException includes server message (4230553)
------------------------------------------------------------------
When authentication with a server fails, the server often supplies
some information in its protocol message that indicates the reason
for the failure. To allow a service provider to return this information
to the user, we now allow the Service.protocolConnect() method to
throw an AuthenticationFailedException in this case. The exception
may contain a string message that includes the additional information
from the server.
/**
* The service implementation should override this method to
* perform the actual protocol-specific connection attempt.
* The default implementation of the <code>connect</code> method
* calls this method as needed. <p>
*
* The <code>protocolConnect</code> method should return
* <code>false</code> if a user name or password is required
* for authentication but the corresponding parameter is null;
* the <code>connect</code> method will prompt the user when
* needed to supply missing information. This method may
* also return <code>false</code> if authentication fails for
* the supplied user name or password. Alternatively, this method
* may throw an AuthenticationFailedException when authentication
* fails. This exception may include a String message with more
* detail about the failure. <p>
*
* The <code>protocolConnect</code> method should throw an
* exception to report failures not related to authentication,
* such as an invalid host name or port number, loss of a
* connection during the authentication process, unavailability
* of the server, etc.
*
* @param host the name of the host to connect to
* @param port the port to use (-1 means use default port)
* @param user the name of the user to login as
* @param password the user's password
* @return true if connection successful, false if authentication failed
* @exception AuthenticationFailedException for authentication failures
* @exception MessagingException for non-authentication failures
*/
protected boolean protocolConnect(String host, int port, String user,
String password) throws MessagingException
===================================================================
7. Support ESMTP 8BITMIME extension (4132029)
---------------------------------------------
JavaMail chooses the encoding for body parts when the Message.saveChanges()
method is called. At the time this method is called, JavaMail has no
information about the Transport that might be used to send the message.
Thus, communicating the Transport's capabilities to the part of JavaMail
that chooses body part encodings is problematic.
To provide some minimal support for the 8BITMIME extension, the SMTP
protocol provider is extended in the following way. Note that this
capability is part of Sun's SMTP protocol provider, and is *not* a
part of the JavaMail API spec. We include it here for convenience only.
If the property "mail.smtp.allow8bitmime" is set to "true", and the
SMTP server supports the 8BITMIME extension, the SMTP Transport will
traverse the message and adjust the Content-Transfer-Encoding of text
body parts from "quoted-printable" or "base64" to "8bit" as appropriate.
Note that if the same message is subsequently sent over a Transport
or to a server that does not support 8bit MIME, the message will *not*
be converted back to a non-8bit encoding. Normally this will not be a
problem. Note also that a message using "8bit" encoding can be safely
appended to an IMAP folder.
===================================================================
8. Make MailDateFormat class public (4266390)
---------------------------------------------
It would be useful to have the MailDateFormat class available as part
of the javax.mail.internet package to allow parsing and formatting
dates in other MIME headers.
/**
* Formats and parses date specification based on the
* draft-ietf-drums-msg-fmt-08 dated January 26, 2000. This is a followup
* spec to RFC822.<p>
*
* This class does not take pattern strings. It always formats the
* date based on the specification below.<p>
*
* 3.3 Date and Time Specification<p>
*
* Date and time occur in several header fields of a message. This section
* specifies the syntax for a full date and time specification. Though folding
* whitespace is permitted throughout the date-time specification, it is
* recommended that only a single space be used where FWS is required and no
* space be used where FWS is optional in the date-time specification; some
* older implementations may not interpret other occurrences of folding
* whitespace correctly.<p>
*
* date-time = [ day-of-week "," ] date FWS time [CFWS]<p>
*
* day-of-week = ([FWS] day-name) / obs-day-of-week<p>
*
* day-name = "Mon" / "Tue" / "Wed" / "Thu" / "Fri" / "Sat" / "Sun"<p>
*
* date = day month year<p>
*
* year = 4*DIGIT / obs-year<p>
*
* month = (FWS month-name FWS) / obs-month<p>
*
*<pre>month-name = "Jan" / "Feb" / "Mar" / "Apr" /
* "May" / "Jun" / "Jul" / "Aug" /
* "Sep" / "Oct" / "Nov" / "Dec"
* </pre><p>
* day = ([FWS] 1*2DIGIT) / obs-day<p>
*
* time = time-of-day FWS zone<p>
*
* time-of-day = hour ":" minute [ ":" second ]<p>
*
* hour = 2DIGIT / obs-hour<p>
*
* minute = 2DIGIT / obs-minute<p>
*
* second = 2DIGIT / obs-second<p>
*
* zone = (( "+" / "-" ) 4DIGIT) / obs-zone<p>
*
*
* The day is the numeric day of the month. The year is any numeric year in
* the common era.<p>
*
* The time-of-day specifies the number of hours, minutes, and optionally
* seconds since midnight of the date indicated.<p>
*
* The date and time-of-day SHOULD express local time.<p>
*
* The zone specifies the offset from Coordinated Universal Time (UTC,
* formerly referred to as "Greenwich Mean Time") that the date and
* time-of-day represent. The "+" or "-" indicates whether the time-of-day is
* ahead of or behind Universal Time. The first two digits indicate the number
* of hours difference from Universal Time, and the last two digits indicate
* the number of minutes difference from Universal Time. (Hence, +hhmm means
* +(hh * 60 + mm) minutes, and -hhmm means -(hh * 60 + mm) minutes). The form
* "+0000" SHOULD be used to indicate a time zone at Universal Time. Though
* "-0000" also indicates Universal Time, it is used to indicate that the time
* was generated on a system that may be in a local time zone other than
* Universal Time.<p>
*
* A date-time specification MUST be semantically valid. That is, the
* day-of-the week (if included) MUST be the day implied by the date, the
* numeric day-of-month MUST be between 1 and the number of days allowed for
* the specified month (in the specified year), the time-of-day MUST be in the
* range 00:00:00 through 23:59:60 (the number of seconds allowing for a leap
* second; see [STD-12]), and the zone MUST be within the range -9959 through
* +9959.<p>
*
*/
public class MailDateFormat extends SimpleDateFormat {
public MailDateFormat()
/**
* Formats the given date in the format specified by
* draft-ietf-drums-msg-fmt-08 in the current TimeZone
*
* @param date the Date object
* @param dateStrBuf the formatted string
* @param fieldPosition the current field position
* @returns StringBuffer the formatted String
*/
public StringBuffer format(Date date, StringBuffer dateStrBuf,
FieldPosition fieldPosition)
/**
* Parses the given date in the format specified by
* draft-ietf-drums-msg-fmt-08 in the current TimeZone
*
* @param text the formatted date to be parsed
* @param pos the current parse position
* @returns Date the parsed date in a Date object
*/
public Date parse(String text, ParsePosition pos)
}
===================================================================
9. String-based MimeMessage setRecipients and addRecipients methods (4328824)
-----------------------------------------------------------------------------
The following convenience methods will be added to MimeMessage. They take a
String for setting/adding a recipient (instead of javax.mail.Address objects).
/**
* Set the specified recipient type to the given addresses.
* If the address parameter is <code>null</code>, the corresponding
* recipient field is removed.
*
* @param type Recipient type
* @param addresses Addresses
* @exception IllegalWriteException if the underlying
* implementation does not support modification
* of existing values
* @exception IllegalStateException if this message is
* obtained from a READ_ONLY folder.
* @exception MessagingException
* @see #getRecipients
*/
public void setRecipients(Message.RecipientType type, String addresses)
throws MessagingException
/**
* Add the given addresses to the specified recipient type.
*
* @param type Recipient type
* @param addresses Addresses
* @exception IllegalWriteException if the underlying
* implementation does not support modification
* of existing values.
* @exception IllegalStateException if this message is
* obtained from a READ_ONLY folder.
* @exception MessagingException
*/
public void addRecipients(Message.RecipientType type, String addresses)
throws MessagingException
===================================================================
10. Add Session.getDefaultInstance(Properties props) and
Session.getInstance(Properties props) methods (4328826)
---------------------------------------------------------------
These are convenience methods for retrieving the default Session or a new
Session object which does not require an Authenticator parameter
(it is assumed to be null).
/**
* Get the default Session object. If a default has not yet been
* setup, a new Session object is created and installed as the
* default.<p>
*
* Note that a default session created with no Authenticator is
* available to all code executing in the same Java virtual
* machine, and the session can contain security sensitive
* information such as user names and passwords.
*
* @param props Properties object. Used only if a new Session
* object is created.<br>
* It is expected that the client supplies values
* for the properties listed in Appendix A of the
* JavaMail spec (particularly mail.store.protocol,
* mail.transport.protocol, mail.host, mail.user,
* and mail.from) as the defaults are unlikely to
* work in all cases.
* @return the default Session object
*/
public static Session getDefaultInstance(Properties props)
/**
* Get a new Session object.
*
* @param props Properties object that hold relevant properties.<br>
* It is expected that the client supplies values
* for the properties listed in Appendix A of the
* JavaMail spec (particularly mail.store.protocol,
* mail.transport.protocol, mail.host, mail.user,
* and mail.from) as the defaults are unlikely to
* work in all cases.
* @return a new Session object
* @see javax.mail.Authenticator
*/
public static Session getInstance(Properties props)
===================================================================
11. Allow for providing a filename when using MimeUtility.encode() (4140579)
----------------------------------------------------------------------------
The UUEncode encoder requires the filename to be inserted into the encoded
stream. The public access point to the encoder is thru the MimeUtility.encode()
method, which does not have any parameter that can provide the filename.
Hence the uuencoded stream always has "encode.buf" as filename. This new
method allows the setting of the filename.
/**
* Wrap an encoder around the given output stream.
* All the encodings defined in RFC 2045 are supported here.
* They include "base64", "quoted-printable", "7bit", "8bit" and
* "binary". In addition, "uuencode" is also supported.
* The <code>filename</code> parameter is used with the "uuencode"
* encoding and is included in the encoded output.
*
* @param os output stream
* @param encoding the encoding of the stream.
* @param filename name for the file being encoded
* @exception MessagingException
* @return output stream that applies the
* specified encoding.
*/
public static OutputStream encode(OutputStream os, String encoding,
String filename)
throws MessagingException
===================================================================
12. New exception constructors (4259211)
----------------------------------------
The FolderNotFoundException constructors are not consistant with other
exceptions defined in the API. New constructors are needed to eliminate
these inconsistencies.
/**
* Constructs a MessagingException with the specified folder
* @param folder the Folder
*/
public FolderNotFoundException(Folder folder)
/**
* Constructs a MessagingException with the specified detail message
* and the specified folder.
* @param folder the Folder
* @param s the detail message
*/
public FolderNotFoundException(Folder folder, String s)
===================================================================
13. InternetAddress.toUnicodeString() method (4281729)
-------------------------------------------------------
Problem: AddressStringTerm.match does not return the correct results
in some situations.
AddressStringTerm wants to do the match against the formatted address
string in Unicode, not the ASCII version that might include charset
encoding information. To do this it attempts to format the address
itself, but it's not smart enough to know all the rules about
formatting an address (e.g., when to quote the personal name) so it
does this formatting differently than InternetAddress.toString does.
When the address contains only ASCII characters, the formatting should
be identical.
/**
* Returns a properly formatted address (RFC 822 syntax) of
* Unicode characters.
*
* @return Unicode address string
*/
public String toUnicodeString()
===================================================================
14. Call saveChanges automatically on newly constructed message (4339203)
-------------------------------------------------------------------------
One of the most common errors when constructing new messages is forgetting
to call the saveChanges() method before writing out the message or calling
the Transport.sendMessage() method. To solve this problem we add a flag
to MimeMessage and change the writeTo() method accordingly:
/**
* Does the <code>saveChanges</code> method need to be called on
* this message? This flag is set to false by the public constructor
* and set to true by the <code>saveChanges</code> method. The
* <code>writeTo</code> method checks this flag and calls the
* <code>saveChanges</code> method as necessary. This avoids the
* common mistake of forgetting to call the <code>saveChanges</code>
* method on a newly constructed message.
*/
protected boolean saved = false;
/**
* Updates the appropriate header fields of this message to be
* consistent with the message's contents. If this message is
* contained in a Folder, any changes made to this message are
* committed to the containing folder. <p>
*
* If any part of a message's headers or contents are changed,
* <code>saveChanges</code> must be called to ensure that those
* changes are permanent. Otherwise, any such modifications may or
* may not be saved, depending on the folder implementation. <p>
*
* Messages obtained from folders opened READ_ONLY should not be
* modified and saveChanges should not be called on such messages. <p>
*
* This method sets the <code>modified</code> flag to true, the
* <code>save</code> flag to true, and then calls the
* <code>updateHeaders<code> method.
*
* @exception IllegalWriteException if the underlying
* implementation does not support modification
* @exception IllegalStateException if this message is
* obtained from a READ_ONLY folder.
* @exception MessagingException
*/
public void saveChanges() throws MessagingException
/**
* Output the message as an RFC 822 format stream, without
* specified headers. If the <code>saved</code> flag is not set,
* the <code>saveChanges</code> method is called.
* If the <code>modified</code> flag is not
* set and the <code>content</code> array is not null, the
* <code>content</code> array is written directly, after
* writing the appropriate message headers.
*
* @exception javax.mail.MessagingException
* @exception IOException if an error occurs writing to the stream
* or if an error is generated by the
* javax.activation layer.
* @see javax.activation.DataHandler#writeTo
*/
public void writeTo(OutputStream os, String[] ignoreList)
throws IOException, MessagingException
===================================================================
15. New MimeUtility.getEncoding(DataHandler) method (4340648)
-------------------------------------------------------------
To improve the performance of JavaMail, we previously added a (package
private) getEncoding() method to MimeUtility. This method is now public:
/**
* Same as <code>getEncoding(DataSource)</code> except that instead
* of reading the data from an <code>InputStream</code> it uses the
* <code>writeTo</code> method to examine the data. This is more
* efficient in the common case of a <code>DataHandler</code>
* created with an object and a MIME type (for example, a
* "text/plain" String) because all the I/O is done in this
* thread. In the case requiring an <code>InputStream</code> the
* <code>DataHandler</code> uses a thread, a pair of pipe streams,
* and the <code>writeTo</code> method to produce the data. <p>
*/
public static String getEncoding(DataHandler dh)
===================================================================
16. New TransportEvent.getMessage() method (4331674)
-----------------------------------------------------
The TransportEvent class saves the message that caused the error,
but provides no getMessage method for the listener to retrieve the
Message object. The following method will be added:
/**
* Get the Message object associated with this Transport Event.
*
* @return the Message object
*/
public Message getMessage()
===================================================================
17. javax.mail.search terms should be serializable (4126013)
------------------------------------------------------------
The javax.mail.search package allows you to programmatically construct
a search term. It would be convenient if those terms could be saved
in persistent storage and restored in a later session. Using
serialization to store these expressions is the simplest approach.
Many of the search terms reference other objects that must also be
serializable. The most problematic such objects are of the class
Message.RecipientType. This class uses the java "type-safe enum"
idiom, which involves a number of static final instances of the class.
Applications are allowed to test for equivalence with these "constants"
by using the "==" equality operator. Thus, it's critical that only a
single instance of each constant exist in the Java virtual machine.
To ensure that this constraint is met when deserializing an object
of this class, we must take advantage of the JDK 1.2 readReplace()
method. Since this method is not available on JDK 1.1, objects of
this class, and thus search terms that reference them, can not be
correctly deserialized on JDK 1.1. This is a limitation of this
new capability.
To provide this support, the following classes and all their subclasses
now implement the Serializable interface:
javax.mail.search.SearchTerm
javax.mail.Address
javax.mail.Flags
javax.mail.Message.RecipientType
In addition, to allow comparison between search terms, the equals
and hashCode methods on SearchTerm (and all subclasses) now implement
"value" equivalence rather than identity equivalence.
===================================================================
18. Support IMAP NAMESPACE extension (4364827)
------------------------------------------------------------
We propose the following new APIs to be added to javax.mail.Store to
provide namespace information. If the IMAP server supports the
NAMESPACE extension, it will be used to return this information.
/**
* Return a set of folders representing the <i>personal</i> namespaces
* for the current user. A personal namespace is a set of names that
* is considered within the personal scope of the authenticated user.
* Typically, only the authenticated user has access to mail folders
* in their personal namespace. If an INBOX exists for a user, it
* must appear within the user's personal namespace. In the
* typical case, there should be only one personal namespace for each
* user in each Store. <p>
*
* This implementation returns an array with a single entry containing
* the return value of the <code>getDefaultFolder</code> method.
* Subclasses should override this method to return appropriate information.
*
* @exception IllegalStateException if this Store is not connected.
* @return array of Folder objects
*/
public Folder[] getPersonalNamespaces() throws MessagingException
/**
* Return a set of folders representing the namespaces for
* <code>user</code>. The namespaces returned represent the
* personal namespaces for the user. To access mail folders in the
* other user's namespace, the currently authenticated user must be
* explicitly granted access rights. For example, it is common for
* a manager to grant to their secretary access rights to their
* mail folders. <p>
*
* This implementation returns an empty array. Subclasses should
* override this method to return appropriate information.
*
* @exception IllegalStateException if this Store is not connected.
* @return array of Folder objects
*/
public Folder[] getUserNamespaces(String user) throws MessagingException
/**
* Return a set of folders representing the <i>shared</i> namespaces.
* A shared namespace is a namespace that consists of mail folders
* that are intended to be shared amongst users and do not exist
* within a user's personal namespace. <p>
*
* This implementation returns an empty array. Subclasses should
* override this method to return appropriate information.
*
* @exception IllegalStateException if this Store is not connected.
* @return array of Folder objects
*/
public Folder[] getSharedNamespaces() throws MessagingException
===================================================================
19. Make ContentDisposition class public (4366373)
--------------------------------------------------
The javax.mail.internet.ContentDisposition class is package private
and should be made public. The API is:
/**
* This class represents a MIME ContentDisposition value. It provides
* methods to parse a ContentDisposition string into individual components
* and to generate a MIME style ContentDisposition string.
*/
public class ContentDisposition
/**
* No-arg Constructor.
*/
public ContentDisposition()
/**
* Constructor.
*
* @param disposition disposition
* @param list ParameterList
*/
public ContentDisposition(String disposition, ParameterList list)
/**
* Constructor that takes a ContentDisposition string. The String
* is parsed into its constituents: dispostion and parameters.
* A ParseException is thrown if the parse fails.
*
* @param s the ContentDisposition string.
* @exception ParseException if the parse fails.
*/
public ContentDisposition(String s) throws ParseException
/**
* Return the disposition value.
* @return the disposition
*/
public String getDisposition()
/**
* Return the specified parameter value. Returns <code>null</code>
* if this parameter is absent.
* @return parameter value
*/
public String getParameter(String name)
/**
* Return a ParameterList object that holds all the available
* parameters. Returns null if no parameters are available.
*
* @return ParameterList
*/
public ParameterList getParameterList()
/**
* Set the primary type. Overrides existing primary type.
* @param primaryType primary type
*/
public void setDisposition(String disposition)
/**
* Set the specified parameter. If this parameter already exists,
* it is replaced by this new value.
*
* @param name parameter name
* @param value parameter value
*/
public void setParameter(String name, String value)
/**
* Set a new ParameterList.
* @param list ParameterList
*/
public void setParameterList(ParameterList list)
/**
* Retrieve a RFC2045 style string representation of
* this ContentDisposition. Returns <code>null</code> if
* the conversion failed.
*
* @return RFC2045 style string
*/
public String toString()
}
===================================================================
20. Improve performance of MimeMessage (4371862)
--------------------------------------------------
To allow us to improve the performance of the MimeMessage and MimeMultipart
classes when parsing data from an InputStream, we introduce a new
interface that allows the data in the InputStream to be shared instead
of copied, and we use this new interface in key parts of the implementation.
The following field is added to MimeMessage:
/**
* If the data for this message was supplied by an
* InputStream that implements the SharedInputStream interface,
* <code>contentStream</code> is another such stream representing
* the content of this message. In this case, <code>content</code>
* will be null.
*/
protected InputStream contentStream;
The following field is added to MimeBodyPart:
/**
* If the data for this body part was supplied by an
* InputStream that implements the SharedInputStream interface,
* <code>contentStream</code> is another such stream representing
* the content of this body part. In this case, <code>content</code>
* will be null.
*/
protected InputStream contentStream;
The following interface is added:
package javax.mail.internet;
/**
* An InputStream that is backed by data that can be shared by multiple
* readers may implement this interface. This allows users of such an
* InputStream to determine the current positionin the InputStream, and
* to create new InputStreams representing a subset of the data in the
* original InputStream. The new InputStream will access the same
* underlying data as the original, without copying the data.
*/
public interface SharedInputStream {
/**
* Return the current position in the InputStream, as an
* offset from the beginning of the InputStream.
*
* @return the current position
*/
public long getPosition();
/**
* Return a new InputStream representing a subset of the data
* from this InputStream, starting at <code>start</code> (inclusive)
* up to <code>end</code> (exclusive). <code>start</code> must be
* non-negative. If <code>end</code> is -1, the new stream ends
* at the same place as this stream. The returned InputStream
* will also implement the SharedInputStream interface.
*
* @param start the starting position
* @param end the ending position + 1
* @return the new stream
*/
public InputStream newStream(long start, long end);
}
===================================================================
21. New ParameterList.toString(int used) method.
--------------------------------------------------
The ParameterList.toString() method returns its results "unfolded". It
would be useful to have the results "folded" in certain situations. A
new method will be added to the ParamterList class which will return
"folded" results. Folding is defined by RFC 822 as the process of splitting
a header field into multiple lines. "The general rule is that wherever there
may be linear-white-space (NOT simply LWSP-chars), a CRLF immediately
followed by AT LEAST one LWSP-char may instead be inserted." Unfolding is
the process of returning to a single line representation. "Unfolding is
accomplished by regarding CRLF immediately followed by a LWSP-char as
equivalent to the LWSP-char."
/**
* Convert this ParameterList into a MIME String. If this is
* an empty list, an empty string is returned.
*
* The 'used' parameter specifies the number of character positions
* already taken up in the field into which the resulting address
* sequence string is to be inserted. It's used to determine where
* to "fold" the resulting parameter list.
*
* @param used number of character positions already used, in
* the field into which the parameter list is to
* be inserted.
* @return String
*/
public String toString(int used)
|