當前位置: 首頁>>代碼示例>>Java>>正文


Java MediaType.toString方法代碼示例

本文整理匯總了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)
	);
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:28,代碼來源:DocumentationMessageBodyWriter.java

示例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())
	);
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:28,代碼來源:SingleModelMessageBodyWriter.java

示例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())
	);
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:27,代碼來源:PageMessageBodyWriter.java

示例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)
	);
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:26,代碼來源:FormMessageBodyWriter.java

示例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[]{})));
}
 
開發者ID:silentbalanceyh,項目名稱:vertx-zero,代碼行數:6,代碼來源:_415MediaNotSupportException.java

示例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;
}
 
開發者ID:teamdigitale,項目名稱:ontonethub,代碼行數:7,代碼來源:IndexingJobInputReader.java


注:本文中的javax.ws.rs.core.MediaType.toString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。