org.springframework.util

## 类 MimeTypeUtils

- java.lang.Object
- - org.springframework.util.MimeTypeUtils

-     public abstract class MimeTypeUtils
      extends Object

  Miscellaneous `MimeType` utility methods.
  从以下版本开始:
    4.0
  作者:
    Arjen Poutsma, Rossen Stoyanchev

- - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `static MimeType` | `ALL` Public constant mime type that includes all media ranges (i.e. "*/*").
    `static String` | `ALL_VALUE` A String equivalent of `ALL`.
    `static MimeType` | `APPLICATION_JSON` Public constant mime type for `application/json`.
    `static String` | `APPLICATION_JSON_VALUE` A String equivalent of `APPLICATION_JSON`.
    `static MimeType` | `APPLICATION_OCTET_STREAM` Public constant mime type for `application/octet-stream`.
    `static String` | `APPLICATION_OCTET_STREAM_VALUE` A String equivalent of `APPLICATION_OCTET_STREAM`.
    `static MimeType` | `APPLICATION_XML` Public constant mime type for `application/xml`.
    `static String` | `APPLICATION_XML_VALUE` A String equivalent of `APPLICATION_XML`.
    `static MimeType` | `IMAGE_GIF` Public constant mime type for `image/gif`.
    `static String` | `IMAGE_GIF_VALUE` A String equivalent of `IMAGE_GIF`.
    `static MimeType` | `IMAGE_JPEG` Public constant mime type for `image/jpeg`.
    `static String` | `IMAGE_JPEG_VALUE` A String equivalent of `IMAGE_JPEG`.
    `static MimeType` | `IMAGE_PNG` Public constant mime type for `image/png`.
    `static String` | `IMAGE_PNG_VALUE` A String equivalent of `IMAGE_PNG`.
    `static Comparator<MimeType>` | `SPECIFICITY_COMPARATOR` Comparator used by `sortBySpecificity(List)`.
    `static MimeType` | `TEXT_HTML` Public constant mime type for `text/html`.
    `static String` | `TEXT_HTML_VALUE` A String equivalent of `TEXT_HTML`.
    `static MimeType` | `TEXT_PLAIN` Public constant mime type for `text/plain`.
    `static String` | `TEXT_PLAIN_VALUE` A String equivalent of `TEXT_PLAIN`.
    `static MimeType` | `TEXT_XML` Public constant mime type for `text/xml`.
    `static String` | `TEXT_XML_VALUE` A String equivalent of `TEXT_XML`.

  - ### 构造器概要

    构造器
    构造器和说明
    `MimeTypeUtils()`

  - ### 方法概要

    所有方法 静态方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `static byte[]` | `generateMultipartBoundary()` Generate a random MIME boundary as bytes, often used in multipart mime types.
    `static String` | `generateMultipartBoundaryString()` Generate a random MIME boundary as String, often used in multipart mime types.
    `static MimeType` | `parseMimeType(String mimeType)` Parse the given String into a single `MimeType`.
    `static List<MimeType>` | `parseMimeTypes(String mimeTypes)` Parse the given, comma-separated string into a list of `MimeType` objects.
    `static void` | `sortBySpecificity(List<MimeType> mimeTypes)` Sorts the given list of `MimeType` objects by specificity.
    `static String` | `toString(Collection<? extends MimeType> mimeTypes)` Return a string representation of the given list of `MimeType` objects.

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### 字段详细资料

    - #### SPECIFICITY_COMPARATOR

          public static final Comparator<MimeType> SPECIFICITY_COMPARATOR

      Comparator used by `sortBySpecificity(List)`.

    - #### ALL

          public static final MimeType ALL

      Public constant mime type that includes all media ranges (i.e. "*/*").

    - #### ALL_VALUE

          public static final String ALL_VALUE

      A String equivalent of `ALL`.
      另请参阅:
        常量字段值

    - #### APPLICATION_JSON

          public static final MimeType APPLICATION_JSON

      Public constant mime type for `application/json`.

    - #### APPLICATION_JSON_VALUE

          public static final String APPLICATION_JSON_VALUE

      A String equivalent of `APPLICATION_JSON`.
      另请参阅:
        常量字段值

    - #### APPLICATION_OCTET_STREAM

          public static final MimeType APPLICATION_OCTET_STREAM

      Public constant mime type for `application/octet-stream`.

    - #### APPLICATION_OCTET_STREAM_VALUE

          public static final String APPLICATION_OCTET_STREAM_VALUE

      A String equivalent of `APPLICATION_OCTET_STREAM`.
      另请参阅:
        常量字段值

    - #### APPLICATION_XML

          public static final MimeType APPLICATION_XML

      Public constant mime type for `application/xml`.

    - #### APPLICATION_XML_VALUE

          public static final String APPLICATION_XML_VALUE

      A String equivalent of `APPLICATION_XML`.
      另请参阅:
        常量字段值

    - #### IMAGE_GIF

          public static final MimeType IMAGE_GIF

      Public constant mime type for `image/gif`.

    - #### IMAGE_GIF_VALUE

          public static final String IMAGE_GIF_VALUE

      A String equivalent of `IMAGE_GIF`.
      另请参阅:
        常量字段值

    - #### IMAGE_JPEG

          public static final MimeType IMAGE_JPEG

      Public constant mime type for `image/jpeg`.

    - #### IMAGE_JPEG_VALUE

          public static final String IMAGE_JPEG_VALUE

      A String equivalent of `IMAGE_JPEG`.
      另请参阅:
        常量字段值

    - #### IMAGE_PNG

          public static final MimeType IMAGE_PNG

      Public constant mime type for `image/png`.

    - #### IMAGE_PNG_VALUE

          public static final String IMAGE_PNG_VALUE

      A String equivalent of `IMAGE_PNG`.
      另请参阅:
        常量字段值

    - #### TEXT_HTML

          public static final MimeType TEXT_HTML

      Public constant mime type for `text/html`.

    - #### TEXT_HTML_VALUE

          public static final String TEXT_HTML_VALUE

      A String equivalent of `TEXT_HTML`.
      另请参阅:
        常量字段值

    - #### TEXT_PLAIN

          public static final MimeType TEXT_PLAIN

      Public constant mime type for `text/plain`.

    - #### TEXT_PLAIN_VALUE

          public static final String TEXT_PLAIN_VALUE

      A String equivalent of `TEXT_PLAIN`.
      另请参阅:
        常量字段值

    - #### TEXT_XML

          public static final MimeType TEXT_XML

      Public constant mime type for `text/xml`.

    - #### TEXT_XML_VALUE

          public static final String TEXT_XML_VALUE

      A String equivalent of `TEXT_XML`.
      另请参阅:
        常量字段值

  - ### 构造器详细资料

    - #### MimeTypeUtils

          public MimeTypeUtils()

  - ### 方法详细资料

    - #### parseMimeType

          public static MimeType parseMimeType(String mimeType)

      Parse the given String into a single `MimeType`.
      参数:
        `mimeType` - the string to parse
      返回:
        the mime type
      抛出:
        `InvalidMimeTypeException` - if the string cannot be parsed

    - #### parseMimeTypes

          public static List<MimeType> parseMimeTypes(String mimeTypes)

      Parse the given, comma-separated string into a list of `MimeType` objects.
      参数:
        `mimeTypes` - the string to parse
      返回:
        the list of mime types
      抛出:
        `IllegalArgumentException` - if the string cannot be parsed

    - #### toString

          public static String toString(Collection<? extends MimeType> mimeTypes)

      Return a string representation of the given list of `MimeType` objects.
      参数:
        `mimeTypes` - the string to parse
      返回:
        the list of mime types
      抛出:
        `IllegalArgumentException` - if the String cannot be parsed

    - #### sortBySpecificity

          public static void sortBySpecificity(List<MimeType> mimeTypes)

      Sorts the given list of `MimeType` objects by specificity.

      Given two mime types:

      1. if either mime type has a wildcard type, then the mime type without the wildcard is ordered before the other.
      2. if the two mime types have different types, then they are considered equal and remain their current order.
      3. if either mime type has a wildcard subtype , then the mime type without the wildcard is sorted before the other.
      4. if the two mime types have different subtypes, then they are considered equal and remain their current order.
      5. if the two mime types have a different amount of parameters, then the mime type with the most parameters is ordered before the other.

      For example:

      > audio/basic < audio/* < */*

      > audio/basic;level=1 < audio/basic

      > audio/basic == text/html

      > audio/basic == audio/wave

      参数:
        `mimeTypes` - the list of mime types to be sorted
      另请参阅:
        HTTP 1.1: Semantics and Content, section 5.3.2

    - #### generateMultipartBoundary

          public static byte[] generateMultipartBoundary()

      Generate a random MIME boundary as bytes, often used in multipart mime types.

    - #### generateMultipartBoundaryString

          public static String generateMultipartBoundaryString()

      Generate a random MIME boundary as String, often used in multipart mime types.