org.apache.geronimo.javamail.store.pop3
Class POP3Message

java.lang.Object
  extended by javax.mail.Message
      extended by javax.mail.internet.MimeMessage
          extended by org.apache.geronimo.javamail.store.pop3.POP3Message
All Implemented Interfaces:
MimePart, Part

public class POP3Message
extends MimeMessage

POP3 implementation of javax.mail.internet.MimeMessage Only the most basic information is given and Message objects created here is a light-weight reference to the actual Message As per the JavaMail spec items from the actual message will get filled up on demand If some other items are obtained from the server as a result of one call, then the other details are also processed and filled in. For ex if RETR is called then header information will also be processed in addition to the content

Version:
$Rev: 597135 $ $Date: 2007-11-21 11:26:57 -0500 (Wed, 21 Nov 2007) $

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.mail.internet.MimeMessage
MimeMessage.RecipientType
 
Field Summary
protected  int headerSize
           
protected  byte[] messageData
           
protected  int msgSize
           
protected  String uid
           
 
Fields inherited from class javax.mail.internet.MimeMessage
content, contentStream, dh, flags, headers, modified, saved
 
Fields inherited from class javax.mail.Message
expunged, folder, msgnum, session
 
Fields inherited from interface javax.mail.Part
ATTACHMENT, INLINE
 
Constructor Summary
protected POP3Message(Folder folder, int msgnum)
          Create a new POP3 message associated with a folder.
 
Method Summary
 void addHeader(String name, String value)
           
 void addHeaderLine(String line)
           
 Enumeration getAllHeaderLines()
           
 Enumeration getAllHeaders()
           
protected  POP3Connection getConnection()
          get the current connection pool attached to the folder.
protected  InputStream getContentStream()
          Get an InputStream for reading the message content.
 String[] getHeader(String name)
           
 String getHeader(String name, String delimiter)
           
 Enumeration getMatchingHeaderLines(String[] names)
           
 Enumeration getMatchingHeaders(String[] names)
           
 Enumeration getNonMatchingHeaderLines(String[] names)
           
 Enumeration getNonMatchingHeaders(String[] names)
           
 int getSize()
          Get the size of the message.
protected  String getUID()
          Retrieve the message UID from the server.
protected  void loadContent()
          Lazy loading of the message content.
protected  void loadContent(ByteArrayInputStream stream)
          Load the message content from the server.
protected  void loadHeaders()
          notice that we pass zero as the no of lines from the message,as it doesn't serv any purpose to get only a certain number of lines.
protected  void loadHeaders(InputStream in)
          Unconditionally load the headers from an inputstream.
protected  void releaseConnection(POP3Connection connection)
          Release the connection back to the Folder after performing an operation that requires a connection.
 void removeHeader(String name)
           
 void saveChanges()
          We cannot modify these messages
 void setFlags(Flags newFlags, boolean set)
          Set a flag value for this Message.
 void setHeader(String name, String value)
           
 void writeTo(OutputStream out)
          Write out the byte data to the provided output stream.
 
Methods inherited from class javax.mail.internet.MimeMessage
addFrom, addRecipients, addRecipients, createInternetHeaders, createMimeMessage, getAllRecipients, getContent, getContentID, getContentLanguage, getContentMD5, getContentType, getDataHandler, getDescription, getDisposition, getEncoding, getFileName, getFlags, getFrom, getInputStream, getLineCount, getMessageID, getRawInputStream, getReceivedDate, getRecipients, getReplyTo, getSender, getSentDate, getSubject, isMimeType, isSet, parse, reply, setContent, setContent, setContentID, setContentLanguage, setContentMD5, setDataHandler, setDescription, setDescription, setDisposition, setFileName, setFrom, setFrom, setRecipients, setRecipients, setReplyTo, setSender, setSentDate, setSubject, setSubject, setText, setText, setText, updateHeaders, updateMessageID, writeTo
 
Methods inherited from class javax.mail.Message
addRecipient, getFolder, getMessageNumber, isExpunged, match, setExpunged, setFlag, setMessageNumber, setRecipient
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

msgSize

protected int msgSize

headerSize

protected int headerSize

uid

protected String uid

messageData

protected byte[] messageData
Constructor Detail

POP3Message

protected POP3Message(Folder folder,
                      int msgnum)
Create a new POP3 message associated with a folder.

Parameters:
folder - The owning folder.
msgnum - The message sequence number in the folder.
Method Detail

getContentStream

protected InputStream getContentStream()
                                throws MessagingException
Get an InputStream for reading the message content.

Overrides:
getContentStream in class MimeMessage
Returns:
An InputStream instance initialized to read the message content.
Throws:
MessagingException

writeTo

public void writeTo(OutputStream out)
             throws IOException,
                    MessagingException
Write out the byte data to the provided output stream.

Specified by:
writeTo in interface Part
Overrides:
writeTo in class MimeMessage
Parameters:
out - The target stream.
Throws:
IOException
MessagingException

setFlags

public void setFlags(Flags newFlags,
                     boolean set)
              throws MessagingException
Set a flag value for this Message. The flags are only set locally, not the server. When the folder is closed, any messages with the Deleted flag set will be removed from the server.

Overrides:
setFlags in class MimeMessage
Parameters:
newFlags - The new flag values.
set - Indicates whether this is a set or an unset operation.
Throws:
MessagingException

loadHeaders

protected void loadHeaders(InputStream in)
                    throws MessagingException
Unconditionally load the headers from an inputstream. When retrieving content, we get back the entire message, including the headers. This allows us to skip over them to reach the content, even if we already have headers loaded.

Parameters:
in - The InputStream with the header data.
Throws:
MessagingException

loadContent

protected void loadContent()
                    throws MessagingException
Lazy loading of the message content.

Throws:
MessagingException

loadContent

protected void loadContent(ByteArrayInputStream stream)
                    throws MessagingException
Load the message content from the server.

Parameters:
stream - A ByteArrayInputStream containing the message content. We explicitly use ByteArrayInputStream because there are some optimizations that can take advantage of the fact it is such a stream.
Throws:
MessagingException

getSize

public int getSize()
            throws MessagingException
Get the size of the message.

Specified by:
getSize in interface Part
Overrides:
getSize in class MimeMessage
Returns:
The calculated message size, in bytes.
Throws:
MessagingException

loadHeaders

protected void loadHeaders()
                    throws MessagingException
notice that we pass zero as the no of lines from the message,as it doesn't serv any purpose to get only a certain number of lines. However this maybe important if a mail client only shows 3 or 4 lines of the message in the list and then when the user clicks they would load the message on demand.

Throws:
MessagingException

getUID

protected String getUID()
                 throws MessagingException
Retrieve the message UID from the server.

Returns:
The string UID value.
Throws:
MessagingException

getHeader

public String[] getHeader(String name)
                   throws MessagingException
Specified by:
getHeader in interface Part
Overrides:
getHeader in class MimeMessage
Throws:
MessagingException

getHeader

public String getHeader(String name,
                        String delimiter)
                 throws MessagingException
Specified by:
getHeader in interface MimePart
Overrides:
getHeader in class MimeMessage
Throws:
MessagingException

getAllHeaders

public Enumeration getAllHeaders()
                          throws MessagingException
Specified by:
getAllHeaders in interface Part
Overrides:
getAllHeaders in class MimeMessage
Throws:
MessagingException

getMatchingHeaders

public Enumeration getMatchingHeaders(String[] names)
                               throws MessagingException
Specified by:
getMatchingHeaders in interface Part
Overrides:
getMatchingHeaders in class MimeMessage
Throws:
MessagingException

getNonMatchingHeaders

public Enumeration getNonMatchingHeaders(String[] names)
                                  throws MessagingException
Specified by:
getNonMatchingHeaders in interface Part
Overrides:
getNonMatchingHeaders in class MimeMessage
Throws:
MessagingException

getAllHeaderLines

public Enumeration getAllHeaderLines()
                              throws MessagingException
Specified by:
getAllHeaderLines in interface MimePart
Overrides:
getAllHeaderLines in class MimeMessage
Throws:
MessagingException

getMatchingHeaderLines

public Enumeration getMatchingHeaderLines(String[] names)
                                   throws MessagingException
Specified by:
getMatchingHeaderLines in interface MimePart
Overrides:
getMatchingHeaderLines in class MimeMessage
Throws:
MessagingException

getNonMatchingHeaderLines

public Enumeration getNonMatchingHeaderLines(String[] names)
                                      throws MessagingException
Specified by:
getNonMatchingHeaderLines in interface MimePart
Overrides:
getNonMatchingHeaderLines in class MimeMessage
Throws:
MessagingException

addHeader

public void addHeader(String name,
                      String value)
               throws MessagingException
Specified by:
addHeader in interface Part
Overrides:
addHeader in class MimeMessage
Throws:
MessagingException

setHeader

public void setHeader(String name,
                      String value)
               throws MessagingException
Specified by:
setHeader in interface Part
Overrides:
setHeader in class MimeMessage
Throws:
MessagingException

removeHeader

public void removeHeader(String name)
                  throws MessagingException
Specified by:
removeHeader in interface Part
Overrides:
removeHeader in class MimeMessage
Throws:
MessagingException

addHeaderLine

public void addHeaderLine(String line)
                   throws MessagingException
Specified by:
addHeaderLine in interface MimePart
Overrides:
addHeaderLine in class MimeMessage
Throws:
MessagingException

saveChanges

public void saveChanges()
                 throws MessagingException
We cannot modify these messages

Overrides:
saveChanges in class MimeMessage
Throws:
MessagingException

getConnection

protected POP3Connection getConnection()
                                throws MessagingException
get the current connection pool attached to the folder. We need to do this dynamically, to A) ensure we're only accessing an currently open folder, and B) to make sure we're using the correct connection attached to the folder.

Returns:
A connection attached to the hosting folder.
Throws:
MessagingException

releaseConnection

protected void releaseConnection(POP3Connection connection)
                          throws MessagingException
Release the connection back to the Folder after performing an operation that requires a connection.

Parameters:
connection - The previously acquired connection.
Throws:
MessagingException


Copyright © 2003-2009 The Apache Software Foundation. All Rights Reserved.