List of usage examples for org.springframework.http MediaType includes
public boolean includes(@Nullable MediaType other)
From source file:com.revolsys.ui.web.rest.interceptor.WebAnnotationMethodHandlerAdapter.java
private MediaType getMediaType(final List<MediaType> supportedMediaTypes, final MediaType acceptedMediaType) { for (final MediaType mediaType : supportedMediaTypes) { if (mediaType.equals(acceptedMediaType)) { return mediaType; }//ww w . j av a2 s . c om } for (final MediaType mediaType : supportedMediaTypes) { if (acceptedMediaType.isWildcardType() || mediaType.includes(acceptedMediaType)) { return mediaType; } } return null; }
From source file:org.springframework.boot.autoconfigure.web.servlet.WelcomePageHandlerMapping.java
@Override public Object getHandlerInternal(HttpServletRequest request) throws Exception { for (MediaType mediaType : getAcceptedMediaTypes(request)) { if (mediaType.includes(MediaType.TEXT_HTML)) { return super.getHandlerInternal(request); }//from w w w.j a v a 2 s .co m } return null; }
From source file:org.springframework.http.converter.AbstractHttpMessageConverter.java
/** * Returns {@code true} if any of the {@linkplain #setSupportedMediaTypes(List) * supported} media types {@link MediaType#includes(MediaType) include} the * given media type.//from w w w.java 2s .c o m * @param mediaType the media type to read, can be {@code null} if not specified. * Typically the value of a {@code Content-Type} header. * @return {@code true} if the supported media types include the media type, * or if the media type is {@code null} */ protected boolean canRead(@Nullable MediaType mediaType) { if (mediaType == null) { return true; } for (MediaType supportedMediaType : getSupportedMediaTypes()) { if (supportedMediaType.includes(mediaType)) { return true; } } return false; }
From source file:org.springframework.http.converter.FormHttpMessageConverter.java
@Override public boolean canRead(Class<?> clazz, @Nullable MediaType mediaType) { if (!MultiValueMap.class.isAssignableFrom(clazz)) { return false; }// w ww .ja va 2 s. co m if (mediaType == null) { return true; } for (MediaType supportedMediaType : getSupportedMediaTypes()) { // We can't read multipart.... if (!supportedMediaType.equals(MediaType.MULTIPART_FORM_DATA) && supportedMediaType.includes(mediaType)) { return true; } } return false; }
From source file:org.springframework.security.web.server.util.matcher.MediaTypeServerWebExchangeMatcher.java
private boolean shouldIgnore(MediaType httpRequestMediaType) { for (MediaType ignoredMediaType : this.ignoredMediaTypes) { if (httpRequestMediaType.includes(ignoredMediaType)) { return true; }/*from w ww. j av a 2s . co m*/ } return false; }