com.caucho.vfs
Class MultipartStream

java.lang.Object
  extended by com.caucho.vfs.StreamImpl
      extended by com.caucho.vfs.MultipartStream

public class MultipartStream
extends StreamImpl


Field Summary
 
Fields inherited from class com.caucho.vfs.StreamImpl
_nullPath, _path
 
Constructor Summary
MultipartStream()
           
MultipartStream(ReadStream is, java.lang.String boundary)
           
 
Method Summary
 boolean canRead()
          Returns true if this is a read stream.
 java.lang.String getAttribute(java.lang.String key)
          Returns a read attribute from the multipart mime.
 java.util.Iterator getAttributeNames()
          Returns the headers from the mime.
 int getAvailable()
          Returns the number of available bytes.
 java.lang.String getEncoding()
          Returns the default encoding.
 java.util.HashMap<java.lang.String,java.util.List<java.lang.String>> getHeaders()
           
 void init(ReadStream is, java.lang.String headerBoundary)
          Initialize the multipart stream with a given boundary.
 boolean isComplete()
          Returns true if complete.
 ReadStream openRead()
          Opens the next part of the multipart/mime stream for reading.
 int read(byte[] buffer, int offset, int length)
          Reads from the multipart mime buffer.
 void setEncoding(java.lang.String encoding)
          Sets the default encoding.
 
Methods inherited from class com.caucho.vfs.StreamImpl
canWrite, clearWrite, close, closeWrite, flush, flushBuffer, flushToDisk, getFlushOnNewline, getNewline, getPath, getReadBuffer, getReadPosition, hasSkip, isClosed, isEof, readNonBlock, readTimeout, removeAttribute, seekEnd, seekStart, setAttribute, setPath, setWriteEncoding, skip, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MultipartStream

public MultipartStream()
                throws java.io.IOException
Throws:
java.io.IOException

MultipartStream

public MultipartStream(ReadStream is,
                       java.lang.String boundary)
                throws java.io.IOException
Throws:
java.io.IOException
Method Detail

getEncoding

public java.lang.String getEncoding()
Returns the default encoding.


setEncoding

public void setEncoding(java.lang.String encoding)
Sets the default encoding.


init

public void init(ReadStream is,
                 java.lang.String headerBoundary)
          throws java.io.IOException
Initialize the multipart stream with a given boundary. The boundary passed to init will have "--" prefixed.

Parameters:
is - the underlying stream
headerBoundary - the multipart/mime boundary.
Throws:
java.io.IOException

isComplete

public boolean isComplete()
Returns true if complete.


openRead

public ReadStream openRead()
                    throws java.io.IOException
Opens the next part of the multipart/mime stream for reading. Returns null when the last section is read.

Throws:
java.io.IOException

getAttribute

public java.lang.String getAttribute(java.lang.String key)
Returns a read attribute from the multipart mime.

Overrides:
getAttribute in class StreamImpl
Parameters:
key - the attribute name.
Returns:
the attribute value.

getAttributeNames

public java.util.Iterator getAttributeNames()
Returns the headers from the mime.

Overrides:
getAttributeNames in class StreamImpl

getHeaders

public java.util.HashMap<java.lang.String,java.util.List<java.lang.String>> getHeaders()

canRead

public boolean canRead()
Description copied from class: StreamImpl
Returns true if this is a read stream.

Overrides:
canRead in class StreamImpl

getAvailable

public int getAvailable()
                 throws java.io.IOException
Returns the number of available bytes.

Overrides:
getAvailable in class StreamImpl
Throws:
java.io.IOException

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws java.io.IOException
Reads from the multipart mime buffer.

Overrides:
read in class StreamImpl
Parameters:
buffer - byte array receiving the data.
offset - starting offset into the array.
length - number of bytes to read.
Returns:
the number of bytes read or -1 on end of file.
Throws:
java.io.IOException