本文整理汇总了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();
}
}
}
示例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;
}
示例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;
}
示例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");
}
示例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);
}
}
示例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;
}
示例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;
}