com.sapportals.wcm.util.mmparser

Class PartInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byjava.io.FilterInputStream
          extended bycom.sapportals.wcm.util.mmparser.PartInputStream

public class PartInputStream
extends FilterInputStream

A PartInputStream filters a MMInputStream , providing access to a single mime part contained in it.

Note the readLine method of MMInputStream adds the \r\n also to the end of the last line. We have to cut those chars. We must always maintain at least 2 characters in the buffer to allow us to trim when necessary.


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Method Summary
 int available()
          Returns the number of bytes that can be read from this input stream without blocking.
 void close()
          Closes this input stream and releases any system resources associated with the stream.
 int read()
          See the general contract of the read method of InputStream .
 int read(byte[] b)
          See the general contract of the read method of InputStream .
 int read(byte[] b, int off, int len)
          See the general contract of the read method of InputStream .
 
Methods inherited from class java.io.FilterInputStream
mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

read

public int read()
         throws IOException
See the general contract of the read method of InputStream .

Returns -1 (end of file) when the MIME boundary of this part is encountered.

Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
IOException - if an I/O error occurs.

read

public int read(byte[] b)
         throws IOException
See the general contract of the read method of InputStream .

Returns -1 (end of file) when the MIME boundary of this part is encountered.

Parameters:
b - the buffer into which the data is read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
IOException - if an I/O error occurs.

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
See the general contract of the read method of InputStream .

Returns -1 (end of file) when the MIME boundary of this part is encountered.

Parameters:
b - the buffer into which the data is read.
off - the start offset of the data.
len - the maximum number of bytes read.
Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.
Throws:
IOException - if an I/O error occurs.

available

public int available()
              throws IOException
Returns the number of bytes that can be read from this input stream without blocking. This is a standard InputStream idiom to deal with buffering gracefully, and is not same as the length of the part arriving in this stream.

Returns:
the number of bytes that can be read from the input stream without blocking.
Throws:
IOException - if an I/O error occurs.

close

public void close()
           throws IOException
Closes this input stream and releases any system resources associated with the stream.

This method will read any unread data in the MIME part so that the next part starts an an expected place in the parent InputStream . Note that if the client code forgets to call this method on error, MultipartParser will call it automatically if you call readNextPart() .

Throws:
IOException - if an I/O error occurs.


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.