Package org.apache.james.mime4j.field
Class Fields
- java.lang.Object
-
- org.apache.james.mime4j.field.Fields
-
public class Fields extends java.lang.ObjectFactory for concreteFieldinstances.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.PatternFIELD_NAME_PATTERN
-
Constructor Summary
Constructors Modifier Constructor Description privateFields()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AddressListFieldaddressList(java.lang.String fieldName, java.lang.Iterable<? extends Address> addresses)Creates an address-list field from the specified field name and mailbox or group addresses.private static AddressListFieldaddressList0(java.lang.String fieldName, java.lang.Iterable<? extends Address> addresses)static AddressListFieldbcc(java.lang.Iterable<Address> addresses)Creates a Bcc field for the specified mailbox or group addresses.static AddressListFieldbcc(Address address)Creates a Bcc field for the specified mailbox or group address.static AddressListFieldbcc(Address... addresses)Creates a Bcc field for the specified mailbox or group addresses.static AddressListFieldcc(java.lang.Iterable<Address> addresses)Creates a Cc field for the specified mailbox or group addresses.static AddressListFieldcc(Address address)Creates a Cc field for the specified mailbox or group address.static AddressListFieldcc(Address... addresses)Creates a Cc field for the specified mailbox or group addresses.private static voidcheckValidFieldName(java.lang.String fieldName)static ContentDispositionFieldcontentDisposition(java.lang.String contentDisposition)Creates a Content-Disposition field from the specified raw field value.static ContentDispositionFieldcontentDisposition(java.lang.String dispositionType, java.lang.Iterable<NameValuePair> parameters)Creates a Content-Disposition field from the specified disposition type and parameters.static ContentDispositionFieldcontentDisposition(java.lang.String dispositionType, java.lang.String filename)Creates a Content-Disposition field from the specified disposition type and filename.static ContentDispositionFieldcontentDisposition(java.lang.String dispositionType, java.lang.String filename, long size)Creates a Content-Disposition field from the specified values.static ContentDispositionFieldcontentDisposition(java.lang.String dispositionType, java.lang.String filename, long size, java.util.Date creationDate, java.util.Date modificationDate, java.util.Date readDate)Creates a Content-Disposition field from the specified values.static ContentDispositionFieldcontentDisposition(java.lang.String dispositionType, java.util.Map<java.lang.String,java.lang.String> parameters)Creates a Content-Disposition field from the specified disposition type and parameters.static ContentTransferEncodingFieldcontentTransferEncoding(java.lang.String contentTransferEncoding)Creates a Content-Transfer-Encoding field from the specified raw field value.static ContentTypeFieldcontentType(java.lang.String contentType)Creates a Content-Type field from the specified raw field value.static ContentTypeFieldcontentType(java.lang.String mimeType, java.lang.Iterable<NameValuePair> parameters)Creates a Content-Type field from the specified MIME type and parameters.static ContentTypeFieldcontentType(java.lang.String mimeType, java.util.Map<java.lang.String,java.lang.String> parameters)Creates a Content-Type field from the specified MIME type and parameters.static ContentTypeFieldcontentType(java.lang.String mimeType, NameValuePair... parameters)Creates a Content-Type field from the specified MIME type and parameters.static DateTimeFielddate(java.lang.String fieldName, java.util.Date date)Creates a date field from the specified field name andDatevalue.static DateTimeFielddate(java.lang.String fieldName, java.util.Date date, java.util.TimeZone zone)Creates a date field from the specified field name,DateandTimeZonevalues.static DateTimeFielddate(java.util.Date date)Creates a Date field from the specifiedDatevalue.private static DateTimeFielddate0(java.lang.String fieldName, java.util.Date date, java.util.TimeZone zone)private static java.lang.StringencodeAddresses(java.lang.Iterable<? extends Address> addresses)static MailboxListFieldfrom(java.lang.Iterable<Mailbox> mailboxes)Creates a From field for the specified mailbox addresses.static MailboxListFieldfrom(Mailbox mailbox)Creates a From field for the specified mailbox address.static MailboxListFieldfrom(Mailbox... mailboxes)Creates a From field for the specified mailbox addresses.static UnstructuredFieldgenerateMessageId(java.lang.String hostname)Creates a Message-ID field for the specified host name.private static booleanisValidDispositionType(java.lang.String dispositionType)private static booleanisValidMimeType(java.lang.String mimeType)static MailboxFieldmailbox(java.lang.String fieldName, Mailbox mailbox)Creates a mailbox field from the specified field name and mailbox address.private static MailboxFieldmailbox0(java.lang.String fieldName, Mailbox mailbox)static MailboxListFieldmailboxList(java.lang.String fieldName, java.lang.Iterable<Mailbox> mailboxes)Creates a mailbox-list field from the specified field name and mailbox addresses.private static MailboxListFieldmailboxList0(java.lang.String fieldName, java.lang.Iterable<Mailbox> mailboxes)static UnstructuredFieldmessageId(java.lang.String messageId)Creates a Message-ID field with the given message ID.private static <F extends ParsedField>
Fparse(FieldParser<F> parser, java.lang.String fieldName, java.lang.String fieldBody)static AddressListFieldreplyTo(java.lang.Iterable<Address> addresses)Creates a Reply-To field for the specified mailbox or group addresses.static AddressListFieldreplyTo(Address address)Creates a Reply-To field for the specified mailbox or group address.static AddressListFieldreplyTo(Address... addresses)Creates a Reply-To field for the specified mailbox or group addresses.static MailboxFieldsender(Mailbox mailbox)Creates a Sender field for the specified mailbox address.static UnstructuredFieldsubject(java.lang.String subject)Creates a Subject field from the specified string value.static AddressListFieldto(java.lang.Iterable<Address> addresses)Creates a To field for the specified mailbox or group addresses.static AddressListFieldto(Address address)Creates a To field for the specified mailbox or group address.static AddressListFieldto(Address... addresses)Creates a To field for the specified mailbox or group addresses.static MimeVersionFieldversion(java.lang.String ver)
-
-
-
Method Detail
-
version
public static MimeVersionField version(java.lang.String ver)
-
contentType
public static ContentTypeField contentType(java.lang.String contentType)
Creates a Content-Type field from the specified raw field value. The specified string gets folded into a multiple-line representation if necessary but is otherwise taken as is.- Parameters:
contentType- raw content type containing a MIME type and optional parameters.- Returns:
- the newly created Content-Type field.
-
contentType
public static ContentTypeField contentType(java.lang.String mimeType, java.util.Map<java.lang.String,java.lang.String> parameters)
Creates a Content-Type field from the specified MIME type and parameters.- Parameters:
mimeType- a MIME type (such as"text/plain"or"application/octet-stream").parameters- map containing content-type parameters such as"boundary".- Returns:
- the newly created Content-Type field.
-
contentType
public static ContentTypeField contentType(java.lang.String mimeType, java.lang.Iterable<NameValuePair> parameters)
Creates a Content-Type field from the specified MIME type and parameters.- Parameters:
mimeType- a MIME type (such as"text/plain"or"application/octet-stream").parameters- list of content-type parameter name/value pairs.- Returns:
- the newly created Content-Type field.
-
contentType
public static ContentTypeField contentType(java.lang.String mimeType, NameValuePair... parameters)
Creates a Content-Type field from the specified MIME type and parameters.- Parameters:
mimeType- a MIME type (such as"text/plain"or"application/octet-stream").parameters- array of content-type parameter name/value pairs.- Returns:
- the newly created Content-Type field.
-
contentTransferEncoding
public static ContentTransferEncodingField contentTransferEncoding(java.lang.String contentTransferEncoding)
Creates a Content-Transfer-Encoding field from the specified raw field value.- Parameters:
contentTransferEncoding- an encoding mechanism such as"7-bit"or"quoted-printable".- Returns:
- the newly created Content-Transfer-Encoding field.
-
contentDisposition
public static ContentDispositionField contentDisposition(java.lang.String contentDisposition)
Creates a Content-Disposition field from the specified raw field value. The specified string gets folded into a multiple-line representation if necessary but is otherwise taken as is.- Parameters:
contentDisposition- raw content disposition containing a disposition type and optional parameters.- Returns:
- the newly created Content-Disposition field.
-
contentDisposition
public static ContentDispositionField contentDisposition(java.lang.String dispositionType, java.util.Map<java.lang.String,java.lang.String> parameters)
Creates a Content-Disposition field from the specified disposition type and parameters.- Parameters:
dispositionType- a disposition type (usually"inline"or"attachment").parameters- map containing disposition parameters such as"filename".- Returns:
- the newly created Content-Disposition field.
-
contentDisposition
public static ContentDispositionField contentDisposition(java.lang.String dispositionType, java.lang.Iterable<NameValuePair> parameters)
Creates a Content-Disposition field from the specified disposition type and parameters.- Parameters:
dispositionType- a disposition type (usually"inline"or"attachment").parameters- list of disposition parameter name/value pairs.- Returns:
- the newly created Content-Disposition field.
-
contentDisposition
public static ContentDispositionField contentDisposition(java.lang.String dispositionType, java.lang.String filename)
Creates a Content-Disposition field from the specified disposition type and filename.- Parameters:
dispositionType- a disposition type (usually"inline"or"attachment").filename- filename parameter value ornullif the parameter should not be included.- Returns:
- the newly created Content-Disposition field.
-
contentDisposition
public static ContentDispositionField contentDisposition(java.lang.String dispositionType, java.lang.String filename, long size)
Creates a Content-Disposition field from the specified values.- Parameters:
dispositionType- a disposition type (usually"inline"or"attachment").filename- filename parameter value ornullif the parameter should not be included.size- size parameter value or-1if the parameter should not be included.- Returns:
- the newly created Content-Disposition field.
-
contentDisposition
public static ContentDispositionField contentDisposition(java.lang.String dispositionType, java.lang.String filename, long size, java.util.Date creationDate, java.util.Date modificationDate, java.util.Date readDate)
Creates a Content-Disposition field from the specified values.- Parameters:
dispositionType- a disposition type (usually"inline"or"attachment").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.- Returns:
- the newly created Content-Disposition field.
-
date
public static DateTimeField date(java.util.Date date)
Creates a Date field from the specifiedDatevalue. The default time zone of the host is used to format the date.- Parameters:
date- date value for the header field.- Returns:
- the newly created Date field.
-
date
public static DateTimeField date(java.lang.String fieldName, java.util.Date date)
Creates a date field from the specified field name andDatevalue. The default time zone of the host is used to format the date.- Parameters:
fieldName- a field name such asDateorResent-Date.date- date value for the header field.- Returns:
- the newly created date field.
-
date
public static DateTimeField date(java.lang.String fieldName, java.util.Date date, java.util.TimeZone zone)
Creates a date field from the specified field name,DateandTimeZonevalues.- Parameters:
fieldName- a field name such asDateorResent-Date.date- date value for the header field.zone- the time zone to be used for formatting the date.- Returns:
- the newly created date field.
-
generateMessageId
public static UnstructuredField generateMessageId(java.lang.String hostname)
Creates a Message-ID field for the specified host name.- Parameters:
hostname- host name to be included in the message ID ornullif no host name should be included.- Returns:
- the newly created Message-ID field.
-
messageId
public static UnstructuredField messageId(java.lang.String messageId)
Creates a Message-ID field with the given message ID.- Parameters:
messageId- message ID value.
-
subject
public static UnstructuredField subject(java.lang.String subject)
Creates a Subject field from the specified string value. The specified string may contain non-ASCII characters.- Parameters:
subject- the subject string.- Returns:
- the newly created Subject field.
-
sender
public static MailboxField sender(Mailbox mailbox)
Creates a Sender field for the specified mailbox address.- Parameters:
mailbox- address to be included in the field.- Returns:
- the newly created Sender field.
-
from
public static MailboxListField from(Mailbox mailbox)
Creates a From field for the specified mailbox address.- Parameters:
mailbox- address to be included in the field.- Returns:
- the newly created From field.
-
from
public static MailboxListField from(Mailbox... mailboxes)
Creates a From field for the specified mailbox addresses.- Parameters:
mailboxes- addresses to be included in the field.- Returns:
- the newly created From field.
-
from
public static MailboxListField from(java.lang.Iterable<Mailbox> mailboxes)
Creates a From field for the specified mailbox addresses.- Parameters:
mailboxes- addresses to be included in the field.- Returns:
- the newly created From field.
-
to
public static AddressListField to(Address address)
Creates a To field for the specified mailbox or group address.- Parameters:
address- mailbox or group address to be included in the field.- Returns:
- the newly created To field.
-
to
public static AddressListField to(Address... addresses)
Creates a To field for the specified mailbox or group addresses.- Parameters:
addresses- mailbox or group addresses to be included in the field.- Returns:
- the newly created To field.
-
to
public static AddressListField to(java.lang.Iterable<Address> addresses)
Creates a To field for the specified mailbox or group addresses.- Parameters:
addresses- mailbox or group addresses to be included in the field.- Returns:
- the newly created To field.
-
cc
public static AddressListField cc(Address address)
Creates a Cc field for the specified mailbox or group address.- Parameters:
address- mailbox or group address to be included in the field.- Returns:
- the newly created Cc field.
-
cc
public static AddressListField cc(Address... addresses)
Creates a Cc field for the specified mailbox or group addresses.- Parameters:
addresses- mailbox or group addresses to be included in the field.- Returns:
- the newly created Cc field.
-
cc
public static AddressListField cc(java.lang.Iterable<Address> addresses)
Creates a Cc field for the specified mailbox or group addresses.- Parameters:
addresses- mailbox or group addresses to be included in the field.- Returns:
- the newly created Cc field.
-
bcc
public static AddressListField bcc(Address address)
Creates a Bcc field for the specified mailbox or group address.- Parameters:
address- mailbox or group address to be included in the field.- Returns:
- the newly created Bcc field.
-
bcc
public static AddressListField bcc(Address... addresses)
Creates a Bcc field for the specified mailbox or group addresses.- Parameters:
addresses- mailbox or group addresses to be included in the field.- Returns:
- the newly created Bcc field.
-
bcc
public static AddressListField bcc(java.lang.Iterable<Address> addresses)
Creates a Bcc field for the specified mailbox or group addresses.- Parameters:
addresses- mailbox or group addresses to be included in the field.- Returns:
- the newly created Bcc field.
-
replyTo
public static AddressListField replyTo(Address address)
Creates a Reply-To field for the specified mailbox or group address.- Parameters:
address- mailbox or group address to be included in the field.- Returns:
- the newly created Reply-To field.
-
replyTo
public static AddressListField replyTo(Address... addresses)
Creates a Reply-To field for the specified mailbox or group addresses.- Parameters:
addresses- mailbox or group addresses to be included in the field.- Returns:
- the newly created Reply-To field.
-
replyTo
public static AddressListField replyTo(java.lang.Iterable<Address> addresses)
Creates a Reply-To field for the specified mailbox or group addresses.- Parameters:
addresses- mailbox or group addresses to be included in the field.- Returns:
- the newly created Reply-To field.
-
mailbox
public static MailboxField mailbox(java.lang.String fieldName, Mailbox mailbox)
Creates a mailbox field from the specified field name and mailbox address. Valid field names areSenderandResent-Sender.- Parameters:
fieldName- the name of the mailbox field (SenderorResent-Sender).mailbox- mailbox address for the field value.- Returns:
- the newly created mailbox field.
-
mailboxList
public static MailboxListField mailboxList(java.lang.String fieldName, java.lang.Iterable<Mailbox> mailboxes)
Creates a mailbox-list field from the specified field name and mailbox addresses. Valid field names areFromandResent-From.- Parameters:
fieldName- the name of the mailbox field (FromorResent-From).mailboxes- mailbox addresses for the field value.- Returns:
- the newly created mailbox-list field.
-
addressList
public static AddressListField addressList(java.lang.String fieldName, java.lang.Iterable<? extends Address> addresses)
Creates an address-list field from the specified field name and mailbox or group addresses. Valid field names areTo,Cc,Bcc,Reply-To,Resent-To,Resent-CcandResent-Bcc.- Parameters:
fieldName- the name of the mailbox field (To,Cc,Bcc,Reply-To,Resent-To,Resent-CcorResent-Bcc).addresses- mailbox or group addresses for the field value.- Returns:
- the newly created address-list field.
-
date0
private static DateTimeField date0(java.lang.String fieldName, java.util.Date date, java.util.TimeZone zone)
-
mailbox0
private static MailboxField mailbox0(java.lang.String fieldName, Mailbox mailbox)
-
mailboxList0
private static MailboxListField mailboxList0(java.lang.String fieldName, java.lang.Iterable<Mailbox> mailboxes)
-
addressList0
private static AddressListField addressList0(java.lang.String fieldName, java.lang.Iterable<? extends Address> addresses)
-
checkValidFieldName
private static void checkValidFieldName(java.lang.String fieldName)
-
isValidMimeType
private static boolean isValidMimeType(java.lang.String mimeType)
-
isValidDispositionType
private static boolean isValidDispositionType(java.lang.String dispositionType)
-
parse
private static <F extends ParsedField> F parse(FieldParser<F> parser, java.lang.String fieldName, java.lang.String fieldBody)
-
encodeAddresses
private static java.lang.String encodeAddresses(java.lang.Iterable<? extends Address> addresses)
-
-