@SuppressWarnings("unchecked") public static Map<String, Object> parseMap(String json) { return parse(json, Map.class); }
private void parseURLEncodedKV(Buf buf, KeyValueRanges params, BufRange body) { int pos = buf.position(); int limit = buf.limit(); buf.position(body.start); buf.limit(body.limit()); while (buf.hasRemaining()) { int ind = params.add(); int which = buf.scanTo(EQ, AMP, params.keys[ind], false); if (which == 1) { buf.scanTo(AMP, params.values[ind], false); } } buf.position(pos); buf.limit(limit); }
@SuppressWarnings("unchecked") public boolean parsePosted(Buf input, KeyValueRanges headersKV, BufRange rBody, KeyValueRanges posted, Map<String, List<Upload>> files, RapidoidHelper helper, Map<String, Object> dest) { BufRanges dataContentTypes = helper.ranges3.reset(); boolean completed = parseBody(input, headersKV, rBody, posted, dataContentTypes, files, helper); posted.toUrlDecodedParams(input, dest, dataContentTypes); return completed; }
public BufRange first() { return get(0); }
static DataFormat[] detectDataFormat(byte[] data) { if (data.length == 0) { return YAML_FIRST; } byte start = findFirstNonWhitespaceByte(data); if (start == '<') { return XML_FIRST; } else if (start == ' ' || (start == '-' && dataStartsWithYAMLMark(data))) { return YAML_FIRST; } else { return JSON_FIRST; } }
private void consumeAndSkip(int toPos, BufRange range, int skip) { range.setInterval(_position, toPos); _position = toPos + skip; }
@SuppressWarnings("unchecked") public static <T> T data(byte[] data, Class<T> targetType) { if (data == null) { return null; } // don't parse if the target type is byte[] if (targetType == byte[].class) { return (T) data; } DataFormat[] formatsOrder = detectDataFormat(data); return tryToParseData(data, formatsOrder, targetType); }
@Override public String toString() { return isEmpty() ? "[]" : "[" + start + ":" + length + "]"; }
@SuppressWarnings("unchecked") public static Map<String, Object> parseMap(String yaml) { return parse(yaml, Map.class); }
public void assign(BufRange range) { set(range.start, range.length); }
public static SimpleModule tuuidModule() { SimpleModule tuuidModule = new SimpleModule("TUUIDModule", new Version(1, 0, 0, null, "org.rapidoid", "rapidoid-commons")); tuuidModule.addSerializer(TUUID.class, new TUUIDSerializer()); tuuidModule.addDeserializer(TUUID.class, new TUUIDDeserializer()); return tuuidModule; }
public static byte[] parseBytes(String json) { return parse(json, byte[].class); }
public BufRanges reset() { for (int i = 0; i < count; i++) { ranges[i].reset(); } count = 0; return this; }
public BufRange last() { return get(count - 1); }