MCPcopy Create free account
hub / github.com/e2wugui/zeze / parse0

Method parse0

ZezeJava/ZezeJava/src/main/java/Zeze/Util/JsonReader.java:434–615  ·  view source on GitHub ↗
(@NotNull T obj, @NotNull ClassMeta<?> classMeta)

Source from the content-addressed store, hash-verified

432 }
433
434 public <T> @NotNull T parse0(@NotNull T obj, @NotNull ClassMeta<?> classMeta) throws ReflectiveOperationException {
435 if (next() != '{')
436 return obj;
437 for (int b = skipNext(); b != '}'; b = skipVar('}')) {
438 FieldMeta fm = classMeta.get(b == '"' || b == '\'' ? parseKeyHash(b) : parseKeyHashNoQuot(b));
439 if (fm == null)
440 continue;
441 b = skipColon();
442 long offset = fm.offset;
443 int type = fm.type;
444 switch (type) {
445 case TYPE_BOOLEAN:
446 unsafe.putBoolean(obj, offset, b == 't');
447 break;
448 case TYPE_BYTE:
449 unsafe.putByte(obj, offset, (byte)parseInt());
450 break;
451 case TYPE_SHORT:
452 unsafe.putShort(obj, offset, (short)parseInt());
453 break;
454 case TYPE_CHAR:
455 unsafe.putChar(obj, offset, (char)parseInt());
456 break;
457 case TYPE_INT:
458 unsafe.putInt(obj, offset, parseInt());
459 break;
460 case TYPE_LONG:
461 unsafe.putLong(obj, offset, parseLong());
462 break;
463 case TYPE_FLOAT:
464 unsafe.putFloat(obj, offset, (float)parseDouble());
465 break;
466 case TYPE_DOUBLE:
467 unsafe.putDouble(obj, offset, parseDouble());
468 break;
469 case TYPE_STRING:
470 unsafe.putObject(obj, offset, parseString(false));
471 break;
472 case TYPE_OBJECT:
473 unsafe.putObject(obj, offset, parse(unsafe.getObject(obj, offset), b));
474 break;
475 case TYPE_POS:
476 Pos p = (Pos)unsafe.getObject(obj, offset);
477 if (p == null)
478 unsafe.putObject(obj, offset, p = new Pos());
479 p.pos = pos;
480 break;
481 case TYPE_CUSTOM:
482 Object subObj = unsafe.getObject(obj, offset);
483 if (subObj != null) {
484 Class<?> subClass = subObj.getClass();
485 ClassMeta<?> subClassMeta;
486 if (subClass == fm.klass) {
487 subClassMeta = fm.classMeta;
488 if (subClassMeta == null)
489 fm.classMeta = subClassMeta = classMeta.json.getClassMeta(subClass);
490 } else
491 subClassMeta = classMeta.json.getClassMeta(subClass);

Callers 4

parseArrayMethod · 0.95
parseMethod · 0.95
parseList0Method · 0.95
parseMap0Method · 0.95

Calls 15

nextMethod · 0.95
skipNextMethod · 0.95
skipVarMethod · 0.95
parseKeyHashMethod · 0.95
parseKeyHashNoQuotMethod · 0.95
skipColonMethod · 0.95
parseIntMethod · 0.95
parseLongMethod · 0.95
parseDoubleMethod · 0.95
parseStringMethod · 0.95
parseMethod · 0.95
getNameMethod · 0.95

Tested by

no test coverage detected