/** * Returns the parser matching the request <code>Content-Type</code> header. * * @return * The parser matching the request <code>Content-Type</code> header, or <jk>null</jk> if no matching parser was * found. */ public Parser getParser() { ParserMatch pm = getParserMatch(); return (pm == null ? null : pm.getParser()); }
@Override /* MessageBodyReader */ public Object readFrom(Class<Object> type, Type gType, Annotation[] a, MediaType mediaType, MultivaluedMap<String,String> headers, InputStream in) throws IOException, WebApplicationException { try { ParserMatch pm = parsers.getParserMatch(mediaType.toString()); if (pm == null) throw new WebApplicationException(SC_UNSUPPORTED_MEDIA_TYPE); Parser p = pm.getParser(); ObjectMap mp = getMethodProperties(a); mp.put("mediaType", mediaType.toString()); Locale locale = getLocale(headers); TimeZone timeZone = getTimeZone(headers); ParserSession session = p.createSession(new ParserSessionArgs(mp, null, locale, timeZone, pm.getMediaType(), null, null, null)); Object in2 = session.isReaderParser() ? new InputStreamReader(in, UTF8) : in; return session.parse(in2, p.getClassMeta(gType)); } catch (ParseException e) { throw new IOException(e); } }
/** * 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); }
@Override /* MessageBodyReader */ public Object readFrom(Class<Object> type, Type gType, Annotation[] a, MediaType mediaType, MultivaluedMap<String,String> headers, InputStream in) throws IOException, WebApplicationException { try { ParserMatch pm = parsers.getParserMatch(mediaType.toString()); if (pm == null) throw new WebApplicationException(SC_UNSUPPORTED_MEDIA_TYPE); Parser p = pm.getParser(); ObjectMap mp = getMethodProperties(a); mp.put("mediaType", mediaType.toString()); Locale locale = getLocale(headers); TimeZone timeZone = getTimeZone(headers); ParserSession session = p.createSession(new ParserSessionArgs(mp, null, locale, timeZone, pm.getMediaType(), null, null, null)); Object in2 = session.isReaderParser() ? new InputStreamReader(in, UTF8) : in; return session.parse(in2, p.getClassMeta(gType)); } catch (ParseException e) { throw new IOException(e); } }
/** * 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); }
Parser p = pm.getParser(); MediaType mediaType = pm.getMediaType(); req.getProperties().append("mediaType", mediaType).append("characterEncoding", req.getCharacterEncoding()); ParserSessionArgs pArgs = new ParserSessionArgs(req.getProperties(), req.getJavaMethod(), locale, timeZone, mediaType, schema, req.isDebug() ? true : null, req.getContext().getResource());
/** * Same as {@link #getParserMatch(String)} but returns just the matched parser. * * @param contentTypeHeader The HTTP <l>Content-Type</l> header string. * @return The parser that matched the content type header, or <jk>null</jk> if no match was made. */ public Parser getParser(String contentTypeHeader) { ParserMatch pm = getParserMatch(contentTypeHeader); return pm == null ? null : pm.getParser(); }
/** * 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); }
Parser p = pm.getParser(); MediaType mediaType = pm.getMediaType(); req.getProperties().append("mediaType", mediaType).append("characterEncoding", req.getCharacterEncoding()); ParserSessionArgs pArgs = new ParserSessionArgs(req.getProperties(), req.getJavaMethod(), locale, timeZone, mediaType, schema, req.isDebug() ? true : null, req.getContext().getResource());
/** * Same as {@link #getParserMatch(String)} but returns just the matched parser. * * @param contentTypeHeader The HTTP <l>Content-Type</l> header string. * @return The parser that matched the content type header, or <jk>null</jk> if no match was made. */ public Parser getParser(String contentTypeHeader) { ParserMatch pm = getParserMatch(contentTypeHeader); return pm == null ? null : pm.getParser(); }
/** * Returns the parser and media type matching the request <code>Content-Type</code> header. * * @return * The parser matching the request <code>Content-Type</code> header, or <jk>null</jk> if no matching parser was * found. * Includes the matching media type. */ public ParserMatch getParserMatch() { if (mediaType != null && parser != null) return new ParserMatch(mediaType, parser); MediaType mt = getMediaType(); return mt == null ? null : parsers.getParserMatch(mt); }
Parser p = pm.getParser(); MediaType mediaType = pm.getMediaType(); req.getProperties().append("mediaType", mediaType).append("characterEncoding", req.getCharacterEncoding()); ParserSessionArgs pArgs = new ParserSessionArgs(req.getProperties(), req.getJavaMethod(), locale, timeZone, mediaType, schema, req.isDebug() ? true : null, req.getContext().getResource());
/** * Same as {@link #getParserMatch(String)} but returns just the matched parser. * * @param contentTypeHeader The HTTP <l>Content-Type</l> header string. * @return The parser that matched the content type header, or <jk>null</jk> if no match was made. */ public Parser getParser(String contentTypeHeader) { ParserMatch pm = getParserMatch(contentTypeHeader); return pm == null ? null : pm.getParser(); }
/** * Returns the parser and media type matching the request <code>Content-Type</code> header. * * @return * The parser matching the request <code>Content-Type</code> header, or <jk>null</jk> if no matching parser was * found. * Includes the matching media type. */ public ParserMatch getParserMatch() { if (mediaType != null && parser != null) return new ParserMatch(mediaType, parser); MediaType mt = getMediaType(); return mt == null ? null : parsers.getParserMatch(mt); }
/** * Returns the parser matching the request <code>Content-Type</code> header. * * @return * The parser matching the request <code>Content-Type</code> header, or <jk>null</jk> if no matching parser was * found. */ public Parser getParser() { ParserMatch pm = getParserMatch(); return (pm == null ? null : pm.getParser()); }
/** * Returns the parser and media type matching the request <code>Content-Type</code> header. * * @return * The parser matching the request <code>Content-Type</code> header, or <jk>null</jk> if no matching parser was * found. * Includes the matching media type. */ public ParserMatch getParserMatch() { if (mediaType != null && parser != null) return new ParserMatch(mediaType, parser); MediaType mt = getMediaType(); return mt == null ? null : parsers.getParserMatch(mt); }
/** * Same as {@link #getParserMatch(MediaType)} but returns just the matched parser. * * @param mediaType The HTTP media type. * @return The parser that matched the media type, or <jk>null</jk> if no match was made. */ public Parser getParser(MediaType mediaType) { ParserMatch pm = getParserMatch(mediaType); return pm == null ? null : pm.getParser(); }
/** * Same as {@link #getParserMatch(MediaType)} but returns just the matched parser. * * @param mediaType The HTTP media type. * @return The parser that matched the media type, or <jk>null</jk> if no match was made. */ public Parser getParser(MediaType mediaType) { ParserMatch pm = getParserMatch(mediaType); return pm == null ? null : pm.getParser(); }
/** * Same as {@link #getParserMatch(MediaType)} but returns just the matched parser. * * @param mediaType The HTTP media type. * @return The parser that matched the media type, or <jk>null</jk> if no match was made. */ public Parser getParser(MediaType mediaType) { ParserMatch pm = getParserMatch(mediaType); return pm == null ? null : pm.getParser(); }
/** * Returns the parser matching the request <code>Content-Type</code> header. * * @return * The parser matching the request <code>Content-Type</code> header, or <jk>null</jk> if no matching parser was * found. */ public Parser getParser() { ParserMatch pm = getParserMatch(); return (pm == null ? null : pm.getParser()); }