KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > mail > dsn > MessageHeaders


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21
22 /*
23  * @(#)MessageHeaders.java 1.5 06/03/09
24  *
25  * Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
26  */

27
28 package com.sun.mail.dsn;
29
30 import java.io.*;
31
32 import javax.activation.*;
33 import javax.mail.*;
34 import javax.mail.internet.*;
35
36 /**
37  * A special MimeMessage object that contains only message headers,
38  * no content. Used to represent the MIME type text/rfc822-headers.
39  */

40 public class MessageHeaders extends MimeMessage {
41
42     /**
43      * Construct a MessageHeaders object.
44      */

45     public MessageHeaders() throws MessagingException {
46     super((Session)null);
47     content = new byte[0];
48     }
49
50     /**
51      * Constructs a MessageHeaders object from the given InputStream.
52      *
53      * @param is InputStream
54      */

55     public MessageHeaders(InputStream is) throws MessagingException {
56     super(null, is);
57     content = new byte[0];
58     }
59
60     /**
61      * Constructs a MessageHeaders object using the given InternetHeaders.
62      *
63      * @param headers InternetHeaders to use
64      */

65     public MessageHeaders(InternetHeaders headers) throws MessagingException {
66     super((Session)null);
67     this.headers = headers;
68     content = new byte[0];
69     }
70
71     /**
72      * Return the size of this message.
73      * Always returns zero.
74      */

75     public int getSize() {
76     return 0;
77     }
78
79     public InputStream getInputStream() {
80     return new ByteArrayInputStream(content);
81     }
82
83     protected InputStream getContentStream() {
84     return new ByteArrayInputStream(content);
85     }
86
87     /**
88      * Can't set any content for a MessageHeaders object.
89      *
90      * @exception MessagingException always
91      */

92     public void setDataHandler(DataHandler dh) throws MessagingException {
93     throw new MessagingException("Can't set content for MessageHeaders");
94     }
95
96 }
97
Popular Tags