com.basho.riak.client.http.util
Class StreamedMultipart

java.lang.Object
  extended by com.basho.riak.client.http.util.StreamedMultipart
All Implemented Interfaces:
Iterator<Multipart.Part>

public class StreamedMultipart
extends Object
implements Iterator<Multipart.Part>


Constructor Summary
StreamedMultipart(Map<String,String> headers, InputStream stream)
          Parses a multipart message or a multipart subpart of a multipart message.
 
Method Summary
 Map<String,String> getHeaders()
          Return the map of document headers that this object was constructed with.
 boolean hasNext()
          See Iterator.hasNext().
 Multipart.Part next()
          See Iterator.next().
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamedMultipart

public StreamedMultipart(Map<String,String> headers,
                         InputStream stream)
                  throws IOException,
                         EOFException
Parses a multipart message or a multipart subpart of a multipart message. Each parts of the message is parsed into a map of headers and the body as an InputStream. stream is not consumed until the return value is iterated over. It is consumed as each part is encountered. A part's body InputStream does not need to be consumed before proceed to the next part. If it is not consumed, it will be buffered in memory and accessible later.

Parameters:
headers - The headers from the original message, which contains the Content-Type header including the boundary string
stream - The input stream to read from
Throws:
IOException - There was a communication error reading the input stream while looking for the initial boundary
EOFException - The initial boundary was not found
Method Detail

getHeaders

public Map<String,String> getHeaders()
Return the map of document headers that this object was constructed with.


hasNext

public boolean hasNext()
See Iterator.hasNext().

Specified by:
hasNext in interface Iterator<Multipart.Part>
Throws:
RuntimeException - (IOException) if there is an error reading the next part from the input stream

next

public Multipart.Part next()
See Iterator.next().

Specified by:
next in interface Iterator<Multipart.Part>
Throws:
RuntimeException - (IOException) if there is an error reading the next part from the input stream

remove

public void remove()
Specified by:
remove in interface Iterator<Multipart.Part>


Copyright © 2012. All Rights Reserved.