Package com.sun.mail.dsn

## Class MessageHeaders

- java.lang.Object
- - javax.mail.Message
  - - javax.mail.internet.MimeMessage
    - - com.sun.mail.dsn.MessageHeaders

All Implemented Interfaces:
  `MimePart`, `Part`

    public class MessageHeaders
    extends MimeMessage

A special MimeMessage object that contains only message headers, no content. Used to represent the MIME type text/rfc822-headers.

Since:
  JavaMail 1.4

### Nested Class Summary

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

`MimeMessage.RecipientType`

### Field Summary

### Fields inherited from class javax.mail.internet.MimeMessage

`cachedContent, 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

Constructors
`MessageHeaders()` Construct a MessageHeaders object.
`MessageHeaders​(java.io.InputStream is)` Constructs a MessageHeaders object from the given InputStream.
`MessageHeaders​(InternetHeaders headers)` Constructs a MessageHeaders object using the given InternetHeaders.

### Method Summary

All Methods Instance Methods Concrete Methods
`protected java.io.InputStream` `getContentStream()` Produce the raw bytes of the content.
`java.io.InputStream` `getInputStream()` Return a decoded input stream for this Message's "content".
`int` `getSize()` Return the size of this message.
`void` `setDataHandler​(javax.activation.DataHandler dh)` Can't set any content for a MessageHeaders object.

### Methods inherited from class javax.mail.internet.MimeMessage

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

### Methods inherited from class javax.mail.Message

`addRecipient, getFolder, getMessageNumber, getSession, isExpunged, match, setExpunged, setFlag, setMessageNumber, setRecipient`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### MessageHeaders

    public MessageHeaders()
                   throws MessagingException

Construct a MessageHeaders object.

Throws:
  `MessagingException` - for failures

#### MessageHeaders

    public MessageHeaders​(java.io.InputStream is)
                   throws MessagingException

Constructs a MessageHeaders object from the given InputStream.

Parameters:
  `is` - InputStream
Throws:
  `MessagingException` - for failures

#### MessageHeaders

    public MessageHeaders​(InternetHeaders headers)
                   throws MessagingException

Constructs a MessageHeaders object using the given InternetHeaders.

Parameters:
  `headers` - InternetHeaders to use
Throws:
  `MessagingException` - for failures

### Method Detail

#### getSize

    public int getSize()

Return the size of this message. Always returns zero.

Specified by:
  `getSize` in interface `Part`
Overrides:
  `getSize` in class `MimeMessage`
Returns:
  size of content in bytes

#### getInputStream

    public java.io.InputStream getInputStream()

Description copied from class: `MimeMessage`
Return a decoded input stream for this Message's "content".

This implementation obtains the input stream from the DataHandler, that is, it invokes `getDataHandler().getInputStream()`.

Specified by:
  `getInputStream` in interface `Part`
Overrides:
  `getInputStream` in class `MimeMessage`
Returns:
  an InputStream
See Also:
  `MimeMessage.getContentStream()`, `DataHandler.getInputStream()`

#### getContentStream

    protected java.io.InputStream getContentStream()

Description copied from class: `MimeMessage`
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 returns a SharedInputStream, if `contentStream` is not null. Otherwise, it returns a ByteArrayInputStream constructed out of the `content` byte array.

Overrides:
  `getContentStream` in class `MimeMessage`
Returns:
  an InputStream containing the raw bytes
See Also:
  `MimeMessage.content`

#### setDataHandler

    public void setDataHandler​(javax.activation.DataHandler dh)
                        throws MessagingException

Can't set any content for a MessageHeaders object.

Specified by:
  `setDataHandler` in interface `Part`
Overrides:
  `setDataHandler` in class `MimeMessage`
Parameters:
  `dh` - The DataHandler for the content.
Throws:
  `MessagingException` - always