本文整理汇总了Java中javax.ws.rs.core.MediaType.toString方法的典型用法代码示例。如果您正苦于以下问题:Java MediaType.toString方法的具体用法?Java MediaType.toString怎么用?Java MediaType.toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.core.MediaType
的用法示例。
在下文中一共展示了MediaType.toString方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDocumentationMessageMapper
import javax.ws.rs.core.MediaType; //导入方法依赖的package包/类
/**
* Returns the right {@link DocumentationMessageMapper} for the provided
* {@code MediaType} that supports writing the provided {@link
* Documentation}.
*
* @param mediaType the request's {@code MediaType}
* @param documentation the {@code Documentation} to write
* @return the {@code DocumentationMessageMapper} that writes the {@code
* Documentation} in the {@code MediaType}
*/
protected DocumentationMessageMapper getDocumentationMessageMapper(
MediaType mediaType, Documentation documentation) {
Stream<DocumentationMessageMapper> stream =
_documentationMessageMappers.stream();
String mediaTypeString = mediaType.toString();
return stream.filter(
bodyWriter ->
mediaTypeString.equals(bodyWriter.getMediaType()) &&
bodyWriter.supports(documentation, _httpHeaders)
).findFirst(
).orElseThrow(
() -> new MustHaveDocumentationMessageMapper(mediaTypeString)
);
}
示例2: getSingleModelMessageMapper
import javax.ws.rs.core.MediaType; //导入方法依赖的package包/类
/**
* Returns the right {@link SingleModelMessageMapper} for the provided
* {@code MediaType} that supports writing the provided {@link SingleModel}.
*
* @param mediaType the request's {@code MediaType}
* @param singleModel the single model to write
* @return the {@code SingleModelMessageMapper} that writes the {@code
* SingleModel} in the {@code MediaType}
*/
protected SingleModelMessageMapper<T> getSingleModelMessageMapper(
MediaType mediaType, SingleModel<T> singleModel) {
Stream<SingleModelMessageMapper<T>> stream =
_singleModelMessageMappers.stream();
String mediaTypeString = mediaType.toString();
return stream.filter(
messageMapper ->
mediaTypeString.equals(messageMapper.getMediaType()) &&
messageMapper.supports(singleModel, _httpHeaders)
).findFirst(
).orElseThrow(
() -> new ApioDeveloperError.MustHaveMessageMapper(
mediaTypeString, singleModel.getModelClass())
);
}
示例3: getPageMessageMapper
import javax.ws.rs.core.MediaType; //导入方法依赖的package包/类
/**
* Returns the right {@link PageMessageMapper} for the provided {@code
* MediaType} that supports writing the provided {@link Page}.
*
* @param mediaType the request's {@code MediaType}
* @param page the {@code Page} to write
* @return the {@code PageMessageMapper} that writes the {@code Page} in the
* {@code MediaType}
*/
protected PageMessageMapper<T> getPageMessageMapper(
MediaType mediaType, Page<T> page) {
Stream<PageMessageMapper<T>> stream = _pageMessageMappers.stream();
String mediaTypeString = mediaType.toString();
return stream.filter(
bodyWriter ->
mediaTypeString.equals(bodyWriter.getMediaType()) &&
bodyWriter.supports(page, _httpHeaders)
).findFirst(
).orElseThrow(
() -> new MustHaveMessageMapper(
mediaTypeString, page.getModelClass())
);
}
示例4: getFormMessageMapper
import javax.ws.rs.core.MediaType; //导入方法依赖的package包/类
/**
* Returns the right {@link FormMessageMapper} for the provided {@code
* MediaType} that supports writing the provided {@link Form}.
*
* @param mediaType the request's {@code MediaType}
* @param form the {@code Form} to write
* @return the {@code FormMessageMapper} that writes the {@code Form} in the
* {@code MediaType}
*/
protected FormMessageMapper getFormMessageMapper(
MediaType mediaType, Form form) {
Stream<FormMessageMapper> stream = _formMessageMappers.stream();
String mediaTypeString = mediaType.toString();
return stream.filter(
bodyWriter ->
mediaTypeString.equals(bodyWriter.getMediaType()) &&
bodyWriter.supports(form, _httpHeaders)
).findFirst(
).orElseThrow(
() -> new MustHaveFormMessageMapper(mediaTypeString)
);
}
示例5: _415MediaNotSupportException
import javax.ws.rs.core.MediaType; //导入方法依赖的package包/类
public _415MediaNotSupportException(final Class<?> clazz,
final MediaType media,
final Set<MediaType> expected) {
super(clazz, media.toString(), StringUtil.join(expected.toArray(new MediaType[]{})));
}
示例6: MessageBodyReaderContext
import javax.ws.rs.core.MediaType; //导入方法依赖的package包/类
public MessageBodyReaderContext(InputStream in, MediaType mediaType){
this.in = in;
this.contentType = mediaType.toString();
String charset = mediaType.getParameters().get("charset");
this.charEncoding = charset == null ? "UTF-8" : charset;
}