private ServiceBox<String> createStringBox(ServiceBox.Type type) { List<String> list = new ArrayList<String>(); while (jsonReader.next()) { int len = jsonReader.stringLength(); list.add(charBuffer.subSequence(0, len).toString()); charBuffer.position(charBuffer.position() + len); } return new ServiceBox<String>(type, list); }
private StatDto decodeStatistics(int ind) { JsonHelper.Decimal decimal = jsonReader.readDecimal(FIELD.id.name()); int id = decimal == null ? ind : (int) decimal.getUnscaled(); int len = jsonReader.stringLength(FIELD.name.name()); String name = charBuffer.subSequence(0, len).toString(); Boolean b = jsonReader.readBoolean(FIELD.hist.name()); boolean histogram = b != null && b; return new StatDto(id, name, histogram); }
public ServiceBox decodeBox(String s) { ServiceBox box = null; charBuffer.clear(); charBuffer.put(s); charBuffer.flip(); // String typeString = s.replaceAll("\\\":.*$", "").replaceAll("^.*\\\"", ""); int typeLength = jsonReader.stringLength(FIELD.type.name()); if (typeLength < 1) { log.err("Data type undefined " + s); return null; } String typeString = charBuffer.subSequence(0, typeLength).toString(); TYPE type = TYPE.valueOf(typeString); int statusCode = 0; if (type == TYPE.status) { statusCode = (int) jsonReader.readDecimal(FIELD.data.name()).getUnscaled(); } else { jsonReader.findField(FIELD.data.name()); } ServiceBox.Type boxType; switch (type) { case pList: case mList: case rList: box = createStatBox(ServiceBox.Type.REG); break; case descData: box = createStringBox(ServiceBox.Type.DESC); break; case status: box = createStringBox(statusCode); break; case statData: box = createSnapshotBox(ServiceBox.Type.STAT); break; case cfgData: box = createStringBox(ServiceBox.Type.CFG); break; } return box; }