当前位置: 首页>>代码示例>>Java>>正文


Java ContentType.toContentTypeString方法代码示例

本文整理汇总了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;
}
 
开发者ID:Hevelian,项目名称:hevelian-olastic,代码行数:24,代码来源:ElasticOData.java

示例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());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:33,代码来源:BatchParserCommon.java

示例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;
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:25,代码来源:ODataImpl.java

示例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());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:12,代码来源:ContentNegotiator.java

示例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());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:9,代码来源:ODataImpl.java

示例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());
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:14,代码来源:ODataImpl.java

示例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());
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:13,代码来源:ODataImpl.java

示例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);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:9,代码来源:AbstractODataBasicRequest.java


注:本文中的org.apache.olingo.commons.api.format.ContentType.toContentTypeString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。