EAF 7.6 Implementation

com.lutris.mime
Class MultipartMimeInput

java.lang.Object
  extended by com.lutris.mime.MultipartMimeInput

public class MultipartMimeInput
extends java.lang.Object

Presents an incoming Multipart MIME message as a series of distinct MultipartMimeInputStream streams.


Field Summary
protected  boolean atEOF
          True if the end of the input source has been reached and no more multipart sections are available to be read.
protected  MultipartMimeInputStream currentStream
          The current section of Multipart input.
protected  BMByteSearch inputPattern
          Pre-compiled Boyer-Moore pattern search object for the Mime boundary string.
protected  java.lang.String inputSeparator
          The boundary string which separates different sections of the multipart Mime input.
protected  BMByteSearchStream inputSource
          An input stream that does exact pattern searching using an efficient string matching algorithm.
protected  java.lang.String newlineString
          The string that represents a newline for this instance of input.
 
Constructor Summary
MultipartMimeInput(java.io.InputStream source, ContentHeader contentHeader)
          Constructs a new MultipartMimeInput object from an input source of type InputStream and a ContentHeader object.
 
Method Summary
 void close()
          Closes the input source and the current MultipartMimeInputStream object.
 MultipartMimeInputStream nextPart()
          Returns the next section of the Multipart MIME stream as a MultipartMimeInputStream object.
 MultipartMimeInputStream nextPart(java.lang.String encoding)
          Returns the next section of the Multipart MIME stream as a MultipartMimeInputStream object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentStream

protected MultipartMimeInputStream currentStream
The current section of Multipart input. This is maintained so that it can be invalidated if a request is made to go to the next section.


inputSource

protected BMByteSearchStream inputSource
An input stream that does exact pattern searching using an efficient string matching algorithm.


newlineString

protected java.lang.String newlineString
The string that represents a newline for this instance of input. This is necessary because some web browsers (typically on Unix hosts) send LF instead of the Mime-required CR+LF.


inputSeparator

protected java.lang.String inputSeparator
The boundary string which separates different sections of the multipart Mime input.


inputPattern

protected BMByteSearch inputPattern
Pre-compiled Boyer-Moore pattern search object for the Mime boundary string.


atEOF

protected boolean atEOF
True if the end of the input source has been reached and no more multipart sections are available to be read.

Constructor Detail

MultipartMimeInput

public MultipartMimeInput(java.io.InputStream source,
                          ContentHeader contentHeader)
                   throws com.lutris.mime.MimeException
Constructs a new MultipartMimeInput object from an input source of type InputStream and a ContentHeader object. The ContentHeader object will usually be a Content-Type header and its value must begin with "multipart/" to indicate multipart Mime input. Other Mime types will cause a MimeException to be thrown. In addition, a parameter called "boundary" must exist in the header, since multipart Mime input is split using a boundary string passed in the Content-Type header.

Parameters:
source - Input stream from which Mime input will be read.
contentHeader - ContentHeader object containing a boundary field and Mime type to be used in scanning the input.
Throws:
MimeException - Thrown if an illegal header or Mime type is encountered while processing the input.
Method Detail

nextPart

public MultipartMimeInputStream nextPart()
                                  throws com.lutris.mime.MimeException
Returns the next section of the Multipart MIME stream as a MultipartMimeInputStream object. Returns null if the end of the input source has been reached.

Note:

Since Multipart MIME data flows in a single stream, calling this method causes the previously returned MultipartMimeInputStream to be automatically closed and its input to be skipped.

Returns:
A MultipartMimeInputStream object for the next section of the multipart message.
Throws:
MimeException - If an error occurs while skipping to the next section of input.

nextPart

public MultipartMimeInputStream nextPart(java.lang.String encoding)
                                  throws com.lutris.mime.MimeException
Returns the next section of the Multipart MIME stream as a MultipartMimeInputStream object. Returns null if the end of the input source has been reached.

Note:

Since Multipart MIME data flows in a single stream, calling this method causes the previously returned MultipartMimeInputStream to be automatically closed and its input to be skipped.

Parameters:
encoding - String encoding to apply during MultipartMimeInputStream initialization.
Returns:
A MultipartMimeInputStream object for the next section of the multipart message.
Throws:
MimeException - If an error occurs while skipping to the next section of input.

close

public void close()
           throws com.lutris.mime.MimeException
Closes the input source and the current MultipartMimeInputStream object. No more parts will be returned by nextPart.

Throws:
MimeException - If an error occurs while closing the input stream.

EAF 7.6 Implementation