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


Java ContentType.parse方法代码示例

本文整理汇总了Java中org.apache.olingo.commons.api.format.ContentType.parse方法的典型用法代码示例。如果您正苦于以下问题:Java ContentType.parse方法的具体用法?Java ContentType.parse怎么用?Java ContentType.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.olingo.commons.api.format.ContentType的用法示例。


在下文中一共展示了ContentType.parse方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateCurrentCharset

import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
private void updateCurrentCharset(final String currentLine) {
  if (currentLine != null) {
    if (currentLine.startsWith(HttpHeader.CONTENT_TYPE)) {
      final ContentType contentType = ContentType.parse(
          currentLine.substring(HttpHeader.CONTENT_TYPE.length() + 1, currentLine.length() - 2).trim());
      if (contentType != null) {
        final String charsetString = contentType.getParameter(ContentType.PARAMETER_CHARSET);
        currentCharset = charsetString == null ?
            contentType.isCompatible(ContentType.APPLICATION_JSON) || contentType.getSubtype().contains("xml") ?
                Charset.forName("UTF-8") :
                DEFAULT_CHARSET :
            Charset.forName(charsetString);

        final String boundary = contentType.getParameter(BOUNDARY);
        if (boundary != null) {
          currentBoundary = DOUBLE_DASH + boundary;
        }
      }
    } else if (CRLF.equals(currentLine)) {
      readState.foundLinebreak();
    } else if (isBoundary(currentLine)) {
      readState.foundBoundary();
    }
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:26,代码来源:BatchLineReader.java

示例2: getBody

import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
@Override
public ClientPrimitiveValue getBody() {
  if (resValue == null) {
    final ContentType contentType = ContentType.parse(getAccept());
    
    try {
      resValue = odataClient.getObjectFactory().newPrimitiveValueBuilder().
              setType(contentType.isCompatible(ContentType.TEXT_PLAIN)
                      ? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
              setValue(getRawResponse()).
              build();
    } catch (Exception e) {
      throw new HttpClientException(e);
    } finally {
      this.close();
    }
  }
  return resValue;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:20,代码来源:ODataValueUpdateRequestImpl.java

示例3: getBody

import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
@Override
public ClientPrimitiveValue getBody() {
  if (value == null) {
    final ContentType contentType = ContentType.parse(getContentType());

    try {
      value = odataClient.getObjectFactory().newPrimitiveValueBuilder().
              setType(contentType.isCompatible(ContentType.TEXT_PLAIN)
                      ? EdmPrimitiveTypeKind.String : EdmPrimitiveTypeKind.Stream).
              setValue(IOUtils.toString(getRawResponse())).build();
    } catch (Exception e) {
      throw new HttpClientException(e);
    } finally {
      this.close();
    }
  }
  return value;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:19,代码来源:ODataValueRequestImpl.java

示例4: getCharset

import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
private Charset getCharset(final BatchQueryOperation operation) {
  final ContentType contentType = ContentType.parse(operation.getHeaders().getHeader(HttpHeader.CONTENT_TYPE));
  if (contentType != null) {
    final String charsetValue = contentType.getParameter(ContentType.PARAMETER_CHARSET);
    if (charsetValue == null) {
      if (contentType.isCompatible(ContentType.APPLICATION_JSON) || contentType.getSubtype().contains("xml")) {
        return Charset.forName("UTF-8");
      }
    } else {
      return Charset.forName(charsetValue);
    }
  }
  return Charset.forName("ISO-8859-1");
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:15,代码来源:BatchRequestTransformator.java

示例5: handleMediaValueDispatching

import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
private void handleMediaValueDispatching(final ODataRequest request, final ODataResponse response,
    final UriResource resource) throws ContentNegotiatorException, 
   ODataApplicationException, ODataLibraryException,
    ODataHandlerException, PreconditionException {
  final HttpMethod method = request.getMethod();
  if (method == HttpMethod.GET) {
    // This can be a GET on an EntitySet, Navigation or Function
    final ContentType requestedContentType = ContentNegotiator.
        doContentNegotiation(uriInfo.getFormatOption(),
        request, handler.getCustomContentTypeSupport(), RepresentationType.MEDIA);
    handler.selectProcessor(MediaEntityProcessor.class)
        .readMediaEntity(request, response, uriInfo, requestedContentType);
    // PUT and DELETE can only be called on EntitySets or Navigation properties which are media resources
  } else if (method == HttpMethod.PUT && (isEntityOrNavigationMedia(resource) 
      || isSingletonMedia(resource))) {
    validatePreconditions(request, true);
    final ContentType requestFormat = ContentType.parse(request.getHeader(HttpHeader.CONTENT_TYPE));
    final ContentType responseFormat = ContentNegotiator.doContentNegotiation(uriInfo.getFormatOption(),
        request, handler.getCustomContentTypeSupport(), RepresentationType.ENTITY);
    handler.selectProcessor(MediaEntityProcessor.class)
        .updateMediaEntity(request, response, uriInfo, requestFormat, responseFormat);
  } else if (method == HttpMethod.DELETE && isEntityOrNavigationMedia(resource)) {
    validatePreconditions(request, true);
    handler.selectProcessor(MediaEntityProcessor.class)
        .deleteMediaEntity(request, response, uriInfo);
  } else {
    throwMethodNotAllowed(method);
  }
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:30,代码来源:ODataDispatcher.java

示例6: getBody

import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
@Override
public ClientEntitySetIterator<ES, E> getBody() {
  if (entitySetIterator == null) {
    entitySetIterator = new ClientEntitySetIterator<ES, E>(
            odataClient, getRawResponse(), ContentType.parse(getContentType()));
  }
  return entitySetIterator;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:9,代码来源:ODataEntitySetIteratorRequestImpl.java

示例7: getRequestContentType

import org.apache.olingo.commons.api.format.ContentType; //导入方法依赖的package包/类
public ContentType getRequestContentType() {
  if (this.request.getHeader(HttpHeader.CONTENT_TYPE) != null) {
    return ContentType.parse(this.request.getHeader(HttpHeader.CONTENT_TYPE));
  }
  return ContentType.APPLICATION_OCTET_STREAM;
}
 
开发者ID:apache,项目名称:olingo-odata4,代码行数:7,代码来源:ServiceRequest.java


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