Package org.springframework.http

Examples of org.springframework.http.MediaType


   */
  public MappingMediaTypeFileExtensionResolver(Map<String, MediaType> mediaTypes) {
    if (mediaTypes != null) {
      for (Entry<String, MediaType> entries : mediaTypes.entrySet()) {
        String extension = entries.getKey().toLowerCase(Locale.ENGLISH);
        MediaType mediaType = entries.getValue();
        addMapping(extension, mediaType);
      }
    }
  }
View Full Code Here


  /**
   * Map a MediaType to an extension or ignore if the extensions is already mapped.
   */
  protected void addMapping(String extension, MediaType mediaType) {
    MediaType previous = this.mediaTypes.putIfAbsent(extension, mediaType);
    if (previous == null) {
      this.fileExtensions.add(mediaType, extension);
      this.allFileExtensions.add(extension);
    }
  }
View Full Code Here

  }

  public List<MediaType> resolveMediaTypes(NativeWebRequest webRequest) {
    String key = getMediaTypeKey(webRequest);
    if (StringUtils.hasText(key)) {
      MediaType mediaType = lookupMediaType(key);
      if (mediaType != null) {
        handleMatch(key, mediaType);
        return Collections.singletonList(mediaType);
      }
      mediaType = handleNoMatch(webRequest, key);
View Full Code Here

   * Look up the given extension via {@link ServletContext#getMimeType(String)}
   * and if that doesn't help, delegate to the parent implementation.
   */
  @Override
  protected MediaType handleNoMatch(NativeWebRequest webRequest, String extension) {
    MediaType mediaType = null;
    if (this.servletContext != null) {
      String mimeType = this.servletContext.getMimeType("file." + extension);
      if (StringUtils.hasText(mimeType)) {
        mediaType = MediaType.parseMediaType(mimeType);
      }
    }
    if (mediaType == null || MediaType.APPLICATION_OCTET_STREAM.equals(mediaType)) {
      MediaType superMediaType = super.handleNoMatch(webRequest, extension);
      if (superMediaType != null) {
        mediaType = superMediaType;
      }
    }
    return mediaType;
View Full Code Here

* @since 3.0.2
*/
public class RssChannelHttpMessageConverter extends AbstractWireFeedHttpMessageConverter<Channel> {

  public RssChannelHttpMessageConverter() {
    super(new MediaType("application", "rss+xml"));
  }
View Full Code Here

* @since 3.0.2
*/
public class AtomFeedHttpMessageConverter extends AbstractWireFeedHttpMessageConverter<Feed> {

  public AtomFeedHttpMessageConverter() {
    super(new MediaType("application", "atom+xml"));
  }
View Full Code Here

    ImageInputStream imageInputStream = null;
    ImageReader imageReader = null;
    try {
      imageInputStream = createImageInputStream(inputMessage.getBody());
      MediaType contentType = inputMessage.getHeaders().getContentType();
      Iterator<ImageReader> imageReaders = ImageIO.getImageReadersByMIMEType(contentType.toString());
      if (imageReaders.hasNext()) {
        imageReader = imageReaders.next();
        ImageReadParam irp = imageReader.getDefaultReadParam();
        process(irp);
        imageReader.setInput(imageInputStream, true);
View Full Code Here

  @Override
  @SuppressWarnings("unchecked")
  protected T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage)
      throws IOException, HttpMessageNotReadableException {
    WireFeedInput feedInput = new WireFeedInput();
    MediaType contentType = inputMessage.getHeaders().getContentType();
    Charset charset;
    if (contentType != null && contentType.getCharSet() != null) {
      charset = contentType.getCharSet();
    } else {
      charset = DEFAULT_CHARSET;
    }
    try {
      Reader reader = new InputStreamReader(inputMessage.getBody(), charset);
View Full Code Here

      throws IOException, HttpMessageNotWritableException {
    String wireFeedEncoding = wireFeed.getEncoding();
    if (!StringUtils.hasLength(wireFeedEncoding)) {
      wireFeedEncoding = DEFAULT_CHARSET.name();
    }
    MediaType contentType = outputMessage.getHeaders().getContentType();
    if (contentType != null) {
      Charset wireFeedCharset = Charset.forName(wireFeedEncoding);
      contentType = new MediaType(contentType.getType(), contentType.getSubtype(), wireFeedCharset);
      outputMessage.getHeaders().setContentType(contentType);
    }

    WireFeedOutput feedOutput = new WireFeedOutput();
View Full Code Here

  /**
   * Protected constructor that sets the {@link #setSupportedMediaTypes(java.util.List) supportedMediaTypes}
   * to {@code text/xml} and {@code application/xml}, and {@code application/*-xml}.
   */
  protected AbstractXmlHttpMessageConverter() {
    super(MediaType.APPLICATION_XML, MediaType.TEXT_XML, new MediaType("application", "*+xml"));
  }
 
View Full Code Here

TOP

Related Classes of org.springframework.http.MediaType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.