Top Description Fields Constructors Methods
org.apache.tomcat.util.http.fileupload.util.mime

public final Class MimeUtility

extends Object
Class Inheritance
Imports
java.io.ByteArrayOutputStream, .IOException, .UnsupportedEncodingException, java.nio.charset.StandardCharsets, java.util.HashMap, .Locale, .Map, org.apache.tomcat.util.codec.binary.Base64

Utility class to decode MIME texts.
Since
1.3

Field Summary

Modifier and TypeField and Description
private static final String
BASE64_ENCODING_MARKER

The marker to indicate text is encoded with BASE64 algorithm.

private static final String
ENCODED_TOKEN_FINISHER

If the text contains any encoded tokens, those tokens will terminate with "=?".

private static final String
ENCODED_TOKEN_MARKER

If the text contains any encoded tokens, those tokens will be marked with "=?".

private static final String
LINEAR_WHITESPACE

The linear whitespace chars sequence.

private static final Map<String, String>
MIME2JAVA

Mappings between MIME and Java charset.

private static final String
QUOTEDPRINTABLE_ENCODING_MARKER

The marker to indicate text is encoded with QuotedPrintable algorithm.

Constructor Summary

AccessConstructor and Description
private
MimeUtility()

Hidden constructor, this class must not be instantiated.

Method Summary

Modifier and TypeMethod and Description
public static String

Returns:

The decoded text string.
decodeText
(final String
The text to decode.
text
)

Decode a string of text obtained from a mail header into its proper form.

private static String

Returns:

The decoded word.
decodeWord
(final String
The possibly encoded word value.
word
)

Parse a string using the RFC 2047 rules for an "encoded-word" type.

private static String

Returns:

The Java equivalent for this name.
javaCharset
(final String
The MIME standard name.
charset
)

Translate a MIME standard character set name into the Java equivalent.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BASE64_ENCODING_MARKERback to summary
private static final String BASE64_ENCODING_MARKER

The marker to indicate text is encoded with BASE64 algorithm.

ENCODED_TOKEN_FINISHERback to summary
private static final String ENCODED_TOKEN_FINISHER

If the text contains any encoded tokens, those tokens will terminate with "=?".

ENCODED_TOKEN_MARKERback to summary
private static final String ENCODED_TOKEN_MARKER

If the text contains any encoded tokens, those tokens will be marked with "=?".

LINEAR_WHITESPACEback to summary
private static final String LINEAR_WHITESPACE

The linear whitespace chars sequence.

MIME2JAVAback to summary
private static final Map<String, String> MIME2JAVA

Mappings between MIME and Java charset.

QUOTEDPRINTABLE_ENCODING_MARKERback to summary
private static final String QUOTEDPRINTABLE_ENCODING_MARKER

The marker to indicate text is encoded with QuotedPrintable algorithm.

Constructor Detail

MimeUtilityback to summary
private MimeUtility()

Hidden constructor, this class must not be instantiated.

Method Detail

decodeTextback to summary
public static String decodeText(final String text) throws UnsupportedEncodingException

Decode a string of text obtained from a mail header into its proper form. The text generally will consist of a string of tokens, some of which may be encoded using base64 encoding.

Parameters
text:String

The text to decode.

Returns:String

The decoded text string.

Exceptions
UnsupportedEncodingException:
if the detected encoding in the input text is not supported.
decodeWordback to summary
private static String decodeWord(final String word) throws ParseException, UnsupportedEncodingException

Parse a string using the RFC 2047 rules for an "encoded-word" type. This encoding has the syntax: encoded-word = "=?" charset "?" encoding "?" encoded-text "?="

Parameters
word:String

The possibly encoded word value.

Returns:String

The decoded word.

Exceptions
ParseException:
in case of a parse error of the RFC 2047
UnsupportedEncodingException:
Thrown when Invalid RFC 2047 encoding was found
javaCharsetback to summary
private static String javaCharset(final String charset)

Translate a MIME standard character set name into the Java equivalent.

Parameters
charset:String

The MIME standard name.

Returns:String

The Java equivalent for this name.