📄 folder.html
字号:
<A NAME="getType()"><!-- --></A><H3>getType</H3><PRE>public abstract int <B>getType</B>() throws <A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></PRE><DL><DD>Returns the type of this Folder, that is, whether this folder can hold messages or subfolders or both. The returned value is an integer bitfield with the appropriate bits set. This method can be invoked on a closed folder.<P><DD><DL><DT><B>Returns:</B><DD>integer with appropriate bits set<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/FolderNotFoundException.html" title="class in javax.mail">FolderNotFoundException</A></CODE> - if this folder does not exist.<DD><CODE><A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE><DT><B>See Also:</B><DD><A HREF="../../javax/mail/Folder.html#HOLDS_FOLDERS"><CODE>HOLDS_FOLDERS</CODE></A>, <A HREF="../../javax/mail/Folder.html#HOLDS_MESSAGES"><CODE>HOLDS_MESSAGES</CODE></A></DL></DD></DL><HR><A NAME="create(int)"><!-- --></A><H3>create</H3><PRE>public abstract boolean <B>create</B>(int type) throws <A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></PRE><DL><DD>Create this folder on the Store. When this folder is created, any folders in its path that do not exist are also created. <p> If the creation is successful, a CREATED FolderEvent is delivered to any FolderListeners registered on this Folder and this Store.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>type</CODE> - The type of this folder.<DT><B>Returns:</B><DD>true if the creation succeeds, else false.<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE><DT><B>See Also:</B><DD><A HREF="../../javax/mail/Folder.html#HOLDS_FOLDERS"><CODE>HOLDS_FOLDERS</CODE></A>, <A HREF="../../javax/mail/Folder.html#HOLDS_MESSAGES"><CODE>HOLDS_MESSAGES</CODE></A>, <A HREF="../../javax/mail/event/FolderEvent.html" title="class in javax.mail.event"><CODE>FolderEvent</CODE></A></DL></DD></DL><HR><A NAME="isSubscribed()"><!-- --></A><H3>isSubscribed</H3><PRE>public boolean <B>isSubscribed</B>()</PRE><DL><DD>Returns true if this Folder is subscribed. <p> This method can be invoked on a closed Folder. <p> The default implementation provided here just returns true.<P><DD><DL><DT><B>Returns:</B><DD>true if this Folder is subscribed</DL></DD></DL><HR><A NAME="setSubscribed(boolean)"><!-- --></A><H3>setSubscribed</H3><PRE>public void <B>setSubscribed</B>(boolean subscribe) throws <A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></PRE><DL><DD>Subscribe or unsubscribe this Folder. Not all Stores support subscription. <p> This method can be invoked on a closed Folder. <p> The implementation provided here just throws the MethodNotSupportedException.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>subscribe</CODE> - true to subscribe, false to unsubscribe<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/FolderNotFoundException.html" title="class in javax.mail">FolderNotFoundException</A></CODE> - if this folder does not exist.<DD><CODE><A HREF="../../javax/mail/MethodNotSupportedException.html" title="class in javax.mail">MethodNotSupportedException</A></CODE> - if this store does not support subscription<DD><CODE><A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE></DL></DD></DL><HR><A NAME="hasNewMessages()"><!-- --></A><H3>hasNewMessages</H3><PRE>public abstract boolean <B>hasNewMessages</B>() throws <A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></PRE><DL><DD>Returns true if this Folder has new messages since the last time this indication was reset. When this indication is set or reset depends on the Folder implementation (and in the case of IMAP, depends on the server). This method can be used to implement a lightweight "check for new mail" operation on a Folder without opening it. (For example, a thread that monitors a mailbox and flags when it has new mail.) This method should indicate whether any messages in the Folder have the <code>RECENT</code> flag set. <p> Note that this is not an incremental check for new mail, i.e., it cannot be used to determine whether any new messages have arrived since the last time this method was invoked. To implement incremental checks, the Folder needs to be opened. <p> This method can be invoked on a closed Folder that can contain Messages.<P><DD><DL><DT><B>Returns:</B><DD>true if the Store has new Messages<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/FolderNotFoundException.html" title="class in javax.mail">FolderNotFoundException</A></CODE> - if this folder does not exist.<DD><CODE><A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE></DL></DD></DL><HR><A NAME="getFolder(java.lang.String)"><!-- --></A><H3>getFolder</H3><PRE>public abstract <A HREF="../../javax/mail/Folder.html" title="class in javax.mail">Folder</A> <B>getFolder</B>(<A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html" title="class or interface in java.lang">String</A> name) throws <A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></PRE><DL><DD>Return the Folder object corresponding to the given name. Note that this folder does not physically have to exist in the Store. The <code>exists()</code> method on a Folder indicates whether it really exists on the Store. <p> In some Stores, name can be an absolute path if it starts with the hierarchy delimiter. Otherwise, it is interpreted relative to this Folder. <p> Folder objects are not cached by the Store, so invoking this method on the same name multiple times will return that many distinct Folder objects. <p> This method can be invoked on a closed Folder.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - name of the Folder<DT><B>Returns:</B><DD>Folder object<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE></DL></DD></DL><HR><A NAME="delete(boolean)"><!-- --></A><H3>delete</H3><PRE>public abstract boolean <B>delete</B>(boolean recurse) throws <A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></PRE><DL><DD>Delete this Folder. This method will succeed only on a closed Folder. <p> The <code>recurse</code> flag controls whether the deletion affects subfolders or not. If true, all subfolders are deleted, then this folder itself is deleted. If false, the behaviour is dependent on the folder type and is elaborated below: <p> <ul> <li> The folder can contain only messages: (type == HOLDS_MESSAGES). <br> All messages within the folder are removed. The folder itself is then removed. An appropriate FolderEvent is generated by the Store and this folder. <p> <li> The folder can contain only subfolders: (type == HOLDS_FOLDERS). <br> If this folder is empty (does not contain any subfolders at all), it is removed. An appropriate FolderEvent is generated by the Store and this folder.<br> If this folder contains any subfolders, the delete fails and returns false. <p> <li> The folder can contain subfolders as well as messages: <br> If the folder is empty (no messages or subfolders), it is removed. If the folder contains no subfolders, but only messages, then all messages are removed. The folder itself is then removed. In both the above cases, an appropriate FolderEvent is generated by the Store and this folder. <p> If the folder contains subfolders there are 3 possible choices an implementation is free to do: <p> <ol> <li> The operation fails, irrespective of whether this folder contains messages or not. Some implementations might elect to go with this simple approach. The delete() method returns false. <li> Any messages within the folder are removed. Subfolders are not removed. The folder itself is not removed or affected in any manner. The delete() method returns true. And the exists() method on this folder will return true indicating that this folder still exists. <br> An appropriate FolderEvent is generated by the Store and this folder. <li> Any messages within the folder are removed. Subfolders are not removed. The folder itself changes its type from HOLDS_FOLDERS | HOLDS_MESSAGES to HOLDS_FOLDERS. Thus new messages cannot be added to this folder, but new subfolders can be created underneath. The delete() method returns true indicating success. The exists() method on this folder will return true indicating that this folder still exists. <br> An appropriate FolderEvent is generated by the Store and this folder. </ol> </ul><P><DD><DL><DT><B>Returns:</B><DD>true if the Folder is deleted successfully<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/FolderNotFoundException.html" title="class in javax.mail">FolderNotFoundException</A></CODE> - if this folder does not exist<DD><CODE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/IllegalStateException.html" title="class or interface in java.lang">IllegalStateException</A></CODE> - if this folder is not in the closed state.<DD><CODE><A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE><DT><B>See Also:</B><DD><A HREF="../../javax/mail/event/FolderEvent.html" title="class in javax.mail.event"><CODE>FolderEvent</CODE></A></DL></DD></DL><HR><A NAME="renameTo(javax.mail.Folder)"><!-- --></A><H3>renameTo</H3><PRE>public abstract boolean <B>renameTo</B>(<A HREF="../../javax/mail/Folder.html" title="class in javax.mail">Folder</A> f) throws <A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></PRE><DL><DD>Rename this Folder. This method will succeed only on a closed Folder. <p> If the rename is successful, a RENAMED FolderEvent is delivered to FolderListeners registered on this folder and its containing Store.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>f</CODE> - a folder representing the new name for this Folder<DT><B>Returns:</B><DD>true if the Folder is renamed successfully<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/FolderNotFoundException.html" title="class in javax.mail">FolderNotFoundException</A></CODE> - if this folder does not exist<DD><CODE><A HREF="http://java.sun.com/j2se/1.4/docs/api/java/lang/IllegalStateException.html" title="class or interface in java.lang">IllegalStateException</A></CODE> - if this folder is not in the closed state.<DD><CODE><A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></CODE><DT><B>See Also:</B><DD><A HREF="../../javax/mail/event/FolderEvent.html" title="class in javax.mail.event"><CODE>FolderEvent</CODE></A></DL></DD></DL><HR><A NAME="open(int)"><!-- --></A><H3>open</H3><PRE>public abstract void <B>open</B>(int mode) throws <A HREF="../../javax/mail/MessagingException.html" title="class in javax.mail">MessagingException</A></PRE><DL><DD>Open this Folder. This method is valid only on Folders that can contain Messages and that are closed. <p> If this folder is opened successfully, an OPENED ConnectionEvent is delivered to any ConnectionListeners registered on this Folder. <p> The effect of opening multiple connections to the same folder on a specifc Store is implementation dependent. Some implementations allow multiple readers, but only one writer. Others allow multiple writers as well as readers.<P><DD><DL><DT><B>Parameters:</B><DD><CODE>mode</CODE> - open the Folder READ_ONLY or READ_WRITE<DT><B>Throws:</B><DD><CODE><A HREF="../../javax/mail/FolderNotFoundException.html" title="class in javax.mail">FolderNotFoundException</A></CODE
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -