public static List<Message> createCommandMessage(QueueSession session, HttpServletRequest request) throws IOException { EJValue value = JSONStreamDecoder.decode(request.getInputStream()); if (value.isObject() != null) { return Collections.singletonList(from(getParts(value), session, request)); } else if (value.isArray() != null) { EJArray arr = value.isArray(); List<Message> messages = new ArrayList<Message>(arr.size()); for (int i = 0; i < arr.size(); i++) { messages.add(from(getParts(arr.get(i)), session, request)); } return messages; } else if (value.isNull()) { return Collections.<Message>emptyList(); } else { throw new RuntimeException("bad payload"); } }
public static EJValue decode(final InputStream instream) throws IOException { return new JSONStreamDecoder(instream).parse(); }
private Object _parse(Context ctx) throws IOException { char c; StringBuilder appender; while ((c = read()) != 0) { switch (c) { case '[': ctx.addValue(_parse(new ArrayContext(new ArrayList<Object>()))); break; ctx.addValue(_parse(new ObjectContext(new LinkedHashMap<Object, Object>()))); break; appender = new StringBuilder(100); StrCapture: while ((c = read()) != 0) { switch (c) { case '\\': appender.append(handleEscapeSequence()); break; case '"': if (isNumberStart(c)) { carry = c; ctx.addValue(parseDouble()); break; while (((c = read()) != 0) && Character.isJavaIdentifierPart(c)) { appender.append(c);
private char handleEscapeSequence() throws IOException { char c; switch (c = read()) { case '\\': return '\\'; for (; i < 4 && isValidHexPart(c = read()); i++) { unicodeSeq[i] = c;
public EJValue parse() { try { return new ErraiJSONValue(_parse(new OuterContext())); } catch (Exception e) { throw new RuntimeException(e); } }
while ((c = read()) != 0) { switch (state) {
private Object _parse(Context ctx) throws IOException { char c; StringBuilder appender; while ((c = read()) != 0) { switch (c) { case '[': ctx.addValue(_parse(new ArrayContext(new ArrayList<Object>()))); break; ctx.addValue(_parse(new ObjectContext(new LinkedHashMap<Object, Object>()))); break; appender = new StringBuilder(100); StrCapture: while ((c = read()) != 0) { switch (c) { case '\\': appender.append(handleEscapeSequence()); break; case '"': if (isNumberStart(c)) { carry = c; ctx.addValue(parseDouble()); break; while (((c = read()) != 0) && Character.isJavaIdentifierPart(c)) { appender.append(c);
private char handleEscapeSequence() throws IOException { char c; switch (c = read()) { case '\\': return '\\'; for (; i < 4 && isValidHexPart(c = read()); i++) { unicodeSeq[i] = c;
public EJValue parse() { try { return new ErraiJSONValue(_parse(new OuterContext())); } catch (Exception e) { throw new RuntimeException(e); } }
while ((c = read()) != 0) { switch (state) {
public static List<Message> createCommandMessage(QueueSession session, InputStream inputStream) throws IOException { EJValue value = JSONStreamDecoder.decode(inputStream); if (value.isObject() != null) { return Collections.singletonList(from(getParts(value), session, null)); } else if (value.isArray() != null) { EJArray arr = value.isArray(); List<Message> messages = new ArrayList<Message>(arr.size()); for (int i = 0; i < arr.size(); i++) { messages.add(from(getParts(arr.get(i)), session, null)); } return messages; } else { throw new RuntimeException("bad payload"); } }
public static EJValue decode(final InputStream instream) throws IOException { return new JSONStreamDecoder(instream).parse(); }
@SuppressWarnings("unchecked") public static <T> T fromJSON(final InputStream inputStream, final Class<T> type) throws IOException { final MarshallingSession session = MarshallingSessionProviderFactory.getDecoding(); return (T) session.getMarshallerInstance(type.getName()).demarshall(JSONStreamDecoder.decode(inputStream), session); }
public static EJValue decode(final String o) { try { return new JSONStreamDecoder(new ByteArrayInputStream(o.getBytes("UTF-8"))).parse(); } catch (UnsupportedEncodingException e) { throw new AssertionError("UTF-8 not supported by this JRE?"); } } }
@SuppressWarnings("unchecked") public static <T> T fromJSON(final InputStream inputStream, final Class<T> type) throws IOException { final MarshallingSession session = MarshallingSessionProviderFactory.getDecoding(); return (T) session.getMarshallerInstance(type.getName()).demarshall(JSONStreamDecoder.decode(inputStream), session); }
public static EJValue decode(final String o) { try { return new JSONStreamDecoder(new ByteArrayInputStream(o.getBytes("UTF-8"))).parse(); } catch (UnsupportedEncodingException e) { throw new AssertionError("UTF-8 not supported by this JRE?"); } } }
public static List<Message> createCommandMessage(QueueSession session, HttpServletRequest request) throws IOException { EJValue value = JSONStreamDecoder.decode(request.getInputStream()); if (value.isObject() != null) { return Collections.singletonList(from(getParts(value), session, request)); } else if (value.isArray() != null) { EJArray arr = value.isArray(); List<Message> messages = new ArrayList<Message>(arr.size()); for (int i = 0; i < arr.size(); i++) { messages.add(from(getParts(arr.get(i)), session, request)); } return messages; } else if (value.isNull()) { return Collections.<Message>emptyList(); } else { throw new RuntimeException("bad payload"); } }
public static List<Message> createCommandMessage(QueueSession session, InputStream inputStream) throws IOException { EJValue value = JSONStreamDecoder.decode(inputStream); if (value.isObject() != null) { return Collections.singletonList(from(getParts(value), session, null)); } else if (value.isArray() != null) { EJArray arr = value.isArray(); List<Message> messages = new ArrayList<Message>(arr.size()); for (int i = 0; i < arr.size(); i++) { messages.add(from(getParts(arr.get(i)), session, null)); } return messages; } else { throw new RuntimeException("bad payload"); } }