SK.gnome.dwarf.mail.mime
Interface MimePart

All Known Implementing Classes:
MimePartBuilder, StreamMimePart

public interface MimePart

Provides base interface for MIME parts.

This class represents a MIME part, which may be a RFC8288 message, a MIME-formatted message attachment or a MIME representation of a standalone arbitrary data.


Method Summary
 java.io.InputStream getContentInputStream()
          Returns the content input stream.
 int getContentSize()
          Returns the content size.
 java.io.InputStream getDecodedInputStream()
          Returns the decoded content input stream.
 java.lang.String[] getHeader(java.lang.String name)
          Returns all values of the given header.
 java.lang.String getHeader(java.lang.String name, java.lang.String delimiter)
          Returns all values of the given header, delimited by the given character sequence.
 java.util.Iterator getHeaderLines()
          Returns all header lines.
 java.util.Iterator getHeaderNames()
          Returns all header names.
 int getLineCount()
          Returns the line count of the body.
 java.util.Iterator getMatchingHeaderLines(java.lang.String[] names)
          Returns matching header lines.
 MimePart getMimePart(int number)
          Returns the nested MIME part.
 int getMimePartCount()
          Returns the number of nested MIME parts.
 java.util.Iterator getNonMatchingHeaderLines(java.lang.String[] names)
          Returns non matching header lines.
 java.io.InputStream getRawInputStream()
          Returns the raw input stream.
 int getRawSize()
          Returns the raw size of this part.
 boolean isMimeType(java.lang.String type)
          Whether this MIME part if of the given type.
 

Method Detail

getHeaderNames

public java.util.Iterator getHeaderNames()
                                  throws MimeException
Returns all header names.

Returns:
the header names
Throws:
MimeException - if a MIME syntax error occured

getHeader

public java.lang.String[] getHeader(java.lang.String name)
                             throws MimeException
Returns all values of the given header.

Parameters:
name - the header name
Returns:
the array of header values
Throws:
MimeException - if a MIME syntax error occured

getHeader

public java.lang.String getHeader(java.lang.String name,
                                  java.lang.String delimiter)
                           throws MimeException
Returns all values of the given header, delimited by the given character sequence.

Parameters:
name - the header name
delimiter - the value delimiter
Returns:
the string of delimited header values
Throws:
MimeException - if a MIME syntax error occured

getHeaderLines

public java.util.Iterator getHeaderLines()
                                  throws MimeException
Returns all header lines.

The header lines are returned in the exact form as they appear in the MIME part.

Returns:
the header lines
Throws:
MimeException - if a MIME syntax error occured

getMatchingHeaderLines

public java.util.Iterator getMatchingHeaderLines(java.lang.String[] names)
                                          throws MimeException
Returns matching header lines.

The header lines are returned in the exact form as they appear in the MIME part.

Parameters:
names - the header names
Returns:
the matching header lines
Throws:
MimeException - if a MIME syntax error occured

getNonMatchingHeaderLines

public java.util.Iterator getNonMatchingHeaderLines(java.lang.String[] names)
                                             throws MimeException
Returns non matching header lines.

The header lines are returned in the exact form as they appear in the MIME part.

Parameters:
names - the header names
Returns:
the non matching header lines
Throws:
MimeException - if a MIME syntax error occured

isMimeType

public boolean isMimeType(java.lang.String type)
                   throws MimeException
Whether this MIME part if of the given type.

The type argument must be in the form of "type/subtype" pair. If wildcard character "*" is used as the subtype, the method will test only the main type. The type matching is case insensitive.

Parameters:
type - the mime type
Returns:
true if this part is of the given type, false otherwise
Throws:
MimeException - if a MIME syntax error occured

getRawSize

public int getRawSize()
               throws MimeException
Returns the raw size of this part.

Returns the size of the whole MIME part including the header.

Returns:
the raw size
Throws:
MimeException - if a MIME syntax error occured

getContentSize

public int getContentSize()
                   throws MimeException
Returns the content size.

Returns the size of content-encoded MIME part body.

Returns:
the content size
Throws:
MimeException - if a MIME syntax error occured

getLineCount

public int getLineCount()
                 throws java.io.IOException,
                        MimeException
Returns the line count of the body.

Returns the total line count of the content-encoded MIME part body.

Returns:
the line count
Throws:
java.io.IOException - if an I/O error occured
MimeException - if a MIME syntax error occured

getRawInputStream

public java.io.InputStream getRawInputStream()
                                      throws java.io.IOException,
                                             MimeException
Returns the raw input stream.

Returns the input stream of the whole MIME part including the header.

Returns:
the raw stream
Throws:
java.io.IOException - if an I/O error occured
MimeException - if a MIME syntax error occured

getContentInputStream

public java.io.InputStream getContentInputStream()
                                          throws java.io.IOException,
                                                 MimeException
Returns the content input stream.

Returns the input stream of the content-encoded MIME part body.

Returns:
the content stream
Throws:
java.io.IOException - if an I/O error occured
MimeException - if a MIME syntax error occured

getDecodedInputStream

public java.io.InputStream getDecodedInputStream()
                                          throws java.io.IOException,
                                                 MimeException
Returns the decoded content input stream.

Returns the input stream of the content-decoded MIME part body.

Returns:
the content stream
Throws:
java.io.IOException - if an I/O error occured
MimeException - if a MIME syntax error occured

getMimePartCount

public int getMimePartCount()
                     throws MimeException
Returns the number of nested MIME parts.

Returns the total number of nested MIME parts. The parts are numbered from zero. Only parts of type "multipart/*" or "message/rfc822" are regarded as multipart. If the part if of type "message/rfc822", it has only one directly nested part - the RFC822 message itself, which may in turn contain another MIME parts, if it is a multipart message.

Returns:
the number of MIME parts
Throws:
MimeException - if a MIME syntax error occured

getMimePart

public MimePart getMimePart(int number)
                     throws MimeException
Returns the nested MIME part.

Parameters:
number - the part number
Returns:
the given MIME part
Throws:
MimeException - if a MIME syntax error occured


Copyright (c) 2004-2005, Gnome Ltd. All rights reserved.