ejel
Class InboxEmailsReader

java.lang.Object
  extended by ejel.InboxEmailsReader
All Implemented Interfaces:
java.lang.Iterable

public class InboxEmailsReader
extends java.lang.Object
implements java.lang.Iterable

InboxEmailsReader is class that will help Java application projects check email accounts used to send mass mailing for incoming email messages to update the mailing list. For example, after a mass mailing operation, you have to check SMTP Servers results for undelivered emails to update an email address status so as not to waste time sending further emails that will never reach recipients


Constructor Summary
InboxEmailsReader(EmailAccount account, java.lang.String exp, boolean isRegEx, javax.mail.Flags flags)
          Constructs a new InboxEmailsReader object
 
Method Summary
 void asyncConnect()
          A non blocking connect version to the server.
 void asyncIterator()
          Asynchronous function that will iterate the email messages in the inbox folder searching for the ones that matches expression member variable search query.
 void close()
          External code must call this function after a successful connection so as to free system resources
 boolean connect()
          Blocking function that will try to connect to the server
 EmailAccount getEmailAccount()
          Gets the EmailAccount object holding login information to the server
 java.lang.Exception getException()
          Gets an Exception object if failed to connect to server, otherwise null
 java.lang.String getSearchExpression()
          Gets the search expression used to filter the email messages in the inbox folder
 javax.mail.Flags getSearchFlags()
          Gets the flags that must be set on a Message object to be included in the search process
 boolean isConnected()
          Check if the object is now connected to the server
 boolean isIterating()
          Gets true if a search thread is now running
 boolean isNowConnecting()
          Gets true if an attempt to connect is now running
 boolean isRegularExpression()
          Gets true if the exp param passed to the constructor is a regular expression or a contains search query
 java.util.Iterator iterator()
           
 void registerEventListener(EventManager.EventID evtId, EventListener listener)
          Register a listener object that will receive events when they're raised
 void unregisterEventListener(EventManager.EventID evtId, EventListener listener)
          Unregister a listener object that will never receive events after the call
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InboxEmailsReader

public InboxEmailsReader(EmailAccount account,
                         java.lang.String exp,
                         boolean isRegEx,
                         javax.mail.Flags flags)
                  throws java.lang.IllegalArgumentException
Constructs a new InboxEmailsReader object

Parameters:
account - The EmailAccount object containing information for logging to the server
exp - The contains or regular expression search query for email messages
isRegEx - Set to true if exp param contains a regular expression, false if it's a contains expression
flags - Set to flags that will be set on the Message object to include it in the search process
Throws:
java.lang.IllegalArgumentException
Method Detail

asyncIterator

public void asyncIterator()
Asynchronous function that will iterate the email messages in the inbox folder searching for the ones that matches expression member variable search query. If the isRegEx constructor param is true, this function will search for email messages whose subject matches the regular expression defined in the expression param of the constructor, otherwise this function will do a contains search in every email message subject to see if it matches the search query. For every email message found, the function will raise the EventID.EID_NEXT_INBOX_EMAIL event for registered listeners

See Also:
registerEventListener()

registerEventListener

public void registerEventListener(EventManager.EventID evtId,
                                  EventListener listener)
Register a listener object that will receive events when they're raised

Parameters:
evtId - The event ID to register for
listener - The listener object to register. It must implement The ejel.EventListener interface
See Also:
EventListener

unregisterEventListener

public void unregisterEventListener(EventManager.EventID evtId,
                                    EventListener listener)
Unregister a listener object that will never receive events after the call

Parameters:
evtId - The event ID to unregister from
listener - The listener object to unregister. It must implement the ejel.EventListener interface to register
See Also:
EventListener

connect

public boolean connect()
Blocking function that will try to connect to the server

Returns:
true if the connection is a success

asyncConnect

public void asyncConnect()
A non blocking connect version to the server.

See Also:
nowConnecting

close

public void close()
External code must call this function after a successful connection so as to free system resources


iterator

public java.util.Iterator iterator()
Specified by:
iterator in interface java.lang.Iterable

isIterating

public boolean isIterating()
Gets true if a search thread is now running

Returns:
true if a search thread is now running
See Also:
asyncIterate()

isConnected

public boolean isConnected()
Check if the object is now connected to the server

Returns:
true if the object is now connected to the server

getSearchFlags

public javax.mail.Flags getSearchFlags()
Gets the flags that must be set on a Message object to be included in the search process

Returns:
The flags that must be set on a Message object to be included in the search process
See Also:
Flags

isRegularExpression

public boolean isRegularExpression()
Gets true if the exp param passed to the constructor is a regular expression or a contains search query

Returns:
true if the exp param passed to the constructor is a regular expression or a contains search query

getSearchExpression

public java.lang.String getSearchExpression()
Gets the search expression used to filter the email messages in the inbox folder

Returns:
The search expression used to filter the email messages in the inbox folder

getEmailAccount

public EmailAccount getEmailAccount()
Gets the EmailAccount object holding login information to the server

Returns:
The EmailAccount object holding login information to the server

isNowConnecting

public boolean isNowConnecting()
Gets true if an attempt to connect is now running

Returns:
true if an attempt to connect is now running

getException

public java.lang.Exception getException()
Gets an Exception object if failed to connect to server, otherwise null

Returns:
An Exception object if failed to connect to server, otherwise null