SK.gnome.dwarf.mail.mime
Class StreamMimePart

java.lang.Object
  extended bySK.gnome.dwarf.mail.mime.StreamMimePart
All Implemented Interfaces:
MimePart

public class StreamMimePart
extends java.lang.Object
implements MimePart

Provides a stream-based MimePart implementation.

This class implements the MimePart interface. The source data is read from input stream via a SharedInputStreamSource instance.


Constructor Summary
  StreamMimePart(SharedInputStreamSource in)
          Creates a new StreamMimePart.
protected StreamMimePart(SharedInputStreamSource source, int offset, int length)
          Creates a new StreamMimePart with the given offset and length.
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamMimePart

public StreamMimePart(SharedInputStreamSource in)
               throws MimeException
Creates a new StreamMimePart.

Parameters:
in - the stream source

StreamMimePart

protected StreamMimePart(SharedInputStreamSource source,
                         int offset,
                         int length)
                  throws MimeException
Creates a new StreamMimePart with the given offset and length.

The new MIME part will begin at the given offset of the stream source and will be limited to the length bytes.

Parameters:
source - the stream source
offset - the stream offset
length - the stream length
Method Detail

getHeaderNames

public java.util.Iterator getHeaderNames()
                                  throws MimeException
Description copied from interface: MimePart
Returns all header names.

Specified by:
getHeaderNames in interface MimePart
Returns:
the header names
Throws:
MimeException - if a MIME syntax error occured

getHeader

public java.lang.String[] getHeader(java.lang.String name)
                             throws MimeException
Description copied from interface: MimePart
Returns all values of the given header.

Specified by:
getHeader in interface MimePart
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
Description copied from interface: MimePart
Returns all values of the given header, delimited by the given character sequence.

Specified by:
getHeader in interface MimePart
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
Description copied from interface: MimePart
Returns all header lines.

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

Specified by:
getHeaderLines in interface MimePart
Returns:
the header lines
Throws:
MimeException - if a MIME syntax error occured

getMatchingHeaderLines

public java.util.Iterator getMatchingHeaderLines(java.lang.String[] names)
                                          throws MimeException
Description copied from interface: MimePart
Returns matching header lines.

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

Specified by:
getMatchingHeaderLines in interface MimePart
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
Description copied from interface: MimePart
Returns non matching header lines.

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

Specified by:
getNonMatchingHeaderLines in interface MimePart
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
Description copied from interface: MimePart
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.

Specified by:
isMimeType in interface MimePart
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()
Description copied from interface: MimePart
Returns the raw size of this part.

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

Specified by:
getRawSize in interface MimePart
Returns:
the raw size

getContentSize

public int getContentSize()
                   throws MimeException
Description copied from interface: MimePart
Returns the content size.

Returns the size of content-encoded MIME part body.

Specified by:
getContentSize in interface MimePart
Returns:
the content size
Throws:
MimeException - if a MIME syntax error occured

getLineCount

public int getLineCount()
                 throws java.io.IOException,
                        MimeException
Description copied from interface: MimePart
Returns the line count of the body.

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

Specified by:
getLineCount in interface MimePart
Returns:
the line count
Throws:
MimeException - if a MIME syntax error occured
java.io.IOException - if an I/O error occured

getRawInputStream

public java.io.InputStream getRawInputStream()
                                      throws java.io.IOException,
                                             MimeException
Description copied from interface: MimePart
Returns the raw input stream.

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

Specified by:
getRawInputStream in interface MimePart
Returns:
the raw stream
Throws:
MimeException - if a MIME syntax error occured
java.io.IOException - if an I/O error occured

getContentInputStream

public java.io.InputStream getContentInputStream()
                                          throws java.io.IOException,
                                                 MimeException
Description copied from interface: MimePart
Returns the content input stream.

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

Specified by:
getContentInputStream in interface MimePart
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
Description copied from interface: MimePart
Returns the decoded content input stream.

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

Specified by:
getDecodedInputStream in interface MimePart
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
Description copied from interface: MimePart
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.

Specified by:
getMimePartCount in interface MimePart
Returns:
the number of MIME parts
Throws:
MimeException - if a MIME syntax error occured

getMimePart

public MimePart getMimePart(int number)
                     throws MimeException
Description copied from interface: MimePart
Returns the nested MIME part.

Specified by:
getMimePart in interface MimePart
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.