Class MimeUtils

java.lang.Object
org.apache.commons.fileupload2.core.MimeUtils

final class MimeUtils extends Object
Utility class to decode MIME texts.
  • Field Details

    • BASE64_ENCODING_MARKER

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

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

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

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

      private static final String LINEAR_WHITESPACE
      The linear whitespace chars sequence.
      See Also:
    • MIME2JAVA

      private static final Map<String,String> MIME2JAVA
      Mappings between MIME and Java charset.
  • Constructor Details

    • MimeUtils

      private MimeUtils()
      Hidden constructor, this class must not be instantiated.
  • Method Details

    • decodeText

      static String decodeText(String text) throws UnsupportedEncodingException
      Decodes 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:
      UnsupportedEncodingException - if the detected encoding in the input text is not supported.
    • decodeWord

      private static String decodeWord(String word) throws ParseException, UnsupportedEncodingException
      Decodes 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 - in case of a parse error of the RFC 2047.
      UnsupportedEncodingException - Thrown when Invalid RFC 2047 encoding was found.
    • javaCharset

      private static String javaCharset(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.