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

Class MultipartPart

java.lang.Object
  extended bycom.sap.engine.services.servlets_jsp.lib.multipart.MultipartPart

public abstract class MultipartPart
extends Object

This class represents a sub-message of a multipart http message. Each sub-message has headers and body.

See Also:
MultipartMessage

Field Summary
protected  Hashtable headers
           
protected  int size
           
 
Constructor Summary
MultipartPart()
           
 
Method Summary
 void addHeader(String headerName, String headerValue)
          Adds a header with specified name and value in this multipart sub-message.
 Enumeration getAllHeaderNames()
          Returns an enumeration of the names of all headers of this multipart sub-message.
 byte[] getBody()
          Returns a byte array containing the body of this multipart sub-message.
 String getCharacterEncoding()
          Returns the value of the character encoding of this sub-message as specified by its Content-type header
 String getContentID()
          Returns the value of the Content-Id header of this sub-message
 String getContentType()
          Returns the content type of this multipart sub-message as specified by its Content-Type headers.
 String getDisposition()
          Returns the content-disposition of this multipart sub-message.
 String getFileName()
          Returns the file name of the file that this sub-message represents.
 String getHeader(String headerName)
          Returns the value of a header with a specified name that is set for this multipart sub-message.
 String[] getHeaderValues(String headerName)
          Returns the values of headers with specified name of this multipart sub-message.
abstract  InputStream getInputStream()
          Returns an input stream for reading the body of this multipart sub-message.
 String getName()
          Returns the name of the body of this multipart sub-message.
 int getSize()
          Returns the size of the body of this multipart sub-message.
 String getTransferEncoding()
          Returns the value of the Content-Transfer-Encoding header of this sub-message
 boolean isFormParameter()
          Returns if this multipart sub-message represents a form-based request parameter as specified by RFC 1867.
 void removeHeader(String headerName)
          Removes a header with specified name from this multipart sub-message.
 void setHeader(String headerName, String headerValue)
          Sets a header with specified name and value in this multipart sub-message.
abstract  void setText(String text)
          Sets a body of this multipart sub-message.
abstract  void writeTo(OutputStream outputstream)
          Writes this multipart sub-message to an output stream according to the multipart message's syntax.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

size

protected int size

headers

protected Hashtable headers
Constructor Detail

MultipartPart

public MultipartPart()
Method Detail

getSize

public int getSize()
Returns the size of the body of this multipart sub-message.

Returns:
The size of the sub-message body

getContentType

public String getContentType()
Returns the content type of this multipart sub-message as specified by its Content-Type headers.

Returns:
The content type of the sub-message

getDisposition

public String getDisposition()
Returns the content-disposition of this multipart sub-message. The content-disposition is the value of the Content-Disposition header (without its parameters) of the sub-message.

Returns:
The value of the content-disposition header (without its parameters) of this message

getName

public String getName()
Returns the name of the body of this multipart sub-message. The name is the value of the parameter "name" of the Content-Disposition header of this sub-message

Returns:
The name of this sub-message

isFormParameter

public boolean isFormParameter()
Returns if this multipart sub-message represents a form-based request parameter as specified by RFC 1867.

Returns:
True, if this sub-message represents a form-based request parameter, and false otherwise

getFileName

public String getFileName()
Returns the file name of the file that this sub-message represents. The sub-message can represent a file if the http multipart message has the same syntax as the one defined by RFC 1867.

Returns:
The name of the file this sub-message represents or null if the message doesn't represent a file as defined by RFC 1867

getInputStream

public abstract InputStream getInputStream()
Returns an input stream for reading the body of this multipart sub-message.

Returns:
An input stream for reading the body of this multipart sub-message.

getBody

public byte[] getBody()
               throws IOException
Returns a byte array containing the body of this multipart sub-message.

Returns:
The body of this message represented as byte array. The size of the byte array is equal to the size of the body.
Throws:
IOException

setText

public abstract void setText(String text)
Sets a body of this multipart sub-message.

Parameters:
text - A String representing the sub-message body

writeTo

public abstract void writeTo(OutputStream outputstream)
Writes this multipart sub-message to an output stream according to the multipart message's syntax.

Parameters:
outputstream - An output stream where the message will be written to

getHeader

public String getHeader(String headerName)
Returns the value of a header with a specified name that is set for this multipart sub-message.

Parameters:
headerName - The name of the header that is set
Returns:
The value of the first header with the specified name that is set for this message, or null if such header does not exist

getHeaderValues

public String[] getHeaderValues(String headerName)
Returns the values of headers with specified name of this multipart sub-message.

Parameters:
headerName - The name of the header that is set
Returns:
An array with the values of all headers with the specified name, or null if such headers do not exist

setHeader

public void setHeader(String headerName,
                      String headerValue)
Sets a header with specified name and value in this multipart sub-message. If the sub-message already contains headers with the same name, they will be removed.

Parameters:
headerName - The name of the header that will be set
headerValue - The value of the header that will de set

addHeader

public void addHeader(String headerName,
                      String headerValue)
Adds a header with specified name and value in this multipart sub-message.

Parameters:
headerName - The name of the header that will be added
headerValue - The value of the header that will de added

removeHeader

public void removeHeader(String headerName)
Removes a header with specified name from this multipart sub-message.

Parameters:
headerName - The name of the header that will be removed

getAllHeaderNames

public Enumeration getAllHeaderNames()
Returns an enumeration of the names of all headers of this multipart sub-message. Each element of this enumeration is a String representing the name of the next header.

Returns:
An enumeration of the names of all headers of this multipart sub-message

getCharacterEncoding

public String getCharacterEncoding()
Returns the value of the character encoding of this sub-message as specified by its Content-type header

Returns:
The value of the character encoding of this sub-message

getTransferEncoding

public String getTransferEncoding()
Returns the value of the Content-Transfer-Encoding header of this sub-message

Returns:
The value of the Content-Transfer-Encoding header of this sub-message

getContentID

public String getContentID()
Returns the value of the Content-Id header of this sub-message

Returns:
The value of the Content-Id header of this sub-message


Copyright 2006 SAP AG. All rights reserved. No part of this publication may be reproduced or transmitted in any form or for any purpose without the express permission of SAP AG. The information contained herein may be changed without prior notice. Microsoft, Windows, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. Oracle is a registered trademark of Oracle Corporation. UNIX, X/Open, OSF/1, and Motif are registered trademarks of the Open Group. Citrix, ICA, Program Neighborhood, MetaFrame, WinFrame, VideoFrame, and MultiWin are trademarks or registered trademarks of Citrix Systems, Inc. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. MaxDB is a trademark of MySQL AB, Sweden. SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary. These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.