Package org.apache.james.mime4j.storage
Class StorageBinaryBody
- java.lang.Object
-
- org.apache.james.mime4j.dom.SingleBody
-
- org.apache.james.mime4j.dom.BinaryBody
-
- org.apache.james.mime4j.storage.StorageBinaryBody
-
- All Implemented Interfaces:
Body
,Disposable
class StorageBinaryBody extends BinaryBody
Binary body backed by aStorage
-
-
Field Summary
Fields Modifier and Type Field Description private MultiReferenceStorage
storage
-
Constructor Summary
Constructors Constructor Description StorageBinaryBody(MultiReferenceStorage storage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StorageBinaryBody
copy()
Returns a copy of thisSingleBody
(optional operation).void
dispose()
Deletes the Storage that holds the content of this binary body.java.io.InputStream
getInputStream()
Gets aInputStream
which reads the bytes of the body.void
writeTo(java.io.OutputStream out)
Writes this single body to the given stream.-
Methods inherited from class org.apache.james.mime4j.dom.SingleBody
getParent, setParent, size
-
-
-
-
Field Detail
-
storage
private MultiReferenceStorage storage
-
-
Constructor Detail
-
StorageBinaryBody
public StorageBinaryBody(MultiReferenceStorage storage)
-
-
Method Detail
-
getInputStream
public java.io.InputStream getInputStream() throws java.io.IOException
Description copied from class:SingleBody
Gets aInputStream
which reads the bytes of the body.- Specified by:
getInputStream
in classSingleBody
- Returns:
- the stream, transfer decoded
- Throws:
java.io.IOException
- on I/O errors.
-
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOException
Description copied from class:SingleBody
Writes this single body to the given stream. The default implementation copies the input stream obtained bySingleBody.getInputStream()
to the specified output stream. May be overwritten by a subclass to improve performance.- Overrides:
writeTo
in classSingleBody
- Parameters:
out
- the stream to write to.- Throws:
java.io.IOException
- in case of an I/O error
-
copy
public StorageBinaryBody copy()
Description copied from class:SingleBody
Returns a copy of thisSingleBody
(optional operation).The general contract of this method is as follows:
- Invoking
SingleBody.getParent()
on the copy returnsnull
. That means that the copy is detached from the parent entity of thisSingleBody
. The copy may get attached to a different entity later on. - The underlying content does not have to be copied. Instead it may be
shared between multiple copies of a
SingleBody
. - If the underlying content is shared by multiple copies the implementation has to make sure that the content gets deleted when the last copy gets disposed of (and not before that).
This implementation always throws an
UnsupportedOperationException
.- Overrides:
copy
in classSingleBody
- Returns:
- a copy of this
SingleBody
.
- Invoking
-
dispose
public void dispose()
Deletes the Storage that holds the content of this binary body.- Specified by:
dispose
in interfaceDisposable
- Overrides:
dispose
in classSingleBody
- See Also:
Disposable.dispose()
-
-