/** * Searches the group for a parser that can handle the specified <l>Content-Type</l> header value. * * <p> * The returned object includes both the parser and media type that matched. * * @param contentTypeHeader The HTTP <l>Content-Type</l> header value. * @return The parser and media type that matched the content type header, or <jk>null</jk> if no match was made. */ public ParserMatch getParserMatch(String contentTypeHeader) { ParserMatch pm = cache.get(contentTypeHeader); if (pm != null) return pm; ContentType ct = ContentType.forString(contentTypeHeader); int match = ct.findMatch(mediaTypes); if (match >= 0) { pm = new ParserMatch(mediaTypes[match], mediaTypeParsers[match]); cache.putIfAbsent(contentTypeHeader, pm); } return cache.get(contentTypeHeader); }
/** * Returns the <code>Content-Type</code> header on the request. * * <p> * The MIME type of the body of the request (used with POST and PUT requests). * * <h5 class='figure'>Example:</h5> * <p class='bcode w800'> * Content-Type: application/x-www-form-urlencoded * </p> * * @return The parsed <code>Content-Type</code> header on the request, or <jk>null</jk> if not found. */ public ContentType getContentType() { return ContentType.forString(getString("Content-Type")); }
/** * Returns a parsed <code>Content-Type</code> header. * * @param value The <code>Content-Type</code> header string. * @return The parsed <code>Content-Type</code> header, or <jk>null</jk> if the string was null. */ public static ContentType forString(String value) { if (value == null) return null; ContentType ct = cache.get(value); if (ct == null) ct = cache.put(value, new ContentType(value)); return ct; }
@RestMethod public String contentType(ContentType contentType) { return contentType.toString(); } @RestMethod
/** * Returns the <code>Content-Type</code> header on the request. * * <p> * The MIME type of the body of the request (used with POST and PUT requests). * * <h5 class='figure'>Example:</h5> * <p class='bcode w800'> * Content-Type: application/x-www-form-urlencoded * </p> * * @return The parsed <code>Content-Type</code> header on the request, or <jk>null</jk> if not found. */ public ContentType getContentType() { return ContentType.forString(getString("Content-Type")); }
/** * Returns a parsed <code>Content-Type</code> header. * * @param value The <code>Content-Type</code> header string. * @return The parsed <code>Content-Type</code> header, or <jk>null</jk> if the string was null. */ public static ContentType forString(String value) { if (value == null) return null; ContentType ct = cache.get(value); if (ct == null) ct = cache.put(value, new ContentType(value)); return ct; }
/** * Searches the group for a parser that can handle the specified <l>Content-Type</l> header value. * * <p> * The returned object includes both the parser and media type that matched. * * @param contentTypeHeader The HTTP <l>Content-Type</l> header value. * @return The parser and media type that matched the content type header, or <jk>null</jk> if no match was made. */ public ParserMatch getParserMatch(String contentTypeHeader) { ParserMatch pm = cache.get(contentTypeHeader); if (pm != null) return pm; ContentType ct = ContentType.forString(contentTypeHeader); int match = ct.findMatch(mediaTypes); if (match >= 0) { pm = new ParserMatch(mediaTypes[match], mediaTypeParsers[match]); cache.putIfAbsent(contentTypeHeader, pm); } return cache.get(contentTypeHeader); }
/** * Returns the <code>Content-Type</code> header on the request. * * <p> * The MIME type of the body of the request (used with POST and PUT requests). * * <h5 class='figure'>Example:</h5> * <p class='bcode w800'> * Content-Type: application/x-www-form-urlencoded * </p> * * @return The parsed <code>Content-Type</code> header on the request, or <jk>null</jk> if not found. */ public ContentType getContentType() { return ContentType.forString(getString("Content-Type")); }
/** * Returns a parsed <code>Content-Type</code> header. * * @param value The <code>Content-Type</code> header string. * @return The parsed <code>Content-Type</code> header, or <jk>null</jk> if the string was null. */ public static ContentType forString(String value) { if (value == null) return null; ContentType ct = cache.get(value); if (ct == null) ct = cache.put(value, new ContentType(value)); return ct; }
/** * Searches the group for a parser that can handle the specified <l>Content-Type</l> header value. * * <p> * The returned object includes both the parser and media type that matched. * * @param contentTypeHeader The HTTP <l>Content-Type</l> header value. * @return The parser and media type that matched the content type header, or <jk>null</jk> if no match was made. */ public ParserMatch getParserMatch(String contentTypeHeader) { ParserMatch pm = cache.get(contentTypeHeader); if (pm != null) return pm; ContentType ct = ContentType.forString(contentTypeHeader); int match = ct.findMatch(mediaTypes); if (match >= 0) { pm = new ParserMatch(mediaTypes[match], mediaTypeParsers[match]); cache.putIfAbsent(contentTypeHeader, pm); } return cache.get(contentTypeHeader); }