TsBiff 1.3


ts.biff
Class Controller

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--ts.biff.Controller
All Implemented Interfaces:
java.lang.Runnable

public class Controller
extends java.lang.Thread

This class uses a FetchAgent e.g. a POP3 agent to repeatly scan a users mailbox for changes. When there is a change in the mailbox, this controller will notify any MailEvent listeners by firing a MailEvent.

Version:
$Id: Controller.java,v 1.20 1999/11/28 06:02:59 hauk Exp $
Author:
Jan-Henrik Haukeland
See Also:
Model

Field Summary
protected  javax.swing.event.EventListenerList listenerList
          A list holding MailListeners
protected  FetchAgent myAgent
          The Fetch Agent used to scan mailbox messages
protected  java.util.Vector myMailFields
          A vector holding mail fields of interest
protected  java.util.Vector myMailModels
          A vector holding "raw" MailModel objects from last scan
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Controller(FetchAgent anAgent)
          Instantiate the controller.
 
Method Summary
 void addMailListener(MailListener aMailListener)
          Adds a MailListener.
protected  void fireMailEvent(MailEvent m)
           
 java.util.Vector getMail()
          Returns a vector with mail messages from the last scan
 MailModel getMailModel(java.lang.String id)
          Returns the MailModel with the submitted id
protected  void handleMessages(java.util.Vector v)
          Fire a new MailEvent if and only if the new mail vector is different from the previous one.
 void removeMailListener(MailListener aMailListener)
          Removes a MailListener
 void run()
          Use the FetchAgent to scan for new Mail messages in a low priority Threaded loop
 void terminate()
          Stop this thread
 void wakeUp()
          Interrupt the sleep between each mail scan
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myAgent

protected FetchAgent myAgent
The Fetch Agent used to scan mailbox messages

listenerList

protected javax.swing.event.EventListenerList listenerList
A list holding MailListeners

myMailFields

protected java.util.Vector myMailFields
A vector holding mail fields of interest

myMailModels

protected java.util.Vector myMailModels
A vector holding "raw" MailModel objects from last scan
Constructor Detail

Controller

public Controller(FetchAgent anAgent)
Instantiate the controller.
Parameters:
anAgent - A FetchAgent that is used to retrieve mail messages
Method Detail

terminate

public void terminate()
Stop this thread

run

public void run()
Use the FetchAgent to scan for new Mail messages in a low priority Threaded loop
Overrides:
run in class java.lang.Thread

wakeUp

public void wakeUp()
Interrupt the sleep between each mail scan

getMail

public java.util.Vector getMail()
Returns a vector with mail messages from the last scan
Returns:
a Vector with mail messages

getMailModel

public MailModel getMailModel(java.lang.String id)
Returns the MailModel with the submitted id
Parameters:
id - a Mail message id
Returns:
a MailModel for the submitted id or null if not found

addMailListener

public void addMailListener(MailListener aMailListener)
Adds a MailListener.
Parameters:
aMailListener - A mail listener object

removeMailListener

public void removeMailListener(MailListener aMailListener)
Removes a MailListener
Parameters:
aMailListener - An mail listener object

fireMailEvent

protected void fireMailEvent(MailEvent m)

handleMessages

protected void handleMessages(java.util.Vector v)
Fire a new MailEvent if and only if the new mail vector is different from the previous one.
Parameters:
v - a Vector with mail models from the latest scan

TsBiff 1.3