Jwma

dtw.webmail.util
Class MultipartInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--java.io.FilterInputStream
              |
              +--dtw.webmail.util.MultipartInputStream
All Implemented Interfaces:
javax.activation.DataSource

public class MultipartInputStream
extends java.io.FilterInputStream
implements javax.activation.DataSource

Class that provides a MultipartInputStream by wrapping an existant InputStream.
It implements size limit checking and serves as a DataSource for handling with Mail API (or other JAF aware) classes.

Version:
0.9.7 07/02/2003
Author:
Dieter Wimberger

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
MultipartInputStream(java.io.InputStream in, java.lang.String ctype, int readlimit)
          Constructs a MultipartInputStream instance.
 
Method Summary
 java.lang.String getContentType()
          Returns the content type of this instance as String.
 java.io.InputStream getInputStream()
          Returns this MultipartInputStream instance as InputStream.
 java.lang.String getName()
          Returns the name of this instance as String.
 java.io.OutputStream getOutputStream()
          Throws an IOException in this implementation, because this instance represents a read-only DataSource.
 int read()
          Reads the next byte of data from the input stream.
 int read(byte[] b, int off, int len)
          Reads up to len bytes of data from this input stream into an array of bytes.
 
Methods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultipartInputStream

public MultipartInputStream(java.io.InputStream in,
                            java.lang.String ctype,
                            int readlimit)
Constructs a MultipartInputStream instance.

Parameters:
in - the InputStream this instance reads from.
ctype - the content type of the incoming request as String. Important because it contains the parts border!
readlimit - the maximum size of the complete request data as int.
Method Detail

getName

public java.lang.String getName()
Returns the name of this instance as String.

(DataSource implementation)

Specified by:
getName in interface javax.activation.DataSource
Returns:
the name as String

getContentType

public java.lang.String getContentType()
Returns the content type of this instance as String.

(DataSource implementation)

Note:the String contains the parts border!

Specified by:
getContentType in interface javax.activation.DataSource
Returns:
the content type as String

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns this MultipartInputStream instance as InputStream.

(DataSource implementation)

Specified by:
getInputStream in interface javax.activation.DataSource
Returns:
this instance as InputStream.
Throws:
java.io.IOException - if impossible.

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Throws an IOException in this implementation, because this instance represents a read-only DataSource.

(DataSource implementation)

Specified by:
getOutputStream in interface javax.activation.DataSource
Returns:
an OutputStream instance for writing to this DataSource.
Throws:
java.io.IOException - if impossible.

read

public int read()
         throws java.io.IOException
Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Overrides:
read in class java.io.FilterInputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
java.io.IOException - if an I/O error occurs.

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from this input stream into an array of bytes. This method blocks until some input is available.

This method simply performs in.read(b, off, len) and returns the result.

Overrides:
read in class java.io.FilterInputStream
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:
java.io.IOException - if an I/O error occurs.
See Also:
FilterInputStream.in

Jwma

Copyright © 2000-2003 jwma team (All Rights Reserved.)