📄 message.java
字号:
* @param type the recipient type * @param address the address * @exception MessagingException * @exception IllegalWriteException if the underlying * implementation does not support modification * of existing values */ public void setRecipient(RecipientType type, Address address) throws MessagingException { Address[] a = new Address[1]; a[0] = address; setRecipients(type, a); } /** * Add these recipient addresses to the existing ones of the given type. * * @param type the recipient type * @param addresses the addresses * @exception MessagingException * @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. */ public abstract void addRecipients(RecipientType type, Address[] addresses) throws MessagingException; /** * Add this recipient address to the existing ones of the given type. <p> * * The default implementation uses the <code>addRecipients</code> method. * * @param type the recipient type * @param address the address * @exception MessagingException * @exception IllegalWriteException if the underlying * implementation does not support modification * of existing values */ public void addRecipient(RecipientType type, Address address) throws MessagingException { Address[] a = new Address[1]; a[0] = address; addRecipients(type, a); } /** * Get the addresses to which replies should be directed. * This will usually be the sender of the message, but * some messages may direct replies to a different address. <p> * * The default implementation simply calls the <code>getFrom</code> * method. <p> * * This method returns <code>null</code> if the corresponding * header is not present. Returns an empty array if the header * is present, but contains no addresses. * * @return addresses to which replies should be directed * @exception MessagingException * @see #getFrom */ public Address[] getReplyTo() throws MessagingException { return getFrom(); } /** * Set the addresses to which replies should be directed. * (Normally only a single address will be specified.) * Not all message types allow this to be specified separately * from the sender of the message. <p> * * The default implementation provided here just throws the * MethodNotSupportedException. * * @param addresses addresses to which replies should be directed * @exception MessagingException * @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 MethodNotSupportedException if the underlying * implementation does not support setting this * attribute */ public void setReplyTo(Address[] addresses) throws MessagingException { throw new MethodNotSupportedException("setReplyTo not supported"); } /** * Get the subject of this message. * * @return the subject * @exception MessagingException */ public abstract String getSubject() throws MessagingException; /** * Set the subject of this message. * * @param subject the subject * @exception MessagingException * @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. */ public abstract void setSubject(String subject) throws MessagingException; /** * Get the date this message was sent. * * @return the date this message was sent * @exception MessagingException */ public abstract Date getSentDate() throws MessagingException; /** * Set the sent date of this message. * * @param date the sent date of this message * @exception MessagingException * @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. */ public abstract void setSentDate(Date date) throws MessagingException; /** * Get the date this message was received. * * @return the date this message was received * @exception MessagingException */ public abstract Date getReceivedDate() throws MessagingException; /** * Returns a <code>Flags</code> object containing the flags for * this message. <p> * * Modifying any of the flags in this returned Flags object will * not affect the flags of this message. Use <code>setFlags()</code> * to do that. <p> * * @return Flags object containing the flags for this message * @see javax.mail.Flags * @see #setFlags * @exception MessagingException */ public abstract Flags getFlags() throws MessagingException; /** * Check whether the flag specified in the <code>flag</code> * argument is set in this message. <p> * * The default implementation uses <code>getFlags</code>. * * @param flag the flag * @return value of the specified flag for this message * @see javax.mail.Flags.Flag * @see javax.mail.Flags.Flag#ANSWERED * @see javax.mail.Flags.Flag#DELETED * @see javax.mail.Flags.Flag#DRAFT * @see javax.mail.Flags.Flag#FLAGGED * @see javax.mail.Flags.Flag#RECENT * @see javax.mail.Flags.Flag#SEEN * @exception MessagingException */ public boolean isSet(Flags.Flag flag) throws MessagingException { return getFlags().contains(flag); } /** * Set the specified flags on this message to the specified value. * Note that any flags in this message that are not specified in * the given <code>Flags</code> object are unaffected. <p> * * This will result in a <code>MessageChangedEvent</code> being * delivered to any MessageChangedListener registered on this * Message's containing folder. * * @param flag Flags object containing the flags to be set * @param set the value to be set * @exception MessagingException * @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. * @see javax.mail.event.MessageChangedEvent */ public abstract void setFlags(Flags flag, boolean set) throws MessagingException; /** * Set the specified flag on this message to the specified value. * * This will result in a <code>MessageChangedEvent</code> being * delivered to any MessageChangedListener registered on this * Message's containing folder. <p> * * The default implementation uses the <code>setFlags</code> method. * * @param flag Flags.Flag object containing the flag to be set * @param set the value to be set * @exception MessagingException * @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. * @see javax.mail.event.MessageChangedEvent */ public void setFlag(Flags.Flag flag, boolean set) throws MessagingException { Flags f = new Flags(flag); setFlags(f, set); } /** * Get the Message number for this Message. * A Message object's message number is the relative * position of this Message in its Folder. Note that the message * number for a particular Message can change during a session * if other messages in the Folder are deleted and expunged. <p> * * Valid message numbers start at 1. Messages that do not belong * to any folder (like newly composed or derived messages) have 0 * as their message number. * * @return the message number */ public int getMessageNumber() { return msgnum; } /** * Set the Message number for this Message. This method is * invoked only by the implementation classes. */ protected void setMessageNumber(int msgnum) { this.msgnum = msgnum; } /** * Get the folder from which this message was obtained. If * this is a new message or nested message, this method returns * null. * * @return the containing folder */ public Folder getFolder() { return folder; } /** * Checks whether this message is expunged. All other methods except * <code>getMessageNumber()</code> are invalid on an expunged * Message object. <p> * * Messages that are expunged due to an explict <code>expunge()</code> * request on the containing Folder are removed from the Folder * immediately. Messages that are externally expunged by another source * are marked "expunged" and return true for the isExpunged() method, * but they are not removed from the Folder until an explicit * <code>expunge()</code> is done on the Folder. <p> * * See the description of <code>expunge()</code> for more details on * expunge handling. * * @see Folder#expunge */ public boolean isExpunged() { return expunged; } /** * Sets the expunged flag for this Message. This method is to * be used only by the implementation classes. * * @param expunged the expunged flag */ protected void setExpunged(boolean expunged) { this.expunged = expunged; } /** * Get a new Message suitable for a reply to this message. * The new Message will have its attributes and headers * set up appropriately. Note that this new message object * will be empty, that is, it will <strong>not</strong> have a "content". * These will have to be suitably filled in by the client. <p> * * If <code>replyToAll</code> is set, the new Message will be addressed * to all recipients of this message. Otherwise, the reply will be * addressed to only the sender of this message (using the value * of the <code>getReplyTo</code> method). <p> * * The "Subject" field is filled in with the original subject * prefixed with "Re:" (unless it already starts with "Re:"). <p> * * The reply message will use the same session as this message. * * @param replyToAll reply should be sent to all recipients * of this message * @return the reply Message * @exception MessagingException */ public abstract Message reply(boolean replyToAll) throws MessagingException; /** * Save any changes made to this message into the message-store * when the containing folder is closed, if the message is contained * in a folder. (Some implementations may save the changes * immediately.) Update any header fields to be consistent with the * changed message contents. If any part of a message's headers or * contents are changed, saveChanges must be called to ensure that * those changes are permanent. If saveChanges is not called, any * such modifications may or may not be saved, depending on the * message store and folder implementation. <p> * * Messages obtained from folders opened READ_ONLY should not be * modified and saveChanges should not be called on such messages. * * @exception MessagingException * @exception IllegalStateException if this message is * obtained from a READ_ONLY folder. * @exception IllegalWriteException if the underlying * implementation does not support modification * of existing values. */ public abstract void saveChanges() throws MessagingException; /** * Apply the specified Search criterion to this message. * * @param term the Search criterion * @return true if the Message matches this search * criterion, false otherwise. * @exception MessagingException * @see javax.mail.search.SearchTerm */ public boolean match(SearchTerm term) throws MessagingException { return term.match(this); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -