com.ibm.portal.resolver.streams
Class MultipartInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.ibm.portal.resolver.streams.MultipartInputStream
All Implemented Interfaces:
MultipartStream, java.io.Closeable, java.nio.channels.Channel
Direct Known Subclasses:
FormDataInputStream

public abstract class MultipartInputStream
extends java.io.InputStream
implements MultipartStream

Input stream that represents the content of a multipart stream following RFC 1521. This multipart stream consists of zero or more substreams that are each separated via a boundary. The construction logic of the instance of MultipartInputStream needs to take care that the correct boundary value is specified. This boundary is typically defered from the content-type request header.

The caller can step over the multipart entries using the getNextEntry() method. Calling this method returns a description of the next entry or null if no entry is available. In addition the input stream will be reset to represent the content of the entry. This content will already be decoded wtr to the Content-Transfer-Encoding header of the entry. Reading the complete input stream until any of the read-method returns -1 will read up to the end of the current entry.

The design of this abstract class has been modelled after ZipInputStream.

Instances of MultipartInputStream can be created via the com.ibm.portal.resolver.streams.StreamFactory.

Since:
6.0.1

Nested Class Summary
static class MultipartInputStream.Entry
          Represents an entry in this archive input stream.
 
Field Summary
 
Fields inherited from interface com.ibm.portal.resolver.streams.MultipartStream
CONTENT_TYPE_FORM_DATA, CONTENT_TYPE_MULTIPART, KEY_CONTENT_DISPOSITION, KEY_FILENAME, KEY_MIME_BOUNDARY, KEY_NAME, VALUE_FORM_DATA, VALUE_MULTIPART
 
Constructor Summary
MultipartInputStream()
           
 
Method Summary
abstract  MultipartInputStream.Entry getNextEntry()
           Reads the next multipart stream entry and positions stream at the beginning of the entry data.
static boolean matches(javax.mail.internet.ContentType ct)
          Checks if the mime type is valid for a multipart input
 
Methods inherited from class java.io.InputStream
available, close, mark, markSupported, read, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.ibm.portal.resolver.streams.MultipartStream
closeEntry
 
Methods inherited from interface java.nio.channels.Channel
close, isOpen
 

Constructor Detail

MultipartInputStream

public MultipartInputStream()
Method Detail

matches

public static boolean matches(javax.mail.internet.ContentType ct)
Checks if the mime type is valid for a multipart input

Parameters:
ct - the content type to check, not null
Returns:
true if this is a valid content type, else false
Since:
7.0

getNextEntry

public abstract MultipartInputStream.Entry getNextEntry()
                                                 throws java.io.IOException

Reads the next multipart stream entry and positions stream at the beginning of the entry data. Note that MultipartInputStream.Entry instances may be recycled, the entry is only valid until the next call to getNextEntry() or MultipartStream.closeEntry().

The implementation will at least interpret the following headers automatically

Returns:
the multipart entry just read or null if there is no more entry
Throws:
java.io.IOException - if an I/O error has occurred