org.springframework.messaging.converter

## Class DefaultContentTypeResolver

- java.lang.Object
- - org.springframework.messaging.converter.DefaultContentTypeResolver

- All Implemented Interfaces:
    ContentTypeResolver

      public class DefaultContentTypeResolver
      extends Object
      implements ContentTypeResolver

  A default `ContentTypeResolver` that checks the `MessageHeaders.CONTENT_TYPE` header or falls back to a default value.

  The header value is expected to be a `MimeType` or a `String` that can be parsed into a `MimeType`.

  Since:
    4.0
  Author:
    Rossen Stoyanchev

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultContentTypeResolver()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `MimeType` | `getDefaultMimeType()` Return the default MIME type to use if no `MessageHeaders.CONTENT_TYPE` header is present.
    `MimeType` | `resolve(MessageHeaders headers)` Determine the `MimeType` of a message from the given MessageHeaders.
    `void` | `setDefaultMimeType(MimeType defaultMimeType)` Set the default MIME type to use when there is no `MessageHeaders.CONTENT_TYPE` header present.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### DefaultContentTypeResolver

          public DefaultContentTypeResolver()

  - ### Method Detail

    - #### setDefaultMimeType

          public void setDefaultMimeType(MimeType defaultMimeType)

      Set the default MIME type to use when there is no `MessageHeaders.CONTENT_TYPE` header present.

      This property does not have a default value.

    - #### getDefaultMimeType

          public MimeType getDefaultMimeType()

      Return the default MIME type to use if no `MessageHeaders.CONTENT_TYPE` header is present.

    - #### resolve

          public MimeType resolve(MessageHeaders headers)

      Description copied from interface: `ContentTypeResolver`
      Determine the `MimeType` of a message from the given MessageHeaders.
      Specified by:
        `resolve` in interface `ContentTypeResolver`
      Parameters:
        `headers` - the headers to use for the resolution
      Returns:
        the resolved `MimeType` of `null` if none found

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`