public class BasicBodyFactory extends java.lang.Object implements BodyFactory
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
BasicBodyFactory.BinaryBody1 |
(package private) static class |
BasicBodyFactory.BinaryBody2 |
(package private) static class |
BasicBodyFactory.StringBody1 |
(package private) static class |
BasicBodyFactory.StringBody2 |
| Modifier and Type | Field and Description |
|---|---|
private java.nio.charset.Charset |
defaultCharset |
static BasicBodyFactory |
INSTANCE |
| Constructor and Description |
|---|
BasicBodyFactory() |
BasicBodyFactory(boolean lenient) |
BasicBodyFactory(java.nio.charset.Charset defaultCharset) |
| Modifier and Type | Method and Description |
|---|---|
BinaryBody |
binaryBody(byte[] buf) |
BinaryBody |
binaryBody(java.io.InputStream is)
Creates a
BinaryBody that holds the content of the given input
stream. |
BinaryBody |
binaryBody(java.lang.String content,
java.nio.charset.Charset charset) |
java.nio.charset.Charset |
getDefaultCharset() |
protected java.nio.charset.Charset |
resolveCharset(java.lang.String mimeCharset)
select the Charset for the given mimeCharset string
if you need support for non standard or invalid mimeCharset specifications you might want to
create your own derived BodyFactory extending BasicBodyFactory and overriding this method as
suggested by: https://issues.apache.org/jira/browse/MIME4J-218
the default behavior is lenient, invalid mimeCharset specifications will return the
defaultCharset
|
TextBody |
textBody(byte[] content,
java.nio.charset.Charset charset) |
TextBody |
textBody(java.io.InputStream content,
java.lang.String mimeCharset)
Creates a
TextBody that holds the content of the given input
stream. |
TextBody |
textBody(java.lang.String text) |
TextBody |
textBody(java.lang.String text,
java.nio.charset.Charset charset) |
TextBody |
textBody(java.lang.String text,
java.lang.String mimeCharset) |
public static final BasicBodyFactory INSTANCE
private final java.nio.charset.Charset defaultCharset
public BasicBodyFactory()
public BasicBodyFactory(java.nio.charset.Charset defaultCharset)
public BasicBodyFactory(boolean lenient)
public java.nio.charset.Charset getDefaultCharset()
protected java.nio.charset.Charset resolveCharset(java.lang.String mimeCharset)
throws java.io.UnsupportedEncodingException
mimeCharset - - the string specification for a Charset e.g. "UTF-8"java.io.UnsupportedEncodingException - if the mimeCharset is invalidpublic TextBody textBody(java.lang.String text, java.lang.String mimeCharset) throws java.io.UnsupportedEncodingException
java.io.UnsupportedEncodingExceptionpublic TextBody textBody(byte[] content, java.nio.charset.Charset charset)
public TextBody textBody(java.io.InputStream content, java.lang.String mimeCharset) throws java.io.IOException
BodyFactoryTextBody 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 BodyFactorycontent - input stream to create a message body from.mimeCharset - name of a MIME charset.java.io.IOException - if an I/O error occurs.public TextBody textBody(java.lang.String text, java.nio.charset.Charset charset)
public TextBody textBody(java.lang.String text)
public BinaryBody binaryBody(java.lang.String content, java.nio.charset.Charset charset)
public BinaryBody binaryBody(java.io.InputStream is) throws java.io.IOException
BodyFactoryBinaryBody that holds the content of the given input
stream.binaryBody in interface BodyFactoryis - input stream to create a message body from.java.io.IOException - if an I/O error occurs.public BinaryBody binaryBody(byte[] buf)