Package org.apache.james.mime4j.util
Class MimeUtil
java.lang.Object
org.apache.james.mime4j.util.MimeUtil
A utility class, which provides some MIME related application logic.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static int
static final String
The7bit
encoding.static final String
The8bit
encoding.static final String
Thebase64
encoding.static final String
Thebinary
encoding.static final String
Thequoted-printable
encoding.private static final int
private static final Random
static final DateTimeFormatter
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
Creates a new unique message boundary string that can be used as boundary parameter for the Content-Type header field of a message.static String
createUniqueMessageId
(String hostName) Creates a new unique message identifier that can be used in message header field such as Message-ID or In-Reply-To.static String
Splits the specified string into a multiple-line representation with lines no longer than 76 characters (because the line might contain encoded words; see RFC 2047 section 2).static String
formatDate
(Date date, TimeZone zone) Formats the specified date into a RFC 822 date-time string.private static int
indexOfWsp
(String s, int fromIndex) static boolean
isBase64Encoding
(String pTransferEncoding) Returns, whether the given transfer-encoding is "base64".static boolean
Returns true, if the given MIME type is that of a message.static boolean
isMultipart
(String pMimeType) Return true, if the given MIME type indicates a multipart entity.static boolean
isQuotedPrintableEncoded
(String pTransferEncoding) Returns, whether the given transfer-encoding is "quoted-printable".static boolean
isSameMimeType
(String pType1, String pType2) Returns, whether the given two MIME types are identical.private static int
static String
Unfold a multiple-line representation into a single line.private static String
static String
unscrambleHeaderValue
(String headerValue) Unfold and decode header valueprivate static ZoneId
-
Field Details
-
ENC_QUOTED_PRINTABLE
Thequoted-printable
encoding.- See Also:
-
ENC_BINARY
Thebinary
encoding.- See Also:
-
ENC_BASE64
Thebase64
encoding.- See Also:
-
ENC_8BIT
The8bit
encoding.- See Also:
-
ENC_7BIT
The7bit
encoding.- See Also:
-
random
-
counter
private static int counter -
INITIAL_YEAR
private static final int INITIAL_YEAR- See Also:
-
RFC822_DATE_FORMAT
-
-
Constructor Details
-
MimeUtil
private MimeUtil()
-
-
Method Details
-
isSameMimeType
Returns, whether the given two MIME types are identical. -
isMessage
Returns true, if the given MIME type is that of a message. -
isMultipart
Return true, if the given MIME type indicates a multipart entity. -
isBase64Encoding
Returns, whether the given transfer-encoding is "base64". -
isQuotedPrintableEncoded
Returns, whether the given transfer-encoding is "quoted-printable". -
createUniqueBoundary
Creates a new unique message boundary string that can be used as boundary parameter for the Content-Type header field of a message.- Returns:
- a new unique message boundary string.
-
createUniqueMessageId
Creates a new unique message identifier that can be used in message header field such as Message-ID or In-Reply-To. If the given host name is notnull
it will be used as suffix for the message ID (following an at sign). The resulting string is enclosed in angle brackets (< and >);- Parameters:
hostName
- host name to be included in the message ID ornull
if no host name should be included.- Returns:
- a new unique message identifier.
-
formatDate
Formats the specified date into a RFC 822 date-time string.- Parameters:
date
- date to be formatted into a string.zone
- the time zone to use ornull
to use the default time zone.- Returns:
- the formatted time string.
-
zone
-
fold
Splits the specified string into a multiple-line representation with lines no longer than 76 characters (because the line might contain encoded words; see RFC 2047 section 2). If the string contains non-whitespace sequences longer than 76 characters a line break is inserted at the whitespace character following the sequence resulting in a line longer than 76 characters.- Parameters:
s
- string to split.usedCharacters
- number of characters already used up. Usually the number of characters for header field name plus colon and one space.- Returns:
- a multiple-line representation of the given string.
-
unfold
Unfold a multiple-line representation into a single line.- Parameters:
s
- string to unfold.- Returns:
- unfolded string.
-
unscrambleHeaderValue
Unfold and decode header value -
unfold0
-
indexOfWsp
-
nextCounterValue
private static int nextCounterValue() -
monthOfYear
-
dayOfWeek
-