/** * Parses the given input string (<code>format</code>) and returns created {@link ContentType} if input was valid or * return <code>NULL</code> if input was not parseable. * * For the definition of the supported format see {@link #create(String)}. * * @param format a string in format as defined in RFC 7231, chapter 3.1.1.1 * @return a new <code>ContentType</code> object */ public static ContentType parse(final String format) { try { return ContentType.create(format); } catch (IllegalArgumentException e) { return null; } }
/** * Parses the given input string (<code>format</code>) and returns created {@link ContentType} if input was valid or * return <code>NULL</code> if input was not parseable. * * For the definition of the supported format see {@link #create(String)}. * * @param format a string in format as defined in RFC 7231, chapter 3.1.1.1 * @return a new <code>ContentType</code> object */ public static ContentType parse(final String format) { try { return ContentType.create(format); } catch (IllegalArgumentException e) { return null; } }
if (charset != null) { if ("*".equals(charset.toString())) { contentType = ContentType.create(contentType, ContentType.PARAMETER_CHARSET, "utf-8"); } else { contentType = ContentType.create(contentType, ContentType.PARAMETER_CHARSET, charset.toString()); contentType = ContentType.create(contentType, ContentType.PARAMETER_CHARSET, "utf-8"); } else { if (CHARSET_PATTERN.matcher(charSetValue).matches()) { contentType = ContentType.create(contentType, ContentType.PARAMETER_IEEE754_COMPATIBLE, "true"); } else if ("false".equalsIgnoreCase(ieee754compatibleValue)) { contentType = ContentType.create(contentType, ContentType.PARAMETER_IEEE754_COMPATIBLE, "false"); } else if (ieee754compatibleValue != null) { throw new IllegalArgumentException("Invalid IEEE754Compatible value in accept header:" +
if (charset != null) { if ("*".equals(charset.toString())) { contentType = ContentType.create(contentType, ContentType.PARAMETER_CHARSET, "utf-8"); } else { contentType = ContentType.create(contentType, ContentType.PARAMETER_CHARSET, charset.toString()); contentType = ContentType.create(contentType, ContentType.PARAMETER_CHARSET, "utf-8"); } else { if (CHARSET_PATTERN.matcher(charSetValue).matches()) { contentType = ContentType.create(contentType, ContentType.PARAMETER_IEEE754_COMPATIBLE, "true"); } else if ("false".equalsIgnoreCase(ieee754compatibleValue)) { contentType = ContentType.create(contentType, ContentType.PARAMETER_IEEE754_COMPATIBLE, "false"); } else if (ieee754compatibleValue != null) { throw new IllegalArgumentException("Invalid IEEE754Compatible value in accept header:" +
type = ContentType.create(contentType); } catch (final IllegalArgumentException e) { throw new BatchDeserializerException("Invalid content type.", e,
type = ContentType.create(contentType); } catch (final IllegalArgumentException e) { throw new BatchDeserializerException("Invalid content type.", e,
private ContentType getSupportedContentType(final String contentTypeHeader, final RepresentationType representationType, final boolean mustNotBeNull) throws ODataHandlerException, ContentNegotiatorException { if (contentTypeHeader == null) { if (mustNotBeNull) { throw new ODataHandlerException("ContentTypeHeader parameter is null", ODataHandlerException.MessageKeys.MISSING_CONTENT_TYPE); } return null; } ContentType contentType; try { contentType = ContentType.create(contentTypeHeader); } catch (final IllegalArgumentException e) { throw new ODataHandlerException("Illegal content type.", e, ODataHandlerException.MessageKeys.INVALID_CONTENT_TYPE, contentTypeHeader); } ContentNegotiator.checkSupport(contentType, handler.getCustomContentTypeSupport(), representationType); return contentType; }
private ContentType getSupportedContentType(final String contentTypeHeader, final RepresentationType representationType, final boolean mustNotBeNull) throws ODataHandlerException, ContentNegotiatorException { if (contentTypeHeader == null) { if (mustNotBeNull) { throw new ODataHandlerException("ContentTypeHeader parameter is null", ODataHandlerException.MessageKeys.MISSING_CONTENT_TYPE); } return null; } ContentType contentType; try { contentType = ContentType.create(contentTypeHeader); } catch (final IllegalArgumentException e) { throw new ODataHandlerException("Illegal content type.", e, ODataHandlerException.MessageKeys.INVALID_CONTENT_TYPE, contentTypeHeader); } ContentNegotiator.checkSupport(contentType, handler.getCustomContentTypeSupport(), representationType); return contentType; }
try { formatTypes = AcceptType.fromContentType(contentType == null ? ContentType.create(formatOption.getFormat()) : contentType); } catch (final IllegalArgumentException e) { throw new AcceptHeaderContentNegotiatorException(
try { formatTypes = AcceptType.fromContentType(contentType == null ? ContentType.create(formatOption.getFormat()) : contentType); } catch (final IllegalArgumentException e) { throw new AcceptHeaderContentNegotiatorException(