SAP J2EE Engine

Version 6.40


com.sap.engine.services.servlets_jsp.lib.multipart
Class MultipartMessage

java.lang.Object
  |
  +--com.sap.engine.services.servlets_jsp.lib.multipart.MultipartMessage

public abstract class MultipartMessage
extends java.lang.Object

This class represents a multipart message body. An http message is multipart if it has content-type starting with "multipart/". A multipart message consists of multipart sub-messages. This class is actually a set of all sub-messages of a multipart message. It contains methods for getting the sub-messages count, obtaining a single message by name or index, adding and removing multipart sub-messages. A multipart request body can be obtained as instance of this class using the getAttribute(String s) method of HttpServletRequest interface. The default parameter that must be passed to this method is MULTIPART_BODY_KEY.

Version:
6.30

Field Summary
protected  boolean addFormParameters
           
protected  java.lang.String contentType
           
static java.lang.String FORM_DATA_TYPE
           
static java.lang.String MULTIPART_BODY_KEY
          The default key used for accessing a multipart request / response body through servlet API.
 
Constructor Summary
MultipartMessage()
           
 
Method Summary
 void addBodyPart(MultipartPart bodypart)
          Adds a sub-message to this multipart message.
 void addBodyPart(MultipartPart bodypart, int i)
          Adds a sub-message in this multipart message on a specified possition.
abstract  void addFormParametersToRequest()
           
 MultipartPart getBodyPart(int i)
          Returns a sub-message at a specified possition within this multipart message.
 MultipartPart getBodyPart(java.lang.String s)
          Returns a sub-message with a specified name.
 java.util.Enumeration getBodyParts()
          Returns an enumeration of all sub-messages within this multipart message.
 java.lang.String getContentType()
          Returns the content type of this multipart body.
 int getCount()
          Returns the number of the sub-messages within this multipart message.
 boolean isFormParametersToRequest()
           
protected abstract  void parse()
           
 void removeBodyPart(int i)
          Removes a sub-message on a specified possition from this multipart message.
 boolean removeBodyPart(MultipartPart bodypart)
          Removes a sub-message from this multipart message.
abstract  void writeTo(java.io.OutputStream outputstream)
          Writes this multipart message to the specified output stream according to the multipart messages syntax.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MULTIPART_BODY_KEY

public static final java.lang.String MULTIPART_BODY_KEY
The default key used for accessing a multipart request / response body through servlet API.

FORM_DATA_TYPE

public static final java.lang.String FORM_DATA_TYPE

contentType

protected java.lang.String contentType

addFormParameters

protected boolean addFormParameters
Constructor Detail

MultipartMessage

public MultipartMessage()
Method Detail

getContentType

public java.lang.String getContentType()
                                throws java.io.IOException,
                                       MultipartParseException
Returns the content type of this multipart body. It usually starts with "multipart/".
Returns:
The content type of this multipart body
Throws:
java.io.IOException - If some error occurs in reading / writing to the input stream of the message body
MultipartParseException - If the message body doesn't represent a valid multipart message

getCount

public int getCount()
             throws java.io.IOException,
                    MultipartParseException
Returns the number of the sub-messages within this multipart message.
Returns:
The number of the sub-messages within this multipart message
Throws:
java.io.IOException - If some error occurs in reading / writing to the input stream of the message body
MultipartParseException - If the message body doesn't represent a valid multipart message

getBodyParts

public java.util.Enumeration getBodyParts()
                                   throws java.io.IOException,
                                          MultipartParseException
Returns an enumeration of all sub-messages within this multipart message.
Returns:
An enumeration of all sub-messages within this multipart message.
Throws:
java.io.IOException - If some error occurs in reading / writing to the input stream of the message body
MultipartParseException - If the message body doesn't represent a valid multipart message

getBodyPart

public MultipartPart getBodyPart(int i)
                          throws java.io.IOException,
                                 MultipartParseException
Returns a sub-message at a specified possition within this multipart message.
Parameters:
i - The possition of the sub-message that will be returned or null if a sub-message with such index does not exist
Returns:
The sub-message at possition i within this multipart message
Throws:
java.io.IOException - If some error occurs in reading / writing to the input stream of the message body
MultipartParseException - If the message body doesn't represent a valid multipart message
ArrayIndexOutOfBoundsException - if the i is a negative number or number that exceeds the number of sub-messages

removeBodyPart

public boolean removeBodyPart(MultipartPart bodypart)
                       throws java.io.IOException,
                              MultipartParseException
Removes a sub-message from this multipart message.
Parameters:
bodypart - The sub-message that will be removed
Returns:
True, if such sub-message exists, or false otherwise
Throws:
java.io.IOException - If some error occurs in reading / writing to the input stream of the message body
MultipartParseException - If the message body doesn't represent a valid multipart message

removeBodyPart

public void removeBodyPart(int i)
                    throws java.io.IOException,
                           MultipartParseException
Removes a sub-message on a specified possition from this multipart message.
Parameters:
i - The index of the sub-message that will be removed
Throws:
java.io.IOException - If some error occurs in reading / writing to the input stream of the message body
MultipartParseException - If the message body doesn't represent a valid multipart message
ArrayIndexOutOfBoundsException - if the index is either negative number of exceeds the number of sub-messages within this multipart message.

addBodyPart

public void addBodyPart(MultipartPart bodypart)
                 throws java.io.IOException,
                        MultipartParseException
Adds a sub-message to this multipart message. The new sub-message is added at the last position of the list of sub-messages.
Parameters:
bodypart - The sub-message that will be added
Throws:
java.io.IOException - If some error occurs in reading / writing to the input stream of the message body
MultipartParseException - If the message body doesn't represent a valid multipart message

addBodyPart

public void addBodyPart(MultipartPart bodypart,
                        int i)
                 throws java.io.IOException,
                        MultipartParseException
Adds a sub-message in this multipart message on a specified possition.
Parameters:
bodypart - The sub-message that will be added
i - The index, identifying the position on which the sub-message will be added. The first message has index 0.
Throws:
java.io.IOException - If some error occurs in reading / writing to the input stream of the message body
MultipartParseException - If the message body doesn't represent a valid multipart message
ArrayIndexOutOfBoundsException - if the index is either negative number of exceeds the number of sub-messages within this multipart message.

getBodyPart

public MultipartPart getBodyPart(java.lang.String s)
                          throws java.io.IOException,
                                 MultipartParseException
Returns a sub-message with a specified name. The name is considered to be the "name" attribute of the content-disposition header of this subtype.
Parameters:
s - The name of the sub-message that will be returned
Returns:
A sub-message with the specified name or null if such does not exis
Throws:
java.io.IOException - If some error occurs in reading / writing to the input stream of the message body
MultipartParseException - If the message body doesn't represent a valid multipart message

addFormParametersToRequest

public abstract void addFormParametersToRequest()

isFormParametersToRequest

public boolean isFormParametersToRequest()

writeTo

public abstract void writeTo(java.io.OutputStream outputstream)
                      throws java.io.IOException
Writes this multipart message to the specified output stream according to the multipart messages syntax.
Parameters:
outputstream - The output stream where the message will be written to
Throws:
java.io.IOException - If some error occurs in reading / writing to the input stream of the message body

parse

protected abstract void parse()
                       throws java.io.IOException,
                              MultipartParseException

SAP J2EE Engine

Version 6.40


Copyright © 2001-2005 SAP AG. All Rights Reserved.