totalcross.net.mail
Class Folder

totalcross.lang.Object
  extended by totalcross.net.mail.Folder
Direct Known Subclasses:
POP3Folder

public abstract class Folder
extends totalcross.lang.Object

Folder is an abstract class that represents a folder for mail messages. Subclasses implement protocol specific Folders.

Since:
TotalCross 1.13

Field Summary
protected  int deletedMessageCount
           
protected  Hashtable expungedMessages
           
protected  int HEADER_BUFFER_SIZE
           
protected  int messageCount
           
protected  Hashtable messagesByNumber
           
protected  Hashtable messagesByUidl
           
protected  byte[] msgHeaderBuffer
           
protected  Store store
           
 
Constructor Summary
protected Folder(Store store)
          Constructor that takes a Store object.
 
Method Summary
 void close(boolean b)
          Close this Folder.
 int getDeleteMessageCount()
           
abstract  Message getMessage(int msgnum)
          Get the Message object corresponding to the given message number.
abstract  Message getMessage(String uidl)
           
 int getMessageCount()
          Get total number of messages in this Folder.
 Message[] getMessages()
          Get all Message objects from this Folder.
 Message[] getMessages(int start, int end)
          Get the Message objects for message numbers ranging from start through end, both start and end inclusive.
abstract  void open()
          Open this Folder.
abstract  void reset()
          Reset this session, undoing any operations performed over messages on this folder during this session.
 
Methods inherited from class totalcross.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

store

protected Store store

messagesByUidl

protected Hashtable messagesByUidl

messagesByNumber

protected Hashtable messagesByNumber

expungedMessages

protected Hashtable expungedMessages

messageCount

protected int messageCount

deletedMessageCount

protected int deletedMessageCount

HEADER_BUFFER_SIZE

protected int HEADER_BUFFER_SIZE

msgHeaderBuffer

protected byte[] msgHeaderBuffer
Constructor Detail

Folder

protected Folder(Store store)
Constructor that takes a Store object.

Parameters:
store - the Store that holds this folder
Since:
TotalCross 1.13
Method Detail

open

public abstract void open()
                   throws MessagingException
Open this Folder. This method is valid only on Folders that can contain Messages and that are closed.

Throws:
MessagingException
Since:
TotalCross 1.13

getMessageCount

public int getMessageCount()
                    throws MessagingException
Get total number of messages in this 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.

Returns:
total number of messages. -1 may be returned by certain implementations if this method is invoked on a closed folder.
Throws:
MessagingException
Since:
TotalCross 1.13

getDeleteMessageCount

public int getDeleteMessageCount()
                          throws MessagingException
Throws:
MessagingException

getMessages

public Message[] getMessages()
                      throws MessagingException
Get all Message objects from this Folder. Returns an empty array if the folder is empty. Clients can use Message objects (instead of sequence numbers) as references to the messages within a folder; this method supplies the Message objects to the client. Folder implementations are expected to provide light-weight Message objects, which get filled on demand. This implementation invokes uses getMessage() to get Message objects from 1 till the message count.

Returns:
array of Message objects, empty array if folder is empty.
Throws:
MessagingException
Since:
TotalCross 1.13

getMessages

public Message[] getMessages(int start,
                             int end)
                      throws MessagingException
Get the Message objects for message numbers ranging from start through end, both start and end inclusive. Note that message numbers start at 1, not 0. Message objects are light-weight references to the actual message that get filled up on demand. Hence Folder implementations are expected to provide light-weight Message objects. This implementation uses getMessage(index) to obtain the required Message objects. Note that the returned array must contain (end-start+1) Message objects.

Parameters:
start -
end -
Returns:
The Message array
Throws:
MessagingException
Since:
TotalCross 1.13

getMessage

public abstract Message getMessage(int msgnum)
                            throws MessagingException
Get the Message object corresponding to the given message number. A Message object's message number is the relative position of this Message in its Folder. Messages are numbered starting at 1 through the total number of message in the folder. Note that the message number for a particular Message can change during a session if other messages in the Folder are deleted and the Folder is expunged. Message objects are light-weight references to the actual message that get filled up on demand. Hence Folder implementations are expected to provide light-weight Message objects. Unlike Folder objects, repeated calls to getMessage with the same message number will return the same Message object, as long as no messages in this folder have been expunged. Since message numbers can change within a session if the folder is expunged, clients are advised not to use message numbers as references to messages. Use Message objects instead.

Parameters:
msgnum - the message number
Returns:
the Message object
Throws:
MessagingException
Since:
TotalCross 1.13

getMessage

public abstract Message getMessage(String uidl)
                            throws MessagingException
Throws:
MessagingException

reset

public abstract void reset()
                    throws MessagingException
Reset this session, undoing any operations performed over messages on this folder during this session.

Throws:
MessagingException
Since:
TotalCross 1.13

close

public void close(boolean b)
Close this Folder. This method is valid only on open Folders.

Parameters:
b -
Since:
TotalCross 1.13