Jacson

de.spieleck.app.jacson.source
Class MailSource

java.lang.Object
  extended byde.spieleck.app.jacson.PluginBase
      extended byde.spieleck.app.jacson.source.ChunkSourceBase
          extended byde.spieleck.app.jacson.source.MailSource
All Implemented Interfaces:
JacsonChunkSource, JacsonReporting, JacsonStately

public class MailSource
extends ChunkSourceBase

This class implements a JacsonChunkSource for emails using.
It supports the POP3 and the IMAP protocolls. When using IMAP processed mails are marked as being seen and at default only unseen mails are processed. So you can avoid double processing by using IMAP. If you have to use POP3 and have to avoid double processing - :( Not possible at the moment. But remember, it's open source :-)
This class needs the JavaMail and the Java activation framework.
Notice that a mail consists of an header and a body. The header contains information like subject, sender or receiver. The body contains the actual text of the mail. To indicate to which part a chunk belongs, the name of the header field or the value of the constant @link MailSouce#BODY is stored within the JacsonState connected to @link MailSource#JACSON_STATE_CHUNK_TYPE.
Furthermore a mail starts with a header so whenever you get a header chunk and the last was a body chunk a new mail began.
For details see RFC 822.

Version:
0.71
Author:
Patrick Carl, fsn

Nested Class Summary
 class MailSource.MessageParserThread
          threaded class for parsing the messages and writing the single lines in a Stack
 
Field Summary
static java.lang.String BODY
          indicates that the current chunk is part of the mail's body
static java.lang.String IMAP
          String constant used to say that MailSource that it should use the IMAP protocoll for receiving mails
static java.lang.String JACSON_STATE_CHUNK_TYPE
          name of the parameter used to indicate the chunk type within JacsonState
static java.lang.String POP3
          String constant used to say that MailSource that it should use the POP3 protocoll for receiving mails
 
Constructor Summary
MailSource(java.lang.String user, java.lang.String password, java.lang.String mailServer)
          Creates a new instance of Pop3Source with the given settings.
MailSource(java.lang.String user, java.lang.String password, java.lang.String mailServer, javax.mail.search.SearchTerm searchTerm)
          A using the given settings but only receives messages that match the given SearchTerm
 
Method Summary
protected  void cleanUp()
          Cleaning up resources
protected  void finalize()
           
static void main(java.lang.String[] args)
          main method for testing functionality
 java.lang.String message()
          implementation analog to LineChunkSource
 java.lang.String nextChunk()
          Deliver a sequence of chunks (that is Strings).
 void setProtocoll(java.lang.String protocoll)
          sets the protocoll used to retrieve emails.
 void startMessageFetching()
          receives the message, filters them and starts a new Thread to parse the Messages
 void summary()
          implementation analog to LineChunkSource
 
Methods inherited from class de.spieleck.app.jacson.PluginBase
getRegReport, getRegState, registerReport, registerState
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface de.spieleck.app.jacson.JacsonStately
registerState
 
Methods inherited from interface de.spieleck.app.jacson.JacsonReporting
registerReport
 

Field Detail

BODY

public static final java.lang.String BODY
indicates that the current chunk is part of the mail's body

See Also:
Constant Field Values

JACSON_STATE_CHUNK_TYPE

public static final java.lang.String JACSON_STATE_CHUNK_TYPE
name of the parameter used to indicate the chunk type within JacsonState

See Also:
Constant Field Values

IMAP

public static final java.lang.String IMAP
String constant used to say that MailSource that it should use the IMAP protocoll for receiving mails

See Also:
Constant Field Values

POP3

public static final java.lang.String POP3
String constant used to say that MailSource that it should use the POP3 protocoll for receiving mails

See Also:
Constant Field Values
Constructor Detail

MailSource

public MailSource(java.lang.String user,
                  java.lang.String password,
                  java.lang.String mailServer)
           throws JacsonException
Creates a new instance of Pop3Source with the given settings. Only those mails are processed which have not set the SEEN flag (does not work with POP3)

Parameters:
user - user of the mailbox read
password - users password at the mailbox read
mailServer - server of the mailbox read

MailSource

public MailSource(java.lang.String user,
                  java.lang.String password,
                  java.lang.String mailServer,
                  javax.mail.search.SearchTerm searchTerm)
           throws JacsonException
A using the given settings but only receives messages that match the given SearchTerm

Parameters:
user - user of the mailbox read
password - users password at the mailbox read
mailServer - server of the mailbox read
searchTerm - a SearchTerm to select messages to read
Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable

cleanUp

protected void cleanUp()
                throws JacsonException
Cleaning up resources

Throws:
JacsonException

setProtocoll

public void setProtocoll(java.lang.String protocoll)
sets the protocoll used to retrieve emails. It the given parameter is not a known protocoll, IMAP will be used instead.


startMessageFetching

public void startMessageFetching()
                          throws JacsonException
receives the message, filters them and starts a new Thread to parse the Messages

Throws:
JacsonException

message

public java.lang.String message()
implementation analog to LineChunkSource


summary

public void summary()
implementation analog to LineChunkSource

Specified by:
summary in interface JacsonReporting
Overrides:
summary in class PluginBase

nextChunk

public java.lang.String nextChunk()
                           throws JacsonException
Deliver a sequence of chunks (that is Strings). The delievered chunks are in the same format which the Message.writeTo(OutputStream os) provides. To indicate the type of the current chunk the JacsonState parameter de.spieleck.app.source.MailSource.ChunkType is set to one of the following values:

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
main method for testing functionality

Throws:
java.lang.Exception

Spieleck

Copyleft 2002 spieleck.de.