public class StorageBodyFactory extends Object implements BodyFactory
Constructor and Description |
---|
StorageBodyFactory()
Creates a new
BodyFactory instance that uses the default
storage provider for creating message bodies from input streams. |
StorageBodyFactory(StorageProvider storageProvider,
DecodeMonitor monitor)
Creates a new
BodyFactory instance that uses the given
storage provider for creating message bodies from input streams. |
Modifier and Type | Method and Description |
---|---|
BinaryBody |
binaryBody(InputStream is)
Creates a
BinaryBody that holds the content of the given input
stream. |
BinaryBody |
binaryBody(Storage storage)
Creates a
BinaryBody that holds the content of the given
Storage . |
StorageProvider |
getStorageProvider()
Returns the
StorageProvider this BodyFactory
uses to create message bodies from input streams. |
TextBody |
textBody(InputStream is)
Creates a
TextBody that holds the content of the given input
stream. |
TextBody |
textBody(InputStream is,
String mimeCharset)
Creates a
TextBody that holds the content of the given input
stream. |
TextBody |
textBody(Storage storage)
|
TextBody |
textBody(Storage storage,
String mimeCharset)
|
TextBody |
textBody(String text)
Creates a
TextBody that holds the content of the given string. |
TextBody |
textBody(String text,
String mimeCharset)
Creates a
TextBody that holds the content of the given string. |
public StorageBodyFactory()
BodyFactory
instance that uses the default
storage provider for creating message bodies from input streams.public StorageBodyFactory(StorageProvider storageProvider, DecodeMonitor monitor)
BodyFactory
instance that uses the given
storage provider for creating message bodies from input streams.storageProvider
- a storage provider or null
to use the default
one.public StorageProvider getStorageProvider()
StorageProvider
this BodyFactory
uses to create message bodies from input streams.StorageProvider
.public BinaryBody binaryBody(InputStream is) throws IOException
BinaryBody
that holds the content of the given input
stream.binaryBody
in interface BodyFactory
is
- input stream to create a message body from.IOException
- if an I/O error occurs.public BinaryBody binaryBody(Storage storage) throws IOException
BinaryBody
that holds the content of the given
Storage
.
Note that the caller must not invoke delete()
on
the given Storage
object after it has been passed to this
method. Instead the message body created by this method takes care of
deleting the storage when it gets disposed of (see
Disposable.dispose()
).
storage
- storage to create a message body from.IOException
- if an I/O error occurs.public TextBody textBody(InputStream is) throws IOException
TextBody
that holds the content of the given input
stream.
"us-ascii" is used to decode the byte content of the
Storage
into a character stream when calling
getReader()
on the returned object.
is
- input stream to create a message body from.IOException
- if an I/O error occurs.public TextBody textBody(InputStream is, String mimeCharset) throws IOException
TextBody
that holds the content of the given input
stream.
The charset corresponding to the given MIME charset name is used to
decode the byte content of the input stream into a character stream when
calling getReader()
on the returned object.
If the MIME charset has no corresponding Java charset or the Java charset
cannot be used for decoding then "us-ascii" is used instead.
textBody
in interface BodyFactory
is
- input stream to create a message body from.mimeCharset
- name of a MIME charset.IOException
- if an I/O error occurs.public TextBody textBody(Storage storage) throws IOException
TextBody
that holds the content of the given
Storage
.
"us-ascii" is used to decode the byte content of the
Storage
into a character stream when calling
getReader()
on the returned object.
Note that the caller must not invoke delete()
on
the given Storage
object after it has been passed to this
method. Instead the message body created by this method takes care of
deleting the storage when it gets disposed of (see
Disposable.dispose()
).
storage
- storage to create a message body from.IOException
- if an I/O error occurs.public TextBody textBody(Storage storage, String mimeCharset) throws IOException
TextBody
that holds the content of the given
Storage
.
The charset corresponding to the given MIME charset name is used to
decode the byte content of the Storage
into a character
stream when calling getReader()
on the
returned object. If the MIME charset has no corresponding Java charset or
the Java charset cannot be used for decoding then "us-ascii" is
used instead.
Note that the caller must not invoke delete()
on
the given Storage
object after it has been passed to this
method. Instead the message body created by this method takes care of
deleting the storage when it gets disposed of (see
Disposable.dispose()
).
storage
- storage to create a message body from.mimeCharset
- name of a MIME charset.IOException
- if an I/O error occurs.public TextBody textBody(String text)
TextBody
that holds the content of the given string.
"us-ascii" is used to encode the characters of the string into
a byte stream when calling
writeTo(OutputStream)
on
the returned object.
text
- text to create a message body from.public TextBody textBody(String text, String mimeCharset)
TextBody
that holds the content of the given string.
The charset corresponding to the given MIME charset name is used to
encode the characters of the string into a byte stream when calling
writeTo(OutputStream)
on
the returned object. If the MIME charset has no corresponding Java
charset or the Java charset cannot be used for encoding then
"us-ascii" is used instead.
text
- text to create a message body from.mimeCharset
- name of a MIME charset.Copyright © 2004-2012 The Apache Software Foundation. All Rights Reserved.