gnu.mail.providers.nntp

Class NNTPMessage

Implemented Interfaces:
MimePart, Part

public final class NNTPMessage
extends MimeMessage

A JavaMail MIME message delegate for an NNTP article.
Version:
2.0
Author:
Chris Burdess

Nested Class Summary

Nested classes/interfaces inherited from class javax.mail.internet.MimeMessage

MimeMessage.RecipientType

Nested classes/interfaces inherited from class javax.mail.Message

Message.RecipientType

Field Summary

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

Method Summary

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.
InputStream
getContentStream()
Produce the raw bytes of the content.
String[]
getHeader(String name)
Get all the headers for this header_name.
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.
int
getLineCount()
Return the number of lines for the content of this message.
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.
String
getMessageId()
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.
void
saveChanges()
Updates the appropriate header fields of this message to be consistent with the message's contents.
void
setFlags(Flags flag, boolean set)
Set the flags for this message.

Methods inherited from class javax.mail.internet.MimeMessage

addFrom, addHeader, addHeaderLine, addRecipients, addRecipients, createInternetHeaders, getAllHeaderLines, getAllHeaders, getAllRecipients, getContent, getContentID, getContentLanguage, getContentMD5, getContentStream, getContentType, getDataHandler, getDescription, getDisposition, getEncoding, getFileName, getFlags, getFrom, getHeader, getHeader, getInputStream, getLineCount, getMatchingHeaderLines, getMatchingHeaders, getMessageID, getNonMatchingHeaderLines, getNonMatchingHeaders, getRawInputStream, getReceivedDate, getRecipients, getReplyTo, getSender, getSentDate, getSize, getSubject, isMimeType, isSet, parse, removeHeader, reply, saveChanges, setContent, setContent, setContentID, setContentLanguage, setContentMD5, setDataHandler, setDescription, setDescription, setDisposition, setFileName, setFlags, setFrom, setFrom, setHeader, setRecipients, setRecipients, setReplyTo, setSender, setSentDate, setSubject, setSubject, setText, setText, updateHeaders, writeTo, writeTo

Methods inherited from class javax.mail.Message

addFrom, addRecipient, addRecipients, getAllRecipients, getFlags, getFolder, getFrom, getMessageNumber, getReceivedDate, getRecipients, getReplyTo, getSentDate, getSubject, isExpunged, isSet, match, reply, saveChanges, setExpunged, setFlag, setFlags, setFrom, setFrom, setMessageNumber, setRecipient, setRecipients, setReplyTo, setSentDate, setSubject

Method Details

getAllHeaderLines

public Enumeration getAllHeaderLines()
            throws MessagingException
Get all header lines as an Enumeration of Strings. A Header line is a raw RFC 822 header-line, containing both the "name" and "value" field.
Specified by:
getAllHeaderLines in interface MimePart
Overrides:
getAllHeaderLines in interface MimeMessage

getAllHeaders

public Enumeration getAllHeaders()
            throws MessagingException
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.

This implementation obtains the headers from the headers InternetHeaders object.

Specified by:
getAllHeaders in interface Part
Overrides:
getAllHeaders in interface MimeMessage
Returns:
array of header objects

getContentStream

public InputStream getContentStream()
            throws MessagingException
Produce the raw bytes of the content. This method is used during parsing, to create a DataHandler object for the content. Subclasses that can provide a separate input stream for just the message content might want to override this method.

This implementation just returns a ByteArrayInputStream constructed out of the content byte array.

Overrides:
getContentStream in interface MimeMessage

getHeader

public String[] getHeader(String name)
            throws MessagingException
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.

This implementation obtains the headers from the headers InternetHeaders object.

Specified by:
getHeader in interface Part
Overrides:
getHeader in interface MimeMessage
Parameters:
name - name of header
Returns:
array of headers

getHeader

public String getHeader(String name,
                        String delimiter)
            throws MessagingException
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.
Specified by:
getHeader in interface MimePart
Overrides:
getHeader in interface MimeMessage
Parameters:
name - the name of the header
delimiter - the delimiter
Returns:
the value fields for all headers with this name

getLineCount

public int getLineCount()
            throws MessagingException
Return the number of lines for the content of this message. Return -1 if this number cannot be determined.

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

This implementation returns -1.

Specified by:
getLineCount in interface Part
Overrides:
getLineCount in interface MimeMessage

getMatchingHeaderLines

public Enumeration getMatchingHeaderLines(String[] names)
            throws MessagingException
Get matching header lines as an Enumeration of Strings. A Header line is a raw RFC 822 header-line, containing both the "name" and "value" field.
Specified by:
getMatchingHeaderLines in interface MimePart
Overrides:
getMatchingHeaderLines in interface MimeMessage

getMatchingHeaders

public Enumeration getMatchingHeaders(String[] names)
            throws MessagingException
Return matching headers from this Message as an Enumeration of Header objects.

This implementation obtains the headers from the headers InternetHeaders object.

Specified by:
getMatchingHeaders in interface Part
Overrides:
getMatchingHeaders in interface MimeMessage

getMessageId

public String getMessageId()

getNonMatchingHeaderLines

public Enumeration getNonMatchingHeaderLines(String[] names)
            throws MessagingException
Get non-matching header lines as an Enumeration of Strings. A Header line is a raw RFC 822 header-line, containing both the "name" and "value" field.
Specified by:
getNonMatchingHeaderLines in interface MimePart
Overrides:
getNonMatchingHeaderLines in interface MimeMessage

getNonMatchingHeaders

public Enumeration getNonMatchingHeaders(String[] names)
            throws MessagingException
Return non-matching headers from this Message as an Enumeration of Header objects.

This implementation obtains the headers from the headers InternetHeaders object.

Specified by:
getNonMatchingHeaders in interface Part
Overrides:
getNonMatchingHeaders in interface MimeMessage

getSize

public int getSize()
            throws MessagingException
Return the size of the content of this message in bytes. Return -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.

This implementation returns the size of the content array (if not null), or, if contentStream is not null, and the available method returns a positive number, it returns that number as the size. Otherwise, it returns -1.

Specified by:
getSize in interface Part
Overrides:
getSize in interface MimeMessage

saveChanges

public void saveChanges()
            throws MessagingException
Updates the appropriate header fields of this message to be consistent with the message's contents. If this message is contained in a Folder, any changes made to this message are committed to the containing folder.

If any part of a message's headers or contents are changed, saveChanges must be called to ensure that those changes are permanent. Otherwise, any such modifications may or may not be saved, depending on the folder implementation.

Messages obtained from folders opened READ_ONLY should not be modified and saveChanges should not be called on such messages.

This method sets the modified flag to true, the save flag to true, and then calls the updateHeaders method.

Overrides:
saveChanges in interface MimeMessage

setFlags

public void setFlags(Flags flag,
                     boolean set)
            throws MessagingException
Set the flags for this message.

This implementation modifies the flags field.

Overrides:
setFlags in interface MimeMessage

© Copyright 2003, 2004 The Free Software Foundation, All rights reserved