Class Message.Builder
java.lang.Object
org.apache.james.mime4j.internal.AbstractEntityBuilder
org.apache.james.mime4j.dom.Message.Builder
- Enclosing interface:
Message
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BodyDescriptorBuilderprivate BodyFactoryprivate MimeConfigprivate FieldParser<?> private booleanprivate DecodeMonitorprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdds a field to the end of the list of fields.build()Clears all fields.Enables disable content decoding forparse(java.io.InputStream)operation.Disables flat parsing mode forparse(java.io.InputStream)operation.Enables automatic content decoding forparse(java.io.InputStream)operation.Enables flat parsing mode forparse(java.io.InputStream)operation.generateMessageId(String hostname) Generates and sets message ID for this message.private AddressListgetAddressList(String fieldName) getBcc()Returns the value of the Bcc header field of this message asAddressListobject ornullif it is not present.getCc()Returns the value of the Cc header field of this message asAddressListobject ornullif it is not present.getDate()Returns the value of the Date header field of this message asDateobject ornullif it is not present.getFrom()Returns the value of the From header field of this message asMailboxListobject ornullif it is not present.private MailboxgetMailbox(String fieldName) private MailboxListgetMailboxList(String fieldName) Returns the value of the Message-ID header field of this message ornullif it is not present.Returns the value of the Reply-To header field of this message asAddressListobject ornullif it is not present.Returns the value of the Sender header field of this message asMailboxobject ornullif it is not present.Returns the (decoded) value of the Subject header field of this message ornullif it is not present.getTo()Returns the value of the To header field of this message asAddressListobject ornullif it is not present.static Message.Builderof()static Message.Builderof(InputStream is) static Message.Builderparse(InputStream is) parseAddresses(String... addresses) parseMailboxes(String... mailboxes) removeFields(String name) Removes allFields having the specified field name.private Message.BuildersetAddressList(String fieldName, String address) private Message.BuildersetAddressList(String fieldName, String... addresses) private Message.BuildersetAddressList(String fieldName, Collection<? extends Address> addresses) private Message.BuildersetAddressList(String fieldName, Address address) private Message.BuildersetAddressList(String fieldName, Address... addresses) setBcc(Collection<? extends Address> bcc) Sets Bcc header field of this message to the specified addresses.Sets Bcc header field of this message to the specified address.Sets Bcc header field of this message to the specified addresses.Sets binary content of this message with the given MIME type.Sets text of this message with the given MIME subtype and charset.Sets text of this message with the charset.setBody(BinaryBody binaryBody) Sets binaryBody of this message.Sets body of this message.Sets body of this message.Sets body of this message.Sets body of this message.setCc(Collection<? extends Address> cc) Sets Cc header field of this message to the specified addresses.Sets Cc header field of this message to the specified address.Sets Cc header field of this message to the specified addresses.setContentDisposition(String dispositionType) Sets content disposition of this message to the specified disposition type.setContentDisposition(String dispositionType, String filename) Sets content disposition of this message to the specified disposition type and filename.setContentDisposition(String dispositionType, String filename, long size) Sets content disposition of this message to the specified values.setContentDisposition(String dispositionType, String filename, long size, Date creationDate, Date modificationDate, Date readDate) Sets content disposition of this message to the specified values.setContentTransferEncoding(String contentTransferEncoding) Sets transfer encoding of this message.setContentType(String mimeType, NameValuePair... parameters) Sets transfer encoding of this message.Sets Date header field for this message.Sets Date header field for this message.Sets or replaces a field.Sets From header field of this message to the specified mailbox address.Sets From header field of this message to the specified mailbox addresses.setFrom(Collection<Mailbox> from) Sets From header field of this message to the specified mailbox addresses.Sets From header field of this message to the specified mailbox address.Sets From header field of this message to the specified mailbox addresses.private Message.BuildersetMailbox(String fieldName, String mailbox) private Message.BuildersetMailbox(String fieldName, Mailbox mailbox) private Message.BuildersetMailboxList(String fieldName, String mailbox) private Message.BuildersetMailboxList(String fieldName, String... mailboxes) private Message.BuildersetMailboxList(String fieldName, Collection<Mailbox> mailboxes) private Message.BuildersetMailboxList(String fieldName, Mailbox mailbox) private Message.BuildersetMailboxList(String fieldName, Mailbox... mailboxes) setMessageId(String messageId) Sets message ID for this message.setReplyTo(Collection<? extends Address> replyTo) Sets Reply-To header field of this message to the specified addresses.setReplyTo(Address replyTo) Sets Reply-To header field of this message to the specified address.setReplyTo(Address... replyTo) Sets Reply-To header field of this message to the specified addresses.Sets Sender header field of this message to the specified mailbox address.Sets Sender header field of this message to the specified mailbox address.setSubject(String subject) Sets Subject header field for this message.Sets To header field of this message to the specified address.Sets To header field of this message to the specified addresses.setTo(Collection<? extends Address> to) Sets To header field of this message to the specified addresses.Sets To header field of this message to the specified address.Sets To header field of this message to the specified addresses.use(DecodeMonitor monitor) SetsDecodeMonitorthat will be used to handle malformed data when executingparse(java.io.InputStream).use(FieldParser<?> fieldParser) SetsFieldParserthat will be used to generate parse message fields when executingparse(java.io.InputStream).use(BodyFactory bodyFactory) SetsBodyFactorythat will be used to generate message body.use(BodyDescriptorBuilder bodyDescBuilder) SetsBodyDescriptorBuilderthat will be used to generate body descriptors when executingparse(java.io.InputStream).use(MimeConfig config) Sets MIME configuration.Methods inherited from class AbstractEntityBuilder
containsField, getBody, getCharset, getContentTransferEncoding, getCreationDate, getDispositionType, getField, getField, getFields, getFields, getFields, getFilename, getMimeType, getModificationDate, getReadDate, getSize, obtainField, setBody, setBody, setBody
-
Field Details
-
config
-
monitor
-
bodyDescBuilder
-
fieldParser
-
bodyFactory
-
flatMode
private boolean flatMode -
rawContent
private boolean rawContent
-
-
Constructor Details
-
Builder
private Builder()
-
-
Method Details
-
of
-
of
-
of
- Throws:
IOException
-
use
Sets MIME configuration.- Parameters:
config- the configuration.
-
use
SetsDecodeMonitorthat will be used to handle malformed data when executingparse(java.io.InputStream).- Parameters:
monitor- the decoder monitor.
-
use
SetsBodyDescriptorBuilderthat will be used to generate body descriptors when executingparse(java.io.InputStream).- Parameters:
bodyDescBuilder- the body descriptor builder.
-
use
SetsFieldParserthat will be used to generate parse message fields when executingparse(java.io.InputStream).- Parameters:
fieldParser- the field parser.
-
use
SetsBodyFactorythat will be used to generate message body.- Parameters:
bodyFactory- the body factory.
-
enableFlatMode
Enables flat parsing mode forparse(java.io.InputStream)operation. -
disableFlatMode
Disables flat parsing mode forparse(java.io.InputStream)operation. -
enableContentDecoding
Enables automatic content decoding forparse(java.io.InputStream)operation. -
disableContentDecoding
Enables disable content decoding forparse(java.io.InputStream)operation. -
copy
-
setField
Description copied from class:AbstractEntityBuilderSets or replaces a field. This method is useful for header fields such as Subject or Message-ID that should not occur more than once in a message. If this builder does not already contain a header field of the same name as the given field then it is added to the end of the list of fields (same behavior asAbstractEntityBuilder.addField(org.apache.james.mime4j.stream.Field)). Otherwise the first occurrence of a field with the same name is replaced by the given field and all further occurrences are removed.- Overrides:
setFieldin classAbstractEntityBuilder- Parameters:
field- the field to set.
-
addField
Description copied from class:AbstractEntityBuilderAdds a field to the end of the list of fields.- Overrides:
addFieldin classAbstractEntityBuilder- Parameters:
field- the field to add.
-
removeFields
Description copied from class:AbstractEntityBuilderRemoves allFields having the specified field name.- Overrides:
removeFieldsin classAbstractEntityBuilder- Parameters:
name- the field name (e.g. From, Subject).
-
clearFields
Description copied from class:AbstractEntityBuilderClears all fields.- Overrides:
clearFieldsin classAbstractEntityBuilder
-
setContentTransferEncoding
Description copied from class:AbstractEntityBuilderSets transfer encoding of this message.- Overrides:
setContentTransferEncodingin classAbstractEntityBuilder- Parameters:
contentTransferEncoding- transfer encoding to use.
-
setContentType
Description copied from class:AbstractEntityBuilderSets transfer encoding of this message.- Overrides:
setContentTypein classAbstractEntityBuilder- Parameters:
mimeType- MIME type of this message the MIME type to use.parameters- content type parameters to use.
-
setContentDisposition
Description copied from class:AbstractEntityBuilderSets content disposition of this message to the specified disposition type. No filename, size or date parameters are included in the content disposition.- Overrides:
setContentDispositionin classAbstractEntityBuilder- Parameters:
dispositionType- disposition type value (usuallyinlineorattachment).
-
setContentDisposition
Description copied from class:AbstractEntityBuilderSets content disposition of this message to the specified disposition type and filename. No size or date parameters are included in the content disposition.- Overrides:
setContentDispositionin classAbstractEntityBuilder- Parameters:
dispositionType- disposition type value (usuallyinlineorattachment).filename- filename parameter value ornullif the parameter should not be included.
-
setContentDisposition
Description copied from class:AbstractEntityBuilderSets content disposition of this message to the specified values. No date parameters are included in the content disposition.- Overrides:
setContentDispositionin classAbstractEntityBuilder- Parameters:
dispositionType- disposition type value (usuallyinlineorattachment).filename- filename parameter value ornullif the parameter should not be included.size- size parameter value or-1if the parameter should not be included.
-
setContentDisposition
public Message.Builder setContentDisposition(String dispositionType, String filename, long size, Date creationDate, Date modificationDate, Date readDate) Description copied from class:AbstractEntityBuilderSets content disposition of this message to the specified values.- Overrides:
setContentDispositionin classAbstractEntityBuilder- Parameters:
dispositionType- disposition type value (usuallyinlineorattachment).filename- filename parameter value ornullif the parameter should not be included.size- size parameter value or-1if the parameter should not be included.creationDate- creation-date parameter value ornullif the parameter should not be included.modificationDate- modification-date parameter value ornullif the parameter should not be included.readDate- read-date parameter value ornullif the parameter should not be included.
-
setBody
Description copied from class:AbstractEntityBuilderSets body of this message. Also sets the content type based on properties of the givenBody.- Overrides:
setBodyin classAbstractEntityBuilder- Parameters:
body- the body.
-
setBody
Description copied from class:AbstractEntityBuilderSets body of this message. Also sets the content type based on properties of the givenBody.- Overrides:
setBodyin classAbstractEntityBuilder- Parameters:
textBody- the body.
-
setBody
Description copied from class:AbstractEntityBuilderSets binaryBody of this message. Also sets the content type based on properties of the givenBody.- Overrides:
setBodyin classAbstractEntityBuilder- Parameters:
binaryBody- the binaryBody.
-
setBody
Description copied from class:AbstractEntityBuilderSets body of this message. Also sets the content type based on properties of the givenMultipart.- Overrides:
setBodyin classAbstractEntityBuilder- Parameters:
multipart- the body.
-
setBody
Description copied from class:AbstractEntityBuilderSets body of this message. Also sets the content type based on properties of the givenMessage.- Overrides:
setBodyin classAbstractEntityBuilder- Parameters:
message- the body.
-
setBody
Sets text of this message with the charset.- Parameters:
text- the text.charset- the charset of the text.- Throws:
IOException
-
setBody
Sets text of this message with the given MIME subtype and charset.- Parameters:
text- the text.subtype- the text subtype (e.g. "plain", "html" or "xml").charset- the charset of the text.- Throws:
IOException
-
setBody
Sets binary content of this message with the given MIME type.- Parameters:
bin- the body.mimeType- the MIME media type of the specified body ("type/subtype").- Throws:
IOException
-
getMessageId
Returns the value of the Message-ID header field of this message ornullif it is not present.- Returns:
- the identifier of this message.
-
generateMessageId
Generates and sets message ID for this message.- Parameters:
hostname- host name to be included in the identifier ornullif no host name should be included.
-
setMessageId
Sets message ID for this message.- Parameters:
messageId- the message ID.
-
getSubject
Returns the (decoded) value of the Subject header field of this message ornullif it is not present.- Returns:
- the subject of this message.
-
setSubject
Sets Subject header field for this message. The specified string may contain non-ASCII characters, in which case it gets encoded as an 'encoded-word' automatically.- Parameters:
subject- subject to set ornullto remove the subject header field.
-
getDate
Returns the value of the Date header field of this message asDateobject ornullif it is not present.- Returns:
- the date of this message.
-
setDate
Sets Date header field for this message. This method uses the defaultTimeZoneof this host to encode the specifiedDateobject into a string.- Parameters:
date- date to set ornullto remove the date header field.
-
setDate
Sets Date header field for this message. The specifiedTimeZoneis used to encode the specifiedDateobject into a string.- Parameters:
date- date to set ornullto remove the date header field.zone- a time zone.
-
getSender
Returns the value of the Sender header field of this message asMailboxobject ornullif it is not present.- Returns:
- the sender of this message.
-
setSender
Sets Sender header field of this message to the specified mailbox address.- Parameters:
sender- address to set ornullto remove the header field.
-
setSender
Sets Sender header field of this message to the specified mailbox address.- Parameters:
sender- address to set ornullto remove the header field.- Throws:
ParseException
-
getFrom
Returns the value of the From header field of this message asMailboxListobject ornullif it is not present.- Returns:
- value of the from field of this message.
-
setFrom
Sets From header field of this message to the specified mailbox address.- Parameters:
from- address to set ornullto remove the header field.
-
setFrom
Sets From header field of this message to the specified mailbox address.- Parameters:
from- address to set ornullto remove the header field.- Throws:
ParseException
-
setFrom
Sets From header field of this message to the specified mailbox addresses.- Parameters:
from- addresses to set ornullor no arguments to remove the header field.
-
setFrom
Sets From header field of this message to the specified mailbox addresses.- Parameters:
from- addresses to set ornullor no arguments to remove the header field.- Throws:
ParseException
-
setFrom
Sets From header field of this message to the specified mailbox addresses.- Parameters:
from- addresses to set ornullor an empty collection to remove the header field.
-
getTo
Returns the value of the To header field of this message asAddressListobject ornullif it is not present.- Returns:
- value of the to field of this message.
-
setTo
Sets To header field of this message to the specified address.- Parameters:
to- address to set ornullto remove the header field.
-
setTo
Sets To header field of this message to the specified address.- Parameters:
to- address to set ornullto remove the header field.- Throws:
ParseException
-
setTo
Sets To header field of this message to the specified addresses.- Parameters:
to- addresses to set ornullor no arguments to remove the header field.
-
setTo
Sets To header field of this message to the specified addresses.- Parameters:
to- addresses to set ornullor no arguments to remove the header field.- Throws:
ParseException
-
setTo
Sets To header field of this message to the specified addresses.- Parameters:
to- addresses to set ornullor an empty collection to remove the header field.
-
getCc
Returns the value of the Cc header field of this message asAddressListobject ornullif it is not present.- Returns:
- value of the cc field of this message.
-
setCc
Sets Cc header field of this message to the specified address.- Parameters:
cc- address to set ornullto remove the header field.
-
setCc
Sets Cc header field of this message to the specified addresses.- Parameters:
cc- addresses to set ornullor no arguments to remove the header field.
-
setCc
Sets Cc header field of this message to the specified addresses.- Parameters:
cc- addresses to set ornullor an empty collection to remove the header field.
-
getBcc
Returns the value of the Bcc header field of this message asAddressListobject ornullif it is not present.- Returns:
- value of the bcc field of this message.
-
setBcc
Sets Bcc header field of this message to the specified address.- Parameters:
bcc- address to set ornullto remove the header field.
-
setBcc
Sets Bcc header field of this message to the specified addresses.- Parameters:
bcc- addresses to set ornullor no arguments to remove the header field.
-
setBcc
Sets Bcc header field of this message to the specified addresses.- Parameters:
bcc- addresses to set ornullor an empty collection to remove the header field.
-
getReplyTo
Returns the value of the Reply-To header field of this message asAddressListobject ornullif it is not present.- Returns:
- value of the reply to field of this message.
-
setReplyTo
Sets Reply-To header field of this message to the specified address.- Parameters:
replyTo- address to set ornullto remove the header field.
-
setReplyTo
Sets Reply-To header field of this message to the specified addresses.- Parameters:
replyTo- addresses to set ornullor no arguments to remove the header field.
-
setReplyTo
Sets Reply-To header field of this message to the specified addresses.- Parameters:
replyTo- addresses to set ornullor an empty collection to remove the header field.
-
parse
- Throws:
IOException
-
build
-
getMailbox
-
setMailbox
-
setMailbox
- Throws:
ParseException
-
getMailboxList
-
setMailboxList
-
setMailboxList
- Throws:
ParseException
-
setMailboxList
-
parseMailboxes
- Throws:
ParseException
-
setMailboxList
- Throws:
ParseException
-
setMailboxList
-
getAddressList
-
setAddressList
-
setAddressList
- Throws:
ParseException
-
setAddressList
-
parseAddresses
- Throws:
ParseException
-
setAddressList
- Throws:
ParseException
-
setAddressList
-