Package org.apache.axiom.blob
Class AbstractWritableBlob
- java.lang.Object
-
- org.apache.axiom.blob.AbstractWritableBlob
-
- All Implemented Interfaces:
Blob
,WritableBlob
public abstract class AbstractWritableBlob extends Object implements WritableBlob
Partial implementation of theWritableBlob
interface that implementsWritableBlob.readFrom(InputStream)
usingWritableBlob.getOutputStream()
andBlob.writeTo(OutputStream)
usingBlob.getInputStream()
.
-
-
Constructor Summary
Constructors Constructor Description AbstractWritableBlob()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
readFrom(InputStream in)
Read data from the given input stream and write it to the blob.void
writeTo(OutputStream out)
Write the data to a given output stream.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.axiom.blob.Blob
getInputStream, getSize
-
Methods inherited from interface org.apache.axiom.blob.WritableBlob
getOutputStream, release
-
-
-
-
Method Detail
-
readFrom
public long readFrom(InputStream in) throws StreamCopyException
Description copied from interface:WritableBlob
Read data from the given input stream and write it to the blob.A call to this method has the same effect as requesting an output stream using
WritableBlob.getOutputStream()
and copying the data from the input stream to that output stream, but the implementation may achieve this result in a more efficient way.The blob must be in state NEW when this method is called. It will be in state COMMITTED after this method completes successfully.
The method transfers data from the input stream to the blob until the end of the input stream is reached.
- Specified by:
readFrom
in interfaceWritableBlob
- Parameters:
in
- An input stream to read data from. This method will not close the stream.- Returns:
- the number of bytes transferred
- Throws:
StreamCopyException
-
writeTo
public void writeTo(OutputStream out) throws StreamCopyException
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:
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.
-
-