Package org.apache.axiom.blob
Interface Blob
-
- All Known Subinterfaces:
MemoryBlob
,OverflowableBlob
,WritableBlob
- All Known Implementing Classes:
AbstractWritableBlob
public interface Blob
Stores binary data.Blobs are thread safe in the sense that methods defined by this interface may be called concurrently. In addition, two different threads can safely invoke methods on two different
InputStream
instances retrieved bygetInputStream()
concurrently. However some blobs (in particularWritableBlob
implementations) may define additional methods and invoking these methods concurrently with methods defined by this interface is generally not thread safe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description InputStream
getInputStream()
Get an input stream to read the data in the blob.long
getSize()
Get the size of the blob.void
writeTo(OutputStream out)
Write the data to a given output stream.
-
-
-
Method Detail
-
getInputStream
InputStream getInputStream() throws IOException
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.- Returns:
- the input stream to read the data from
- Throws:
IOException
-
writeTo
void writeTo(OutputStream out) throws StreamCopyException
Write the data to a given output stream. This method can be called multiple times, i.e. it doesn't consume the content.- Parameters:
out
- The output stream to write the data to. This method will not close the stream.- Throws:
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
long getSize()
Get the size of the blob.- Returns:
- the number of bytes in the blob
-
-