本文整理汇总了Java中org.apache.olingo.commons.api.format.ContentType.toContentTypeString方法的典型用法代码示例。如果您正苦于以下问题:Java ContentType.toContentTypeString方法的具体用法?Java ContentType.toContentTypeString怎么用?Java ContentType.toContentTypeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.olingo.commons.api.format.ContentType
的用法示例。
在下文中一共展示了ContentType.toContentTypeString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSerializer
import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
@Override
public ODataSerializer createSerializer(ContentType contentType) throws SerializerException {
ODataSerializer serializer = null;
if (contentType.isCompatible(ContentType.APPLICATION_JSON)) {
String metadata = contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA);
if (metadata == null
|| ContentType.VALUE_ODATA_METADATA_MINIMAL.equalsIgnoreCase(metadata)
|| ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase(metadata)
|| ContentType.VALUE_ODATA_METADATA_FULL.equalsIgnoreCase(metadata)) {
serializer = new ElasticODataJsonSerializer(contentType);
}
} else if (contentType.isCompatible(ContentType.APPLICATION_XML)
|| contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) {
serializer = new ElasticODataXmlSerializer();
}
if (serializer == null) {
throw new SerializerException(
"Unsupported format: " + contentType.toContentTypeString(),
SerializerException.MessageKeys.UNSUPPORTED_FORMAT,
contentType.toContentTypeString());
}
return serializer;
}
示例2: parseContentType
import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
/**
* Get the content type based on <code>contentType</code> parameter.
* If this content type is not compatible to the expected ContentType a
* BatchDeserializerException is thrown.
*
* @param contentType content type string which is parsed
* @param expected content type to which the parsed must be compatible
* @param line parsed line
* @return the parsed content type or if not compatible or parseable an exception is thrown (never returns null)
* @throws BatchDeserializerException
*/
public static ContentType parseContentType(final String contentType, final ContentType expected, final int line)
throws BatchDeserializerException {
if (contentType == null) {
throw new BatchDeserializerException("Missing content type",
BatchDeserializerException.MessageKeys.MISSING_CONTENT_TYPE, Integer.toString(line));
}
ContentType type;
try {
type = ContentType.create(contentType);
} catch (final IllegalArgumentException e) {
throw new BatchDeserializerException("Invalid content type.", e,
BatchDeserializerException.MessageKeys.INVALID_CONTENT_TYPE, Integer.toString(line));
}
if (type.isCompatible(expected)) {
return type;
} else {
throw new BatchDeserializerException("Content type is not the expected content type",
BatchDeserializerException.MessageKeys.UNEXPECTED_CONTENT_TYPE,
Integer.toString(line), expected.toContentTypeString(), type.toContentTypeString());
}
}
示例3: createSerializer
import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
@Override
public ODataSerializer createSerializer(final ContentType contentType) throws SerializerException {
ODataSerializer serializer = null;
if (contentType.isCompatible(ContentType.APPLICATION_JSON)) {
final String metadata = contentType.getParameter(ContentType.PARAMETER_ODATA_METADATA);
if (metadata == null
|| ContentType.VALUE_ODATA_METADATA_MINIMAL.equalsIgnoreCase(metadata)
|| ContentType.VALUE_ODATA_METADATA_NONE.equalsIgnoreCase(metadata)
|| ContentType.VALUE_ODATA_METADATA_FULL.equalsIgnoreCase(metadata)) {
serializer = new ODataJsonSerializer(contentType, new Constantsv00());
}
} else if (contentType.isCompatible(ContentType.APPLICATION_XML)
|| contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) {
serializer = new ODataXmlSerializer();
}
if (serializer == null) {
throw new SerializerException("Unsupported format: " + contentType.toContentTypeString(),
SerializerException.MessageKeys.UNSUPPORTED_FORMAT, contentType.toContentTypeString());
} else {
return serializer;
}
}
示例4: checkSupport
import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
public static void checkSupport(final ContentType contentType,
final CustomContentTypeSupport customContentTypeSupport, final RepresentationType representationType)
throws ContentNegotiatorException {
for (ContentType supportedContentType : getSupportedContentTypes(customContentTypeSupport, representationType)) {
if (AcceptType.fromContentType(supportedContentType).get(0).matches(contentType)) {
return;
}
}
throw new ContentNegotiatorException("unsupported content type: " + contentType,
ContentNegotiatorException.MessageKeys.UNSUPPORTED_CONTENT_TYPE, contentType.toContentTypeString());
}
示例5: createEdmAssistedSerializer
import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
@Override
public EdmAssistedSerializer createEdmAssistedSerializer(final ContentType contentType) throws SerializerException {
if (contentType.isCompatible(ContentType.APPLICATION_JSON)) {
return new EdmAssistedJsonSerializer(contentType);
}
throw new SerializerException("Unsupported format: " + contentType.toContentTypeString(),
SerializerException.MessageKeys.UNSUPPORTED_FORMAT, contentType.toContentTypeString());
}
示例6: createEdmDeltaSerializer
import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
@Override
public EdmDeltaSerializer createEdmDeltaSerializer(final ContentType contentType, final List<String> versions)
throws SerializerException {
if (contentType.isCompatible(ContentType.APPLICATION_JSON)) {
if(versions!=null && !versions.isEmpty()){
return getMaxVersion(versions)>4 ? new JsonDeltaSerializerWithNavigations(contentType):
new JsonDeltaSerializer(contentType);
}
return new JsonDeltaSerializerWithNavigations(contentType);
}
throw new SerializerException("Unsupported format: " + contentType.toContentTypeString(),
SerializerException.MessageKeys.UNSUPPORTED_FORMAT, contentType.toContentTypeString());
}
示例7: createDeserializer
import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
@Override
public ODataDeserializer createDeserializer(final ContentType contentType) throws DeserializerException {
if (contentType.isCompatible(ContentType.JSON)) {
return new ODataJsonDeserializer(contentType);
} else if (contentType.isCompatible(ContentType.APPLICATION_XML)
|| contentType.isCompatible(ContentType.APPLICATION_ATOM_XML)) {
return new ODataXmlDeserializer();
} else {
throw new DeserializerException("Unsupported format: " + contentType.toContentTypeString(),
DeserializerException.MessageKeys.UNSUPPORTED_FORMAT, contentType.toContentTypeString());
}
}
示例8: setFormat
import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
@Override
public void setFormat(final ContentType contentType) {
if (contentType != null) {
final String formatString = contentType.toContentTypeString();
setAccept(formatString);
setContentType(formatString);
}
}