public class

POP3Message

extends MimeMessage
java.lang.Object
   ↳ com.google.code.javax.mail.Message
     ↳ com.google.code.javax.mail.internet.MimeMessage
       ↳ com.google.code.com.sun.mail.pop3.POP3Message

Class Overview

A POP3 Message. Just like a MimeMessage except that some things are not supported.

Summary

Constants
String UNKNOWN
[Expand]
Inherited Constants
From interface com.google.code.javax.mail.Part
Fields
private SoftReference contentData
private POP3Folder folder
private int hdrSize
private int msgSize
String uid
[Expand]
Inherited Fields
From class com.google.code.javax.mail.internet.MimeMessage
From class com.google.code.javax.mail.Message
Public Constructors
POP3Message(Folder folder, int msgno)
Public Methods
void addHeader(String name, String value)
Add this value to the existing values for this header_name.
void addHeaderLine(String line)
Add a raw RFC822 header-line.
Enumeration getAllHeaderLines()
Get all header lines as an Enumeration of Strings.
Enumeration getAllHeaders()
Return all the headers from this Message as an enumeration of Header objects.
String getHeader(String name, String delimiter)
Get all the headers for this header name, returned as a single String, with headers separated by the delimiter.
String[] getHeader(String name)
Get all the headers for this header_name.
Enumeration getMatchingHeaderLines(String[] names)
Get matching header lines as an Enumeration of Strings.
Enumeration getMatchingHeaders(String[] names)
Return matching headers from this Message as an Enumeration of Header objects.
Enumeration getNonMatchingHeaderLines(String[] names)
Get non-matching header lines as an Enumeration of Strings.
Enumeration getNonMatchingHeaders(String[] names)
Return non-matching headers from this Message as an Enumeration of Header objects.
int getSize()
Return the size of the content of this message in bytes.
synchronized void invalidate(boolean invalidateHeaders)
Invalidate the cache of content for this message object, causing it to be fetched again from the server the next time it is needed.
void removeHeader(String name)
Remove all headers with this name.
void saveChanges()
POP3 message can't be changed.
void setFlags(Flags newFlags, boolean set)
Set the specified flags on this message to the specified value.
void setHeader(String name, String value)
Set the value for this header_name.
InputStream top(int n)
Fetch the header of the message and the first n lines of the raw content of the message.
synchronized void writeTo(OutputStream os, String[] ignoreList)
Output the message as an RFC 822 format stream, without specified headers.
Protected Methods
InputStream getContentStream()
Produce the raw bytes of the content.
[Expand]
Inherited Methods
From class com.google.code.javax.mail.internet.MimeMessage
From class com.google.code.javax.mail.Message
From class java.lang.Object
From interface com.google.code.javax.mail.HasRawInputStream
From interface com.google.code.javax.mail.Part
From interface com.google.code.javax.mail.internet.MimePart

Constants

static final String UNKNOWN

Constant Value: "UNKNOWN"

Fields

private SoftReference contentData

private POP3Folder folder

private int hdrSize

private int msgSize

String uid

Public Constructors

public POP3Message (Folder folder, int msgno)

Parameters
folder
msgno

Public Methods

public void addHeader (String name, String value)

Add this value to the existing values for this header_name. Throws IllegalWriteException because POP3 messages are read-only.

Parameters
name Header name
value Header value
Throws
IllegalWriteException because the underlying implementation does not support modification
IllegalStateException if this message is obtained from a READ_ONLY folder.
MessagingException
See Also
  • javax.mail.internet.MimeUtility

public void addHeaderLine (String line)

Add a raw RFC822 header-line. Throws IllegalWriteException because POP3 messages are read-only.

Parameters
line
Throws
IllegalWriteException because the underlying implementation does not support modification
IllegalStateException if this message is obtained from a READ_ONLY folder.
MessagingException

public Enumeration getAllHeaderLines ()

Get all header lines as an Enumeration of Strings. A Header line is a raw RFC822 header-line, containing both the "name" and "value" field.

public Enumeration getAllHeaders ()

Return all the headers from this Message as an enumeration of Header objects.

Note that certain headers may be encoded as per RFC 2047 if they contain non US-ASCII characters and these should be decoded.

Returns
  • array of header objects
See Also
  • javax.mail.internet.MimeUtility

public String getHeader (String name, String delimiter)

Get all the headers for this header name, returned as a single String, with headers separated by the delimiter. If the delimiter is null, only the first header is returned.

Parameters
name The name of this header
delimiter Delimiter between returned headers
Returns
  • the value fields for all headers with this name

public String[] getHeader (String name)

Get all the headers for this header_name. Note that certain headers may be encoded as per RFC 2047 if they contain non US-ASCII characters and these should be decoded.

Parameters
name Name of header
Returns
  • array of headers
See Also
  • javax.mail.internet.MimeUtility

public Enumeration getMatchingHeaderLines (String[] names)

Get matching header lines as an Enumeration of Strings. A Header line is a raw RFC822 header-line, containing both the "name" and "value" field.

Parameters
names

public Enumeration getMatchingHeaders (String[] names)

Return matching headers from this Message as an Enumeration of Header objects.

Parameters
names
Returns
  • enumeration of Header objects

public Enumeration getNonMatchingHeaderLines (String[] names)

Get non-matching header lines as an Enumeration of Strings. A Header line is a raw RFC822 header-line, containing both the "name" and "value" field.

Parameters
names

public Enumeration getNonMatchingHeaders (String[] names)

Return non-matching headers from this Message as an Enumeration of Header objects.

Parameters
names
Returns
  • enumeration of Header objects

public int getSize ()

Return the size of the content of this message in bytes. Returns -1 if the size cannot be determined.

Note that this number may not be an exact measure of the content size and may or may not account for any transfer encoding of the content.

Returns
  • size of content in bytes

public synchronized void invalidate (boolean invalidateHeaders)

Invalidate the cache of content for this message object, causing it to be fetched again from the server the next time it is needed. If invalidateHeaders is true, invalidate the headers as well.

Parameters
invalidateHeaders Invalidate the headers as well?

public void removeHeader (String name)

Remove all headers with this name. Throws IllegalWriteException because POP3 messages are read-only.

Parameters
name The name of this header
Throws
IllegalWriteException because the underlying implementation does not support modification
IllegalStateException if this message is obtained from a READ_ONLY folder.
MessagingException

public void saveChanges ()

POP3 message can't be changed. This method throws IllegalWriteException.

Throws
IllegalWriteException because the underlying implementation does not support modification
MessagingException

public void setFlags (Flags newFlags, boolean set)

Set the specified flags on this message to the specified value.

Parameters
newFlags The flags to be set
set The value to be set

public void setHeader (String name, String value)

Set the value for this header_name. Throws IllegalWriteException because POP3 messages are read-only.

Parameters
name Header name
value Header value
Throws
IllegalWriteException because the underlying implementation does not support modification
IllegalStateException if this message is obtained from a READ_ONLY folder.
MessagingException
See Also
  • javax.mail.internet.MimeUtility

public InputStream top (int n)

Fetch the header of the message and the first n lines of the raw content of the message. The headers and data are available in the returned InputStream.

Parameters
n Number of lines of content to fetch
Returns
  • InputStream containing the message headers and n content lines

public synchronized void writeTo (OutputStream os, String[] ignoreList)

Output the message as an RFC 822 format stream, without specified headers. If the property "mail.pop3.cachewriteto" is set to "true", and ignoreList is null, and the message hasn't already been cached as a side effect of other operations, the message content is cached before being written. Otherwise, the message is streamed directly to the output stream without being cached.

Parameters
os
ignoreList
Throws
IOException if an error occurs writing to the stream or if an error is generated by the javax.activation layer.
MessagingException

Protected Methods

protected InputStream getContentStream ()

Produce the raw bytes of the content. The data is fetched using the POP3 RETR command.

See Also