Package org.apache.axiom.mime.activation
Class PartDataHandlerBlob
java.lang.Object
org.apache.axiom.mime.activation.PartDataHandlerBlob
PartBlob
implementation that wraps a PartDataHandler
.-
Method Summary
Modifier and TypeMethodDescriptionGet an input stream to read the data in the blob.getPart()
The the MIME part from which this blob was created.long
getSize()
Get the (approximate) size of the blob.void
writeTo
(OutputStream out) Write the data to a given output stream.
-
Method Details
-
getDataHandler
-
getPart
Description copied from interface:PartBlob
The the MIME part from which this blob was created. -
getInputStream
Description copied from interface:Blob
Get an input stream to read the data in the blob. A newInputStream
object is returned each time this method is called, and the stream is positioned at the beginning of the data.- Specified by:
getInputStream
in interfaceBlob
- Returns:
- the input stream to read the data from
- Throws:
IOException
-
writeTo
Description copied from interface:Blob
Write the data to a given output stream. This method can be called multiple times, i.e. it doesn't consume the content.- Specified by:
writeTo
in interfaceBlob
- Parameters:
out
- The output stream to write the data to. This method will not close the stream.- Throws:
org.apache.axiom.ext.io.StreamCopyException
- Thrown if there is an I/O when reading the data from the blob or when writing it to the stream.StreamCopyException.getOperation()
can be used to determine whether the failed operation was a read or a write.
-
getSize
public long getSize()Description copied from interface:Blob
Get the (approximate) size of the blob. Returns -1 if the size can't be determined without reading the entire blob (in which case the caller may want to useBlob.writeTo(OutputStream)
with anOutputStream
that counts the number of bytes to determine the size). The method may choose to return a value based on an estimation. This may be the case e.g. if reading the data involves a decoding operation, and the length of the resulting stream can't be determined precisely without performing the decoding operation.When reading the actual data, the code should always read until the end of the stream is reached (as indicated by the return value of the
read
methods of theInputStream
class). It must be prepared to reach the end of the stream after a number of bytes that is lower or higher than the value returned by this method.
-