Class MemoryBlob
- All Implemented Interfaces:
Blob,WritableBlob
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Get an input stream to read the data in the blob.longDeprecated.Get the length of the data in the blob, i.e. the number of bytes.Deprecated.Create an output stream to write data to the blob.booleanDeprecated.Determine whether the blob supports reading in state NEW or UNCOMMITTED.longreadFrom(InputStream in, long length) Deprecated.Read data from the given input stream and write it to the blob.longreadFrom(InputStream in, long length, boolean commit) Deprecated.Read data from the given input stream and write it to the blob.voidrelease()Deprecated.Release all resources held by this blob.voidwriteTo(OutputStream os) Deprecated.Write the data to a given output stream.
-
Constructor Details
-
MemoryBlob
public MemoryBlob()Deprecated.
-
-
Method Details
-
isSupportingReadUncommitted
public boolean isSupportingReadUncommitted()Deprecated.Description copied from interface:WritableBlobDetermine whether the blob supports reading in state NEW or UNCOMMITTED. If this method returnsfalseand the blob is in state NEW or UNCOMMITTED, any call to a method defined by theBlobsuperinterface will result in anIllegalStateException. If this method returnstrue, then any data written to the blob will be immediately available for reading. This is also true for an input stream obtained fromBlob.getInputStream()before the data is written. This implies that it is possible for the input stream to first report the end of the stream and later allow reading additional data. Therefore, a pair of streams obtained fromWritableBlob.getOutputStream()andBlob.getInputStream()behaves differently than aPipedOutputStreamandPipedInputStreampair, because in this situationPipedInputStreamwould block.- Specified by:
isSupportingReadUncommittedin interfaceWritableBlob- Returns:
trueif the blob allows reading the data in state NEW or UNCOMMITTED;falseif the blob allows read operations only in state COMMITTED
-
getLength
public long getLength()Deprecated.Description copied from interface:BlobGet the length of the data in the blob, i.e. the number of bytes. -
getOutputStream
Deprecated.Description copied from interface:WritableBlobCreate an output stream to write data to the blob.Precondition: The blob is in state NEW.
Postcondition: The blob is in state UNCOMMITTED.
Note that the pre- and postconditions imply that this method may be called at most once for a given blob instance.
Calls to methods of the returned output stream will modify the state of the blob according to the following rules:
- A call to
OutputStream.close()will change the state to COMMITTED. - Calls to other methods will not modify the state of the blob. They will result in
an
IOExceptionif the state is COMMITTED, i.e. if the stream has already been closed.
- Specified by:
getOutputStreamin interfaceWritableBlob- Returns:
- an output stream that can be used to write data to the blob
- A call to
-
readFrom
public long readFrom(InputStream in, long length, boolean commit) throws org.apache.axiom.ext.io.StreamCopyException Deprecated.Description copied from interface:WritableBlobRead 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 will achieve this result in a more efficient way.Precondition: The blob is in state NEW or UNCOMMITTED.
Postcondition: The blob is in state UNCOMMITTED if
commitisfalse. It is in state COMMITTED ifcommitistrue.The precondition implies that this method may be used after a call to
WritableBlob.getOutputStream(). In that case it is illegal to setcommittotrue(because this would invalidate the state of the output stream).The method transfers data from the input stream to the blob until one of the following conditions is met:
- The end of the input stream is reached.
- The value of the
lengthargument is different from-1and the number of bytes transferred is equal tolength.
- Specified by:
readFromin interfaceWritableBlob- Parameters:
in- An input stream to read data from. This method will not close the stream.length- the number of bytes to transfer, or-1if the method should transfer data until the end of the input stream is reachedcommit- indicates whether the blob should be in state COMMITTED after the operation- Returns:
- the number of bytes transferred
- Throws:
org.apache.axiom.ext.io.StreamCopyException
-
readFrom
public long readFrom(InputStream in, long length) throws org.apache.axiom.ext.io.StreamCopyException Deprecated.Description copied from interface:WritableBlobRead data from the given input stream and write it to the blob.This method is similar to
WritableBlob.readFrom(InputStream, long, boolean), except that the state of the blob after the invocation (i.e. thecommitargument) is determined automatically:State transitions Precondition (state) Postcondition (state) NEW COMMITTED UNCOMMITTED UNCOMMITTED COMMITTED illegal There are thus two usage patterns for this method:
- The method is used to fill the blob with the data from an input stream, but no other data is written to the blob.
- The method is used in parallel with the output stream returned by
WritableBlob.getOutputStream(): some data is written using the output stream and some data is written using this method (for efficiency reasons).
- Specified by:
readFromin interfaceWritableBlob- Parameters:
in- An input stream to read data from. This method will not close the stream.length- the number of bytes to transfer, or-1if the method should transfer data until the end of the input stream is reached- Returns:
- the number of bytes transferred
- Throws:
org.apache.axiom.ext.io.StreamCopyException
-
getInputStream
Deprecated.Description copied from interface:BlobGet an input stream to read the data in the blob.- Specified by:
getInputStreamin interfaceBlob- Returns:
- the input stream to read the data from
- Throws:
IOException
-
writeTo
Deprecated.Description copied from interface:BlobWrite the data to a given output stream.- Specified by:
writeToin interfaceBlob- Parameters:
os- 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.
-
release
public void release()Deprecated.Description copied from interface:WritableBlobRelease all resources held by this blob.- Specified by:
releasein interfaceWritableBlob
-
MemoryBlobinstead.