public static class Message.Builder extends AbstractEntityBuilder
Modifier and Type | Method and Description |
---|---|
Message.Builder |
addField(Field field)
Adds a field to the end of the list of fields.
|
Message |
build() |
Message.Builder |
clearFields()
Clears all fields.
|
Message.Builder |
copy(Message other) |
Message.Builder |
disableContentDecoding()
Enables disable content decoding for
parse(java.io.InputStream) operation. |
Message.Builder |
disableFlatMode()
Disables flat parsing mode for
parse(java.io.InputStream) operation. |
Message.Builder |
enableContentDecoding()
Enables automatic content decoding for
parse(java.io.InputStream) operation. |
Message.Builder |
enableFlatMode()
Enables flat parsing mode for
parse(java.io.InputStream) operation. |
Message.Builder |
generateMessageId(String hostname)
Generates and sets message ID for this message.
|
AddressList |
getBcc()
Returns the value of the Bcc header field of this message as
AddressList object or null if it is not
present. |
AddressList |
getCc()
Returns the value of the Cc header field of this message as
AddressList object or null if it is not
present. |
Date |
getDate()
Returns the value of the Date header field of this message as
Date object or null if it is not present. |
MailboxList |
getFrom()
Returns the value of the From header field of this message as
MailboxList object or null if it is not
present. |
String |
getMessageId()
Returns the value of the Message-ID header field of this message
or
null if it is not present. |
AddressList |
getReplyTo()
Returns the value of the Reply-To header field of this message as
AddressList object or null if it is not
present. |
Mailbox |
getSender()
Returns the value of the Sender header field of this message as
Mailbox object or null if it is not
present. |
String |
getSubject()
Returns the (decoded) value of the Subject header field of this
message or
null if it is not present. |
AddressList |
getTo()
Returns the value of the To header field of this message as
AddressList object or null if it is not
present. |
static Message.Builder |
of() |
static Message.Builder |
of(InputStream is) |
static Message.Builder |
of(Message other) |
Message.Builder |
parse(InputStream is) |
Message.Builder |
removeFields(String name)
Removes all
Field s having the specified field name. |
Message.Builder |
setBcc(Address... bcc)
Sets Bcc header field of this message to the specified
addresses.
|
Message.Builder |
setBcc(Address bcc)
Sets Bcc header field of this message to the specified
address.
|
Message.Builder |
setBcc(Collection<? extends Address> bcc)
Sets Bcc header field of this message to the specified
addresses.
|
Message.Builder |
setBody(BinaryBody binaryBody)
Sets binaryBody of this message.
|
Message.Builder |
setBody(Body body)
Sets body of this message.
|
Message.Builder |
setBody(byte[] bin,
String mimeType)
Sets binary content of this message with the given MIME type.
|
Message.Builder |
setBody(Message message)
Sets body of this message.
|
Message.Builder |
setBody(Multipart multipart)
Sets body of this message.
|
Message.Builder |
setBody(String text,
Charset charset)
Sets text of this message with the charset.
|
Message.Builder |
setBody(String text,
String subtype,
Charset charset)
Sets text of this message with the given MIME subtype and charset.
|
Message.Builder |
setBody(TextBody textBody)
Sets body of this message.
|
Message.Builder |
setCc(Address... cc)
Sets Cc header field of this message to the specified
addresses.
|
Message.Builder |
setCc(Address cc)
Sets Cc header field of this message to the specified
address.
|
Message.Builder |
setCc(Collection<? extends Address> cc)
Sets Cc header field of this message to the specified
addresses.
|
Message.Builder |
setContentDisposition(String dispositionType)
Sets content disposition of this message to the
specified disposition type.
|
Message.Builder |
setContentDisposition(String dispositionType,
String filename)
Sets content disposition of this message to the
specified disposition type and filename.
|
Message.Builder |
setContentDisposition(String dispositionType,
String filename,
long size)
Sets content disposition of this message to the
specified values.
|
Message.Builder |
setContentDisposition(String dispositionType,
String filename,
long size,
Date creationDate,
Date modificationDate,
Date readDate)
Sets content disposition of this message to the
specified values.
|
Message.Builder |
setContentTransferEncoding(String contentTransferEncoding)
Sets transfer encoding of this message.
|
Message.Builder |
setContentType(String mimeType,
NameValuePair... parameters)
Sets transfer encoding of this message.
|
Message.Builder |
setDate(Date date)
Sets Date header field for this message.
|
Message.Builder |
setDate(Date date,
TimeZone zone)
Sets Date header field for this message.
|
Message.Builder |
setField(Field field)
Sets or replaces a field.
|
Message.Builder |
setFrom(Collection<Mailbox> from)
Sets From header field of this message to the specified
mailbox addresses.
|
Message.Builder |
setFrom(Mailbox... from)
Sets From header field of this message to the specified
mailbox addresses.
|
Message.Builder |
setFrom(Mailbox from)
Sets From header field of this message to the specified
mailbox address.
|
Message.Builder |
setFrom(String... from)
Sets From header field of this message to the specified
mailbox addresses.
|
Message.Builder |
setFrom(String from)
Sets From header field of this message to the specified
mailbox address.
|
Message.Builder |
setMessageId(String messageId)
Sets message ID for this message.
|
Message.Builder |
setReplyTo(Address... replyTo)
Sets Reply-To header field of this message to the specified
addresses.
|
Message.Builder |
setReplyTo(Address replyTo)
Sets Reply-To header field of this message to the specified
address.
|
Message.Builder |
setReplyTo(Collection<? extends Address> replyTo)
Sets Reply-To header field of this message to the specified
addresses.
|
Message.Builder |
setSender(Mailbox sender)
Sets Sender header field of this message to the specified
mailbox address.
|
Message.Builder |
setSender(String sender)
Sets Sender header field of this message to the specified
mailbox address.
|
Message.Builder |
setSubject(String subject)
Sets Subject header field for this message.
|
Message.Builder |
setTo(Address... to)
Sets To header field of this message to the specified
addresses.
|
Message.Builder |
setTo(Address to)
Sets To header field of this message to the specified
address.
|
Message.Builder |
setTo(Collection<? extends Address> to)
Sets To header field of this message to the specified
addresses.
|
Message.Builder |
setTo(String... to)
Sets To header field of this message to the specified
addresses.
|
Message.Builder |
setTo(String to)
Sets To header field of this message to the specified
address.
|
Message.Builder |
use(BodyDescriptorBuilder bodyDescBuilder)
Sets
BodyDescriptorBuilder that will be
used to generate body descriptors when executing parse(java.io.InputStream) . |
Message.Builder |
use(BodyFactory bodyFactory)
Sets
BodyFactory that will be
used to generate message body. |
Message.Builder |
use(DecodeMonitor monitor)
Sets
DecodeMonitor that will be
used to handle malformed data when executing parse(java.io.InputStream) . |
Message.Builder |
use(FieldParser<?> fieldParser)
Sets
FieldParser that will be
used to generate parse message fields when executing parse(java.io.InputStream) . |
Message.Builder |
use(MimeConfig config)
Sets MIME configuration.
|
containsField, getBody, getCharset, getContentTransferEncoding, getCreationDate, getDispositionType, getField, getField, getFields, getFields, getFields, getFilename, getMimeType, getModificationDate, getReadDate, getSize, obtainField, setBody, setBody, setBody
public static Message.Builder of()
public static Message.Builder of(Message other)
public static Message.Builder of(InputStream is) throws IOException
IOException
public Message.Builder use(MimeConfig config)
config
- the configuration.public Message.Builder use(DecodeMonitor monitor)
DecodeMonitor
that will be
used to handle malformed data when executing parse(java.io.InputStream)
.monitor
- the decoder monitor.public Message.Builder use(BodyDescriptorBuilder bodyDescBuilder)
BodyDescriptorBuilder
that will be
used to generate body descriptors when executing parse(java.io.InputStream)
.bodyDescBuilder
- the body descriptor builder.public Message.Builder use(FieldParser<?> fieldParser)
FieldParser
that will be
used to generate parse message fields when executing parse(java.io.InputStream)
.fieldParser
- the field parser.public Message.Builder use(BodyFactory bodyFactory)
BodyFactory
that will be
used to generate message body.bodyFactory
- the body factory.public Message.Builder enableFlatMode()
parse(java.io.InputStream)
operation.public Message.Builder disableFlatMode()
parse(java.io.InputStream)
operation.public Message.Builder enableContentDecoding()
parse(java.io.InputStream)
operation.public Message.Builder disableContentDecoding()
parse(java.io.InputStream)
operation.public Message.Builder copy(Message other)
public Message.Builder setField(Field field)
AbstractEntityBuilder
AbstractEntityBuilder.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.setField
in class AbstractEntityBuilder
field
- the field to set.public Message.Builder addField(Field field)
AbstractEntityBuilder
addField
in class AbstractEntityBuilder
field
- the field to add.public Message.Builder removeFields(String name)
AbstractEntityBuilder
Field
s having the specified field name.removeFields
in class AbstractEntityBuilder
name
- the field name (e.g. From, Subject).public Message.Builder clearFields()
AbstractEntityBuilder
clearFields
in class AbstractEntityBuilder
public Message.Builder setContentTransferEncoding(String contentTransferEncoding)
AbstractEntityBuilder
setContentTransferEncoding
in class AbstractEntityBuilder
contentTransferEncoding
- transfer encoding to use.public Message.Builder setContentType(String mimeType, NameValuePair... parameters)
AbstractEntityBuilder
setContentType
in class AbstractEntityBuilder
mimeType
- MIME type of this message
the MIME type to use.parameters
- content type parameters to use.public Message.Builder setContentDisposition(String dispositionType)
AbstractEntityBuilder
setContentDisposition
in class AbstractEntityBuilder
dispositionType
- disposition type value (usually inline
or
attachment
).public Message.Builder setContentDisposition(String dispositionType, String filename)
AbstractEntityBuilder
setContentDisposition
in class AbstractEntityBuilder
dispositionType
- disposition type value (usually inline
or
attachment
).filename
- filename parameter value or null
if the
parameter should not be included.public Message.Builder setContentDisposition(String dispositionType, String filename, long size)
AbstractEntityBuilder
setContentDisposition
in class AbstractEntityBuilder
dispositionType
- disposition type value (usually inline
or
attachment
).filename
- filename parameter value or null
if the
parameter should not be included.size
- size parameter value or -1
if the parameter
should not be included.public Message.Builder setContentDisposition(String dispositionType, String filename, long size, Date creationDate, Date modificationDate, Date readDate)
AbstractEntityBuilder
setContentDisposition
in class AbstractEntityBuilder
dispositionType
- disposition type value (usually inline
or
attachment
).filename
- filename parameter value or null
if the
parameter should not be included.size
- size parameter value or -1
if the parameter
should not be included.creationDate
- creation-date parameter value or null
if the
parameter should not be included.modificationDate
- modification-date parameter value or null
if
the parameter should not be included.readDate
- read-date parameter value or null
if the
parameter should not be included.public Message.Builder setBody(Body body)
AbstractEntityBuilder
Body
.setBody
in class AbstractEntityBuilder
body
- the body.public Message.Builder setBody(TextBody textBody)
AbstractEntityBuilder
Body
.setBody
in class AbstractEntityBuilder
textBody
- the body.public Message.Builder setBody(BinaryBody binaryBody)
AbstractEntityBuilder
Body
.setBody
in class AbstractEntityBuilder
binaryBody
- the binaryBody.public Message.Builder setBody(Multipart multipart)
AbstractEntityBuilder
Multipart
.setBody
in class AbstractEntityBuilder
multipart
- the body.public Message.Builder setBody(Message message)
AbstractEntityBuilder
Message
.setBody
in class AbstractEntityBuilder
message
- the body.public Message.Builder setBody(String text, Charset charset) throws IOException
text
- the text.charset
- the charset of the text.IOException
public Message.Builder setBody(String text, String subtype, Charset charset) throws IOException
text
- the text.charset
- the charset of the text.subtype
- the text subtype (e.g. "plain", "html" or
"xml").IOException
public Message.Builder setBody(byte[] bin, String mimeType) throws IOException
bin
- the body.mimeType
- the MIME media type of the specified body
("type/subtype").IOException
public String getMessageId()
null
if it is not present.public Message.Builder generateMessageId(String hostname)
hostname
- host name to be included in the identifier or
null
if no host name should be included.public Message.Builder setMessageId(String messageId)
messageId
- the message ID.public String getSubject()
null
if it is not present.public Message.Builder setSubject(String subject)
subject
- subject to set or null
to remove the subject
header field.public Date getDate()
Date
object or null
if it is not present.public Message.Builder setDate(Date date)
TimeZone
of this host to encode the specified
Date
object into a string.date
- date to set or null
to remove the date header
field.public Message.Builder setDate(Date date, TimeZone zone)
TimeZone
is used to encode the specified Date
object into a string.date
- date to set or null
to remove the date header
field.zone
- a time zone.public Mailbox getSender()
Mailbox
object or null
if it is not
present.public Message.Builder setSender(Mailbox sender)
sender
- address to set or null
to remove the header
field.public Message.Builder setSender(String sender) throws ParseException
sender
- address to set or null
to remove the header
field.ParseException
public MailboxList getFrom()
MailboxList
object or null
if it is not
present.public Message.Builder setFrom(Mailbox from)
from
- address to set or null
to remove the header
field.public Message.Builder setFrom(String from) throws ParseException
from
- address to set or null
to remove the header
field.ParseException
public Message.Builder setFrom(Mailbox... from)
from
- addresses to set or null
or no arguments to
remove the header field.public Message.Builder setFrom(String... from) throws ParseException
from
- addresses to set or null
or no arguments to
remove the header field.ParseException
public Message.Builder setFrom(Collection<Mailbox> from)
from
- addresses to set or null
or an empty collection
to remove the header field.public AddressList getTo()
AddressList
object or null
if it is not
present.public Message.Builder setTo(Address to)
to
- address to set or null
to remove the header
field.public Message.Builder setTo(String to) throws ParseException
to
- address to set or null
to remove the header
field.ParseException
public Message.Builder setTo(Address... to)
to
- addresses to set or null
or no arguments to
remove the header field.public Message.Builder setTo(String... to) throws ParseException
to
- addresses to set or null
or no arguments to
remove the header field.ParseException
public Message.Builder setTo(Collection<? extends Address> to)
to
- addresses to set or null
or an empty collection
to remove the header field.public AddressList getCc()
AddressList
object or null
if it is not
present.public Message.Builder setCc(Address cc)
cc
- address to set or null
to remove the header
field.public Message.Builder setCc(Address... cc)
cc
- addresses to set or null
or no arguments to
remove the header field.public Message.Builder setCc(Collection<? extends Address> cc)
cc
- addresses to set or null
or an empty collection
to remove the header field.public AddressList getBcc()
AddressList
object or null
if it is not
present.public Message.Builder setBcc(Address bcc)
bcc
- address to set or null
to remove the header
field.public Message.Builder setBcc(Address... bcc)
bcc
- addresses to set or null
or no arguments to
remove the header field.public Message.Builder setBcc(Collection<? extends Address> bcc)
bcc
- addresses to set or null
or an empty collection
to remove the header field.public AddressList getReplyTo()
AddressList
object or null
if it is not
present.public Message.Builder setReplyTo(Address replyTo)
replyTo
- address to set or null
to remove the header
field.public Message.Builder setReplyTo(Address... replyTo)
replyTo
- addresses to set or null
or no arguments to
remove the header field.public Message.Builder setReplyTo(Collection<? extends Address> replyTo)
replyTo
- addresses to set or null
or an empty collection
to remove the header field.public Message.Builder parse(InputStream is) throws IOException
IOException
public Message build()
Copyright © 2004–2023 The Apache Software Foundation. All rights reserved.