org.springframework.util

## 类 MimeType

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

- 所有已实现的接口:
    Serializable, Comparable<MimeType>

      public class MimeType
      extends Object
      implements Comparable<MimeType>, Serializable

  Represents a MIME Type, as originally defined in RFC 2046 and subsequently used in other Internet protocols including HTTP.

  This class, however, does not contain support for the q-parameters used in HTTP content negotiation. Those can be found in the subclass `org.springframework.http.MediaType` in the `spring-web` module.

  Consists of a type and a subtype. Also has functionality to parse MIME Type values from a `String` using `valueOf(String)`. For more parsing options see `MimeTypeUtils`.

  从以下版本开始:
    4.0
  作者:
    Arjen Poutsma, Juergen Hoeller, Rossen Stoyanchev, Sam Brannen
  另请参阅:
    `MimeTypeUtils`, 序列化表格

- - ### 嵌套类概要

    嵌套类
    限定符和类型 | 类和说明
    --- | ---
    `static class` | `MimeType.SpecificityComparator<T extends MimeType>`

  - ### 字段概要

    字段
    限定符和类型 | 字段和说明
    --- | ---
    `protected static String` | `WILDCARD_TYPE`

  - ### 构造器概要

    构造器
    构造器和说明
    `MimeType(MimeType other, Charset charset)` Copy-constructor that copies the type, subtype, parameters of the given `MimeType`, and allows to set the specified character set.
    `MimeType(MimeType other, Map<String,String> parameters)` Copy-constructor that copies the type and subtype of the given `MimeType`, and allows for different parameter.
    `MimeType(String type)` Create a new `MimeType` for the given primary type.
    `MimeType(String type, String subtype)` Create a new `MimeType` for the given primary type and subtype.
    `MimeType(String type, String subtype, Charset charset)` Create a new `MimeType` for the given type, subtype, and character set.
    `MimeType(String type, String subtype, Map<String,String> parameters)` Create a new `MimeType` for the given type, subtype, and parameters.

  - ### 方法概要

    所有方法 静态方法 实例方法 具体方法
    限定符和类型 | 方法和说明
    --- | ---
    `protected void` | `appendTo(StringBuilder builder)`
    `protected void` | `checkParameters(String attribute, String value)`
    `int` | `compareTo(MimeType other)` Compares this MIME Type to another alphabetically.
    `boolean` | `equals(Object other)`
    `Charset` | `getCharset()` Return the character set, as indicated by a `charset` parameter, if any.
    `String` | `getParameter(String name)` Return a generic parameter value, given a parameter name.
    `Map<String,String>` | `getParameters()` Return all generic parameter values.
    `String` | `getSubtype()` Return the subtype.
    `String` | `getType()` Return the primary type.
    `int` | `hashCode()`
    `boolean` | `includes(MimeType other)` Indicate whether this MIME Type includes the given MIME Type.
    `boolean` | `isCompatibleWith(MimeType other)` Indicate whether this MIME Type is compatible with the given MIME Type.
    `boolean` | `isConcrete()` Indicates whether this MIME Type is concrete, i.e. whether neither the type nor the subtype is a wildcard character `*`.
    `boolean` | `isWildcardSubtype()` Indicates whether the subtype is the wildcard character `*` or the wildcard character followed by a suffix (e.g.
    `boolean` | `isWildcardType()` Indicates whether the type is the wildcard character `*` or not.
    `String` | `toString()`
    `protected String` | `unquote(String s)`
    `static MimeType` | `valueOf(String value)` Parse the given String value into a `MimeType` object, with this method name following the 'valueOf' naming convention (as supported by `ConversionService`.

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

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### 字段详细资料

    - #### WILDCARD_TYPE

          protected static final String WILDCARD_TYPE

      另请参阅:
        常量字段值

  - ### 构造器详细资料

    - #### MimeType

          public MimeType(String type)

      Create a new `MimeType` for the given primary type.

      The subtype is set to `"*"`, and the parameters are empty.

      参数:
        `type` - the primary type
      抛出:
        `IllegalArgumentException` - if any of the parameters contains illegal characters

    - #### MimeType

          public MimeType(String type,
                          String subtype)

      Create a new `MimeType` for the given primary type and subtype.

      The parameters are empty.

      参数:
        `type` - the primary type
        `subtype` - the subtype
      抛出:
        `IllegalArgumentException` - if any of the parameters contains illegal characters

    - #### MimeType

          public MimeType(String type,
                          String subtype,
                          Charset charset)

      Create a new `MimeType` for the given type, subtype, and character set.
      参数:
        `type` - the primary type
        `subtype` - the subtype
        `charset` - the character set
      抛出:
        `IllegalArgumentException` - if any of the parameters contains illegal characters

    - #### MimeType

          public MimeType(MimeType other,
                          Charset charset)

      Copy-constructor that copies the type, subtype, parameters of the given `MimeType`, and allows to set the specified character set.
      参数:
        `other` - the other MimeType
        `charset` - the character set
      抛出:
        `IllegalArgumentException` - if any of the parameters contains illegal characters
      从以下版本开始:
        4.3

    - #### MimeType

          public MimeType(MimeType other,
                          @Nullable
                          Map<String,String> parameters)

      Copy-constructor that copies the type and subtype of the given `MimeType`, and allows for different parameter.
      参数:
        `other` - the other MimeType
        `parameters` - the parameters (may be `null`)
      抛出:
        `IllegalArgumentException` - if any of the parameters contains illegal characters

    - #### MimeType

          public MimeType(String type,
                          String subtype,
                          @Nullable
                          Map<String,String> parameters)

      Create a new `MimeType` for the given type, subtype, and parameters.
      参数:
        `type` - the primary type
        `subtype` - the subtype
        `parameters` - the parameters (may be `null`)
      抛出:
        `IllegalArgumentException` - if any of the parameters contains illegal characters

  - ### 方法详细资料

    - #### checkParameters

          protected void checkParameters(String attribute,
                                         String value)

    - #### unquote

          protected String unquote(String s)

    - #### isWildcardType

          public boolean isWildcardType()

      Indicates whether the type is the wildcard character `*` or not.

    - #### isWildcardSubtype

          public boolean isWildcardSubtype()

      Indicates whether the subtype is the wildcard character `*` or the wildcard character followed by a suffix (e.g. `*+xml`).
      返回:
        whether the subtype is a wildcard

    - #### isConcrete

          public boolean isConcrete()

      Indicates whether this MIME Type is concrete, i.e. whether neither the type nor the subtype is a wildcard character `*`.
      返回:
        whether this MIME Type is concrete

    - #### getType

          public String getType()

      Return the primary type.

    - #### getSubtype

          public String getSubtype()

      Return the subtype.

    - #### getCharset

          @Nullable
          public Charset getCharset()

      Return the character set, as indicated by a `charset` parameter, if any.
      返回:
        the character set, or `null` if not available
      从以下版本开始:
        4.3

    - #### getParameter

          @Nullable
          public String getParameter(String name)

      Return a generic parameter value, given a parameter name.
      参数:
        `name` - the parameter name
      返回:
        the parameter value, or `null` if not present

    - #### getParameters

          public Map<String,String> getParameters()

      Return all generic parameter values.
      返回:
        a read-only map (possibly empty, never `null`)

    - #### includes

          public boolean includes(@Nullable
                                  MimeType other)

      Indicate whether this MIME Type includes the given MIME Type.

      For instance, `text/*` includes `text/plain` and `text/html`, and `application/*+xml` includes `application/soap+xml`, etc. This method is not symmetric.

      参数:
        `other` - the reference MIME Type with which to compare
      返回:
        `true` if this MIME Type includes the given MIME Type; `false` otherwise

    - #### isCompatibleWith

          public boolean isCompatibleWith(@Nullable
                                          MimeType other)

      Indicate whether this MIME Type is compatible with the given MIME Type.

      For instance, `text/*` is compatible with `text/plain`, `text/html`, and vice versa. In effect, this method is similar to `includes(org.springframework.util.MimeType)`, except that it is symmetric.

      参数:
        `other` - the reference MIME Type with which to compare
      返回:
        `true` if this MIME Type is compatible with the given MIME Type; `false` otherwise

    - #### equals

          public boolean equals(Object other)

      覆盖:
        `equals` 在类中 `Object`

    - #### hashCode

          public int hashCode()

      覆盖:
        `hashCode` 在类中 `Object`

    - #### toString

          public String toString()

      覆盖:
        `toString` 在类中 `Object`

    - #### appendTo

          protected void appendTo(StringBuilder builder)

    - #### compareTo

          public int compareTo(MimeType other)

      Compares this MIME Type to another alphabetically.
      指定者:
        `compareTo` 在接口中 `Comparable<MimeType>`
      参数:
        `other` - the MIME Type to compare to
      另请参阅:
        `MimeTypeUtils.sortBySpecificity(List)`

    - #### valueOf

          public static MimeType valueOf(String value)

      Parse the given String value into a `MimeType` object, with this method name following the 'valueOf' naming convention (as supported by `ConversionService`.
      另请参阅:
        `MimeTypeUtils.parseMimeType(String)`