/** * Same as {@link #parse(Object, Type, Type...)} except the type has already been converted into a {@link ClassMeta} * object. * * <p> * This is mostly an internal method used by the framework. * * @param <T> The class type of the object being created. * @param input * The input. * See {@link #parse(Object, Type, Type...)} for details. * @param type The object type to create. * @return The parsed object. * @throws ParseException * If the input contains a syntax error or is malformed, or is not valid for the specified type. */ public final <T> T parse(Object input, ClassMeta<T> type) throws ParseException { return createSession().parse(input, type); }
private static String getMessage(ParserSession session, String msg, Object... args) { if (args.length != 0) msg = format(msg, args); if (session != null) { Position p = session.getPosition(); msg += "\n\tAt: " + p; ObjectMap lastLocation = session.getLastLocation(); if (lastLocation != null) { msg += "\n\tWhile parsing into: "; for (Map.Entry<String,Object> e : lastLocation.entrySet()) msg += "\n\t\t" + e.getKey() + ": " + e.getValue(); } String lines = session.getInputAsString(); if (lines == null) msg += "\n\tUse BEAN_debug setting to display content."; else { int numLines = session.getDebugOutputLines(); int start = p.line - numLines, end = p.line + numLines; msg += "\n---start--\n" + StringUtils.getNumberedLines(lines, start, end) + "---end---"; } } return msg; }
try (ParserPipe pipe = createPipe(input)) { return doParse(pipe, getArgsClassMeta(argTypes)); } catch (ParseException e) { throw e; e.getClass().getSimpleName(), e.getLocalizedMessage()); } finally { checkForWarnings();
/** * Same as {@link #parse(Object, Type, Type...)} except the type has already been converted into a {@link ClassMeta} * object. * * <p> * This is mostly an internal method used by the framework. * * @param <T> The class type of the object being created. * @param input * The input. * See {@link #parse(Object, Type, Type...)} for details. * @param type The object type to create. * @return The parsed object. * @throws ParseException * If the input contains a syntax error or is malformed, or is not valid for the specified type. */ public final <T> T parse(Object input, ClassMeta<T> type) throws ParseException { try (ParserPipe pipe = createPipe(input)) { return parseInner(pipe, type); } }
try (ParserPipe pipe = createPipe(input)) { return parseInner(pipe, getClassMeta(type));
try (ParserPipe pipe = createPipe(input)) { return doParseIntoMap(pipe, m, keyType, valueType); } catch (ParseException e) { throw e; throw new ParseException(this, e); } finally { checkForWarnings();
@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); } }
String btpn = getBeanTypePropertyName(eType); String typeName = o.toString(); ClassMeta<?> cm = getClassMeta(typeName, pMeta, eType); v = cast((ObjectMap)v, pMeta, eType); bm.put(k, v);
try (ParserPipe pipe = createPipe(input)) { return doParseIntoCollection(pipe, c, elementType); } catch (ParseException e) { throw e; e.getClass().getSimpleName(), e.getLocalizedMessage()); } finally { checkForWarnings();
@Override /* ParserListener */ public <T> void onUnknownBeanProperty(ParserSession session, String propertyName, Class<T> beanClass, T bean) { events.add(propertyName + ", " + session.getPosition()); } }
return null; try { return doParse(pipe, type); } catch (ParseException e) { throw e; e.getClass().getSimpleName(), e.getLocalizedMessage()); } finally { checkForWarnings();
@Override /* Session */ public ObjectMap asMap() { return super.asMap() .append("ReaderParserSession", new ObjectMap() ); } }
@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); } }
try (ParserPipe pipe = createPipe(input)) { return parseInner(pipe, getClassMeta(type));
try (ParserPipe pipe = createPipe(input)) { return doParseIntoMap(pipe, m, keyType, valueType); } catch (ParseException e) { throw e; throw new ParseException(this, e); } finally { checkForWarnings();
String btpn = getBeanTypePropertyName(eType); String typeName = o.toString(); ClassMeta<?> cm = getClassMeta(typeName, pMeta, eType); v = cast((ObjectMap)v, pMeta, eType); bm.put(k, v);
try (ParserPipe pipe = createPipe(input)) { return doParseIntoCollection(pipe, c, elementType); } catch (ParseException e) { throw e; e.getClass().getSimpleName(), e.getLocalizedMessage()); } finally { checkForWarnings();
@Override /* ParserListener */ public <T> void onUnknownBeanProperty(ParserSession session, String propertyName, Class<T> beanClass, T bean) { events.add(propertyName + ", " + session.getPosition()); } }
/** * Same as {@link #parse(Object, Type, Type...)} except the type has already been converted into a {@link ClassMeta} * object. * * <p> * This is mostly an internal method used by the framework. * * @param <T> The class type of the object being created. * @param input * The input. * See {@link #parse(Object, Type, Type...)} for details. * @param type The object type to create. * @return The parsed object. * @throws ParseException * If the input contains a syntax error or is malformed, or is not valid for the specified type. */ public final <T> T parse(Object input, ClassMeta<T> type) throws ParseException { try (ParserPipe pipe = createPipe(input)) { return parseInner(pipe, type); } }
return null; try { return doParse(pipe, type); } catch (ParseException e) { throw e; e.getClass().getSimpleName(), e.getLocalizedMessage()); } finally { checkForWarnings();