Class BasicBodyFactory
java.lang.Object
org.apache.james.mime4j.message.BasicBodyFactory
- All Implemented Interfaces:
BodyFactory
Factory for creating message bodies.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class(package private) static class -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbinaryBody(byte[] buf) Creates aBinaryBodythat holds the content of the given input stream.binaryBody(String content, Charset charset) protected CharsetresolveCharset(String mimeCharset) Select the Charset for the givenmimeCharsetstring.textBody(InputStream content, String mimeCharset) Creates aTextBodythat holds the content of the given input stream.
-
Field Details
-
INSTANCE
-
defaultCharset
-
-
Constructor Details
-
BasicBodyFactory
public BasicBodyFactory() -
BasicBodyFactory
-
BasicBodyFactory
public BasicBodyFactory(boolean lenient)
-
-
Method Details
-
getDefaultCharset
- Returns:
- the defaultCharset
-
resolveCharset
Select the Charset for the given
mimeCharsetstring.If you need support for non standard or invalid
mimeCharsetspecifications you might want to create your own derivedBodyFactoryextendingBasicBodyFactoryand overriding this method as suggested by MIME4J-218The default behavior is lenient, invalid
mimeCharsetspecifications will return thedefaultCharset.- Parameters:
mimeCharset- - the string specification for a Charset e.g. "UTF-8"- Throws:
UnsupportedEncodingException- if the mimeCharset is invalid
-
textBody
- Throws:
UnsupportedEncodingException
-
textBody
-
textBody
Description copied from interface:BodyFactoryCreates aTextBodythat 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.- Specified by:
textBodyin interfaceBodyFactory- Parameters:
content- input stream to create a message body from.mimeCharset- name of a MIME charset.- Returns:
- a text body.
- Throws:
IOException- if an I/O error occurs.
-
textBody
-
textBody
-
binaryBody
-
binaryBody
Description copied from interface:BodyFactoryCreates aBinaryBodythat holds the content of the given input stream.- Specified by:
binaryBodyin interfaceBodyFactory- Parameters:
is- input stream to create a message body from.- Returns:
- a binary body.
- Throws:
IOException- if an I/O error occurs.
-
binaryBody
-