|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.mail.Folder
com.sun.mail.mbox.MboxFolder
public class MboxFolder
This class represents a mailbox file containing RFC822 style email messages.
Field Summary |
---|
Fields inherited from class javax.mail.Folder |
---|
HOLDS_FOLDERS, HOLDS_MESSAGES, mode, READ_ONLY, READ_WRITE, store |
Constructor Summary | |
---|---|
MboxFolder(MboxStore store,
java.lang.String name)
|
Method Summary | |
---|---|
void |
appendMessages(javax.mail.Message[] msgs)
Append given Messages to this folder. |
void |
close(boolean expunge)
Close this Folder. |
boolean |
create(int type)
Create this folder on the Store. |
protected javax.mail.Folder |
createFolder(MboxStore store,
java.lang.String name)
Create an MboxFolder object, or a subclass thereof. |
boolean |
delete(boolean recurse)
Delete this Folder. |
boolean |
exists()
Tests if this folder physically exists on the Store. |
javax.mail.Message[] |
expunge()
Expunge (permanently remove) messages marked DELETED. |
javax.mail.Folder |
getFolder(java.lang.String name)
Return the Folder object corresponding to the given name. |
java.lang.String |
getFullName()
Returns the full name of this Folder. |
javax.mail.Message |
getMessage(int msgno)
Get the specified message. |
int |
getMessageCount()
Get total number of messages in this Folder. |
java.lang.String |
getName()
Returns the name of this Folder. |
javax.mail.Folder |
getParent()
Returns the parent folder of this folder. |
javax.mail.Flags |
getPermanentFlags()
Get the permanent flags supported by this Folder. |
char |
getSeparator()
Return the delimiter character that separates this Folder's pathname from the names of immediate subfolders. |
int |
getType()
Returns the type of this Folder, that is, whether this folder can hold messages or subfolders or both. |
protected static java.lang.String |
getUnixFrom(javax.mail.internet.MimeMessage msg)
Construct an appropriately formatted UNIX From line using the sender address and the date in the message. |
javax.mail.URLName |
getURLName()
this is an exact duplicate of the Folder.getURL except it doesn't add a beginning '/' to the URLName. |
boolean |
hasNewMessages()
Returns true if this Folder has new messages since the last time this indication was reset. |
boolean |
isOpen()
Indicates whether this Folder is in the 'open' state. |
javax.mail.Folder[] |
list(java.lang.String pattern)
Returns a list of Folders belonging to this Folder's namespace that match the specified pattern. |
protected javax.mail.Folder[] |
list(java.lang.String ref,
java.lang.String pattern,
boolean fromStore)
|
protected void |
notifyMessageChangedListeners(int type,
javax.mail.Message m)
Notify all MessageChangedListeners. |
void |
open(int mode)
Open this Folder. |
boolean |
renameTo(javax.mail.Folder f)
Rename this Folder. |
protected int |
writeFolder(boolean closing,
boolean expunge)
Re-write the folder with the current contents of the messages. |
static void |
writeMboxMessage(javax.mail.internet.MimeMessage msg,
java.io.OutputStream os)
Write a MimeMessage to the specified OutputStream in a format suitable for a UNIX mailbox, i.e., including a correct Content-Length header and with the local platform's line terminating convention. |
Methods inherited from class javax.mail.Folder |
---|
addConnectionListener, addFolderListener, addMessageChangedListener, addMessageCountListener, copyMessages, fetch, finalize, getDeletedMessageCount, getMessages, getMessages, getMessages, getMode, getNewMessageCount, getStore, getUnreadMessageCount, isSubscribed, list, listSubscribed, listSubscribed, notifyConnectionListeners, notifyFolderListeners, notifyFolderRenamedListeners, notifyMessageAddedListeners, notifyMessageRemovedListeners, removeConnectionListener, removeFolderListener, removeMessageChangedListener, removeMessageCountListener, search, search, setFlags, setFlags, setFlags, setSubscribed, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MboxFolder(MboxStore store, java.lang.String name)
Method Detail |
---|
public char getSeparator()
javax.mail.Folder
getSeparator
in class javax.mail.Folder
public javax.mail.Folder[] list(java.lang.String pattern) throws javax.mail.MessagingException
javax.mail.Folder
"%"
, which matches any character except hierarchy
delimiters, and "*"
, which matches any character. As an example, given the folder hierarchy:
Personal/ Finance/ Stocks Bonus StockOptions Jokes
list("*")
on "Personal" will return the whole
hierarchy. list("%")
on "Personal" will return "Finance" and
"Jokes". list("Jokes")
on "Personal" will return "Jokes".list("Stock*")
on "Finance" will return "Stocks"
and "StockOptions". Folder objects are not cached by the Store, so invoking this method on the same pattern multiple times will return that many distinct Folder objects.
This method can be invoked on a closed Folder.
list
in class javax.mail.Folder
pattern
- the match pattern
javax.mail.MessagingException
Folder.listSubscribed(java.lang.String)
protected javax.mail.Folder[] list(java.lang.String ref, java.lang.String pattern, boolean fromStore) throws javax.mail.MessagingException
javax.mail.MessagingException
public java.lang.String getName()
javax.mail.Folder
This method can be invoked on a closed Folder.
getName
in class javax.mail.Folder
public java.lang.String getFullName()
javax.mail.Folder
This method can be invoked on a closed Folder.
getFullName
in class javax.mail.Folder
public javax.mail.Folder getParent()
javax.mail.Folder
Note that since Folder objects are not cached, invoking this method returns a new distinct Folder object.
getParent
in class javax.mail.Folder
public boolean exists()
javax.mail.Folder
exists
in class javax.mail.Folder
Folder.create(int)
public int getType()
javax.mail.Folder
getType
in class javax.mail.Folder
Folder.HOLDS_FOLDERS
,
Folder.HOLDS_MESSAGES
public javax.mail.Flags getPermanentFlags()
javax.mail.Folder
The special flag Flags.USER
indicates that this Folder
supports arbitrary user-defined flags.
The supported permanent flags for a folder may not be available until the folder is opened.
getPermanentFlags
in class javax.mail.Folder
public boolean hasNewMessages()
javax.mail.Folder
RECENT
flag set. 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.
This method can be invoked on a closed Folder that can contain Messages.
hasNewMessages
in class javax.mail.Folder
public javax.mail.Folder getFolder(java.lang.String name) throws javax.mail.MessagingException
javax.mail.Folder
exists()
method on a Folder indicates whether it really
exists on the Store. In some Stores, name can be an absolute path if it starts with the hierarchy delimiter. Otherwise, it is interpreted relative to this Folder.
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.
This method can be invoked on a closed Folder.
getFolder
in class javax.mail.Folder
name
- name of the Folder
javax.mail.MessagingException
public boolean create(int type) throws javax.mail.MessagingException
javax.mail.Folder
If the creation is successful, a CREATED FolderEvent is delivered to any FolderListeners registered on this Folder and this Store.
create
in class javax.mail.Folder
type
- The type of this folder.
javax.mail.MessagingException
Folder.HOLDS_FOLDERS
,
Folder.HOLDS_MESSAGES
,
FolderEvent
public boolean delete(boolean recurse) throws javax.mail.MessagingException
javax.mail.Folder
The recurse
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:
If the folder contains subfolders there are 3 possible choices an implementation is free to do:
delete
in class javax.mail.Folder
javax.mail.MessagingException
FolderEvent
public boolean renameTo(javax.mail.Folder f) throws javax.mail.MessagingException
javax.mail.Folder
If the rename is successful, a RENAMED FolderEvent is delivered to FolderListeners registered on this folder and its containing Store.
renameTo
in class javax.mail.Folder
f
- a folder representing the new name for this Folder
javax.mail.MessagingException
FolderEvent
public boolean isOpen()
javax.mail.Folder
isOpen
in class javax.mail.Folder
public void open(int mode) throws javax.mail.MessagingException
javax.mail.Folder
If this folder is opened successfully, an OPENED ConnectionEvent is delivered to any ConnectionListeners registered on this Folder.
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.
open
in class javax.mail.Folder
mode
- open the Folder READ_ONLY or READ_WRITE
javax.mail.MessagingException
Folder.READ_ONLY
,
Folder.READ_WRITE
,
Folder.getType()
,
ConnectionEvent
public void close(boolean expunge) throws javax.mail.MessagingException
javax.mail.Folder
A CLOSED ConnectionEvent is delivered to any ConnectionListeners registered on this Folder. Note that the folder is closed even if this method terminates abnormally by throwing a MessagingException.
close
in class javax.mail.Folder
expunge
- expunges all deleted messages if this flag is true
javax.mail.MessagingException
ConnectionEvent
protected int writeFolder(boolean closing, boolean expunge) throws java.io.IOException, javax.mail.MessagingException
java.io.IOException
javax.mail.MessagingException
public static void writeMboxMessage(javax.mail.internet.MimeMessage msg, java.io.OutputStream os) throws java.io.IOException, javax.mail.MessagingException
If the message is really a MboxMessage, use its writeToFile method, which has access to the UNIX From line. Otherwise, do all the work here, creating an appropriate UNIX From line.
java.io.IOException
javax.mail.MessagingException
protected static java.lang.String getUnixFrom(javax.mail.internet.MimeMessage msg)
public int getMessageCount() throws javax.mail.MessagingException
javax.mail.Folder
This method can be invoked on a closed folder. However, note that for some folder implementations, getting the total message count can be an expensive operation involving actually opening the folder. In such cases, a provider can choose not to support this functionality in the closed state, in which case this method must return -1.
Clients invoking this method on a closed folder must be aware that this is a potentially expensive operation. Clients must also be prepared to handle a return value of -1 in this case.
getMessageCount
in class javax.mail.Folder
javax.mail.MessagingException
public javax.mail.Message getMessage(int msgno) throws javax.mail.MessagingException
getMessage
in class javax.mail.Folder
msgno
- the message number
javax.mail.MessagingException
Folder.getMessageCount()
,
Folder.fetch(javax.mail.Message[], javax.mail.FetchProfile)
public void appendMessages(javax.mail.Message[] msgs) throws javax.mail.MessagingException
javax.mail.Folder
Folder implementations must not abort this operation if a Message in the given message array turns out to be an expunged Message.
appendMessages
in class javax.mail.Folder
msgs
- array of Messages to be appended
javax.mail.MessagingException
- if the append failed.public javax.mail.Message[] expunge() throws javax.mail.MessagingException
javax.mail.Folder
getMessageNumber
method
on each of these message objects returns that Message's original
(that is, prior to the expunge) sequence number. A MessageCountEvent
containing the expunged messages is delivered to any
MessageCountListeners registered on the folder. Expunge causes the renumbering of Message objects subsequent to the expunged messages. Clients that use message numbers as references to messages should be aware of this and should be prepared to deal with the situation (probably by flushing out existing message number caches and reloading them). Because of this complexity, it is better for clients to use Message objects as references to messages, rather than message numbers. Any expunged Messages objects still have to be pruned, but other Messages in that folder are not affected by the expunge.
After a message is expunged, only the isExpunged
and
getMessageNumber
methods are still valid on the
corresponding Message object; other methods may throw
MessageRemovedException
expunge
in class javax.mail.Folder
javax.mail.MessagingException
Message.isExpunged()
,
MessageCountEvent
protected void notifyMessageChangedListeners(int type, javax.mail.Message m)
javax.mail.Folder
The provided implementation queues the event into an internal event queue. An event dispatcher thread dequeues events from the queue and dispatches them to registered MessageChangedListeners. Note that the event dispatching occurs in a separate thread, thus avoiding potential deadlock problems.
notifyMessageChangedListeners
in class javax.mail.Folder
public javax.mail.URLName getURLName()
getURLName
in class javax.mail.Folder
URLName
protected javax.mail.Folder createFolder(MboxStore store, java.lang.String name)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |