Class MimeUtility


  • public final class MimeUtility
    extends java.lang.Object
    Utility class to decode MIME texts.
    Since:
    1.3
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String BASE64_ENCODING_MARKER
      The marker to indicate text is encoded with BASE64 algorithm.
      private static java.lang.String ENCODED_TOKEN_FINISHER
      If the text contains any encoded tokens, those tokens will terminate with "=?".
      private static java.lang.String ENCODED_TOKEN_MARKER
      If the text contains any encoded tokens, those tokens will be marked with "=?".
      private static java.lang.String LINEAR_WHITESPACE
      The linear whitespace chars sequence.
      private static java.util.Map<java.lang.String,​java.lang.String> MIME2JAVA
      Mappings between MIME and Java charset.
      private static java.lang.String QUOTEDPRINTABLE_ENCODING_MARKER
      The marker to indicate text is encoded with QuotedPrintable algorithm.
      private static java.lang.String US_ASCII_CHARSET
      The US-ASCII charset identifier constant.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private MimeUtility()
      Hidden constructor, this class must not be instantiated.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String decodeText​(java.lang.String text)
      Decode a string of text obtained from a mail header into its proper form.
      private static java.lang.String decodeWord​(java.lang.String word)
      Parse a string using the RFC 2047 rules for an "encoded-word" type.
      private static java.lang.String javaCharset​(java.lang.String charset)
      Translate a MIME standard character set name into the Java equivalent.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • US_ASCII_CHARSET

        private static final java.lang.String US_ASCII_CHARSET
        The US-ASCII charset identifier constant.
        See Also:
        Constant Field Values
      • BASE64_ENCODING_MARKER

        private static final java.lang.String BASE64_ENCODING_MARKER
        The marker to indicate text is encoded with BASE64 algorithm.
        See Also:
        Constant Field Values
      • QUOTEDPRINTABLE_ENCODING_MARKER

        private static final java.lang.String QUOTEDPRINTABLE_ENCODING_MARKER
        The marker to indicate text is encoded with QuotedPrintable algorithm.
        See Also:
        Constant Field Values
      • ENCODED_TOKEN_MARKER

        private static final java.lang.String ENCODED_TOKEN_MARKER
        If the text contains any encoded tokens, those tokens will be marked with "=?".
        See Also:
        Constant Field Values
      • ENCODED_TOKEN_FINISHER

        private static final java.lang.String ENCODED_TOKEN_FINISHER
        If the text contains any encoded tokens, those tokens will terminate with "=?".
        See Also:
        Constant Field Values
      • LINEAR_WHITESPACE

        private static final java.lang.String LINEAR_WHITESPACE
        The linear whitespace chars sequence.
        See Also:
        Constant Field Values
      • MIME2JAVA

        private static final java.util.Map<java.lang.String,​java.lang.String> MIME2JAVA
        Mappings between MIME and Java charset.
    • Constructor Detail

      • MimeUtility

        private MimeUtility()
        Hidden constructor, this class must not be instantiated.
    • Method Detail

      • decodeText

        public static java.lang.String decodeText​(java.lang.String text)
                                           throws java.io.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 - The text to decode.
        Returns:
        The decoded text string.
        Throws:
        java.io.UnsupportedEncodingException - if the detected encoding in the input text is not supported.
      • decodeWord

        private static java.lang.String decodeWord​(java.lang.String word)
                                            throws ParseException,
                                                   java.io.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 - The possibly encoded word value.
        Returns:
        The decoded word.
        Throws:
        ParseException
        java.io.UnsupportedEncodingException
      • javaCharset

        private static java.lang.String javaCharset​(java.lang.String charset)
        Translate a MIME standard character set name into the Java equivalent.
        Parameters:
        charset - The MIME standard name.
        Returns:
        The Java equivalent for this name.