Tynamo™-TINI
v1.0.4

com.qindesign.mime
Class Multipart

java.lang.Object
  extended by com.qindesign.mime.Multipart

public class Multipart
extends Object

Processes multipart messages. This can be used to process files uploaded from an HTML form.

Version:
1.0.4
Author:
Shawn Silverman
See Also:
Section 5.1, Multipart Media Type, RFC 2046, Appendix A -- A Complex Multipart Example, RFC 2049

Nested Class Summary
static class Multipart.BodyPart
          Represents one body part of a multipart body.
 
Constructor Summary
Multipart(InputStream in, String contentType)
          Creates a new multipart processor.
 
Method Summary
static Enumeration getParameters(String headerValue)
          Returns an Enumeration of the parameters in the given content type.
static String getType(String headerValue)
          Gets the media type portion of the given content type.
static boolean isMultipart(String contentType)
          Checks if the given content type is multipart.
 Multipart.BodyPart nextBodyPart()
          Reads the next body part.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Multipart

public Multipart(InputStream in,
                 String contentType)
          throws IOException
Creates a new multipart processor.

Parameters:
in - an InputStream containing the body
contentType - the content type of the data, should be a multipart type
Throws:
IOException - if there was an I/O error or if the multipart body is not in the correct format.
Method Detail

nextBodyPart

public Multipart.BodyPart nextBodyPart()
                                throws IOException
Reads the next body part. This returns null if there are none left.

Returns:
a BodyPart object, or null if there are none left.
Throws:
IOException - if there was an I/O error or if the body part is not in the correct format.

isMultipart

public static boolean isMultipart(String contentType)
Checks if the given content type is multipart.

Parameters:
contentType - the content type to check
Returns:
whether the given content type is multipart.

getType

public static String getType(String headerValue)
Gets the media type portion of the given content type. This can also be used to extract the disposition type from the Content-Disposition header.

Parameters:
headerValue - the value of the Content-Type or Content-Disposition header
Returns:
the media type portion of the given content type, or the disposition type from the Content-Disposition header.

getParameters

public static Enumeration getParameters(String headerValue)
Returns an Enumeration of the parameters in the given content type. Each enumerated element will be a string array containing two items. This can also be used to extract the parameters from the Content-Disposition header.

This method correctly handles quoted strings. The double quotes are not returned, so there is no need to process the parameter values further.

Parameters:
headerValue - the value of the Content-Type or Content-Disposition header
Returns:
the parameters in the given header.

Tynamo™-TINI
v1.0.4

© 2001-2007 Shawn Silverman