ts.mail
Class MboxAgent
java.lang.Object
|
+--ts.mail.MboxAgent
- All Implemented Interfaces:
- FetchAgent, SafeTerminate
- public class MboxAgent
- extends java.lang.Object
- implements FetchAgent
This Class is a FetchAgent but does not use a mailserver for
fetching mail, instead it fetches mail by reading and parsing a
standard Unix mailbox file (mbox).
The getMail method implements the FetchAgents interface
method getMail. It returns the content of the mailbox file as a
Vector of MailModel objects, where one MailModel represents one
mail message from the mailbox file.
- Version:
- $Id: MboxAgent.java,v 1.11 1999/11/26 00:30:55 hauk Exp $
- Author:
- Jan-Henrik Haukeland <hauk@tildeslash.com>
- See Also:
DefaultMailModel,
FetchAgent
|
Field Summary |
protected java.lang.String |
PROTOCOL
Protocol used by this class |
|
Constructor Summary |
MboxAgent(java.lang.String aMailBoxFile)
Initializes the class with the mailbox filename |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
PROTOCOL
protected final java.lang.String PROTOCOL
- Protocol used by this class
MboxAgent
public MboxAgent(java.lang.String aMailBoxFile)
- Initializes the class with the mailbox filename
- Parameters:
aMailBoxFile - The mail box file to parse for mail messages
canTerminate
public boolean canTerminate()
- Implementation of the SafeTerminate interface
- Specified by:
canTerminate in interface SafeTerminate
- Returns:
- true if it's safe to terminate
getMail
public java.util.Vector getMail()
throws GetMailException
- Implementation of getMail method. This method opens a mailbox file
and read mail messages. Each message is put into a MailModel object.
- Specified by:
getMail in interface FetchAgent
- Returns:
- A Vector with MailModel objects, representing the mbox file
- Throws:
GetMailException - Is thrown if mail for some reason
could not be obtained
stopScan
public void stopScan()
- Stop reading mail
- Specified by:
stopScan in interface FetchAgent
getProtocol
public java.lang.String getProtocol()
- Specified by:
getProtocol in interface FetchAgent
- Returns:
- The protocol used
validateMboxFile
protected void validateMboxFile()
throws GetMailException
- Validate the mbox file. If it's not a regular file or if this
program has no read permission, throw an exception.
If the mailbox file does not exist or size of mailbox is 0, throw
an exception as well, but only with a warning status, because if
the user does not have any mail, the mailbox file will on some
systems not be present.
- Throws:
GetMailException - Is thrown if the mailbox file
is invalid or could not be found