/** * Process an object. * @param object The object. * @param targetcl If not null, the traverser should make sure that the result object is compatible with the class loader, * e.g. by cloning the object using the class loaded from the target class loader. * @return The processed object. */ public Object process(Object object, Type type, List<ITraverseProcessor> processors, Traverser traverser, Map<Object, Object> traversed, boolean clone, ClassLoader targetcl, Object context) { JsonObject obj = (JsonObject)object; int x = obj.getInt("x", 0); int y = obj.getInt("y", 0); int w = obj.getInt("w", 0); int h = obj.getInt("h", 0); Rectangle ret = new Rectangle(x, y, w, h); // traversed.put(object, ret); // ((JsonReadContext)context).addKnownObject(ret); JsonValue idx = (JsonValue)obj.get(JsonTraverser.ID_MARKER); if(idx!=null) ((JsonReadContext)context).addKnownObject(ret, idx.asInt()); return ret; } }
/** * Process an object. * @param object The object. * @param targetcl If not null, the traverser should make sure that the result object is compatible with the class loader, * e.g. by cloning the object using the class loaded from the target class loader. * @return The processed object. */ public Object process(Object object, Type type, List<ITraverseProcessor> processors, Traverser traverser, Map<Object, Object> traversed, boolean clone, ClassLoader targetcl, Object context) { JsonObject obj = (JsonObject)object; int num = obj.getInt(JsonTraverser.REFERENCE_MARKER, 0); return ((JsonReadContext)context).getKnownObject(num); // return traversed.get(Integer.valueOf(num)); } }
int brokerPort = jsonObject.getInt(PropsKeys.PORT, -1);
int brokerPort = jsonObject.getInt(PropsKeys.PORT, -1);
/** * Process an object. * @param object The object. * @param targetcl If not null, the traverser should make sure that the result object is compatible with the class loader, * e.g. by cloning the object using the class loaded from the target class loader. * @return The processed object. */ public Object process(Object object, Type type, List<ITraverseProcessor> processors, Traverser traverser, Map<Object, Object> traversed, boolean clone, ClassLoader targetcl, Object context) { JsonObject obj = (JsonObject)object; int rgb = obj.getInt("value", 0); Color ret = new Color(rgb); // traversed.put(object, ret); // ((JsonReadContext)context).addKnownObject(ret); JsonValue idx = (JsonValue)obj.get(JsonTraverser.ID_MARKER); if(idx!=null) ((JsonReadContext)context).addKnownObject(ret, idx.asInt()); return ret; } }
/** * Process an object. * @param object The object. * @param targetcl If not null, the traverser should make sure that the result object is compatible with the class loader, * e.g. by cloning the object using the class loaded from the target class loader. * @return The processed object. */ public Object process(Object object, Type type, List<ITraverseProcessor> processors, Traverser traverser, Map<Object, Object> traversed, boolean clone, ClassLoader targetcl, Object context) { JsonObject obj = (JsonObject)object; long time = obj.getLong("time", 0); int nanos = obj.getInt("nanos", 0); Timestamp ret = new Timestamp(time); ret.setNanos(nanos); // traversed.put(object, ret); // ((JsonReadContext)context).addKnownObject(ret); JsonValue idx = (JsonValue)obj.get(JsonTraverser.ID_MARKER); if(idx!=null) ((JsonReadContext)context).addKnownObject(ret, idx.asInt()); return ret; } }
public synchronized ShieldCoinbaseResponse shieldCoinbase(String from, String to) throws WalletCallException, IOException, InterruptedException { JsonObject objResponse = this.executeCommandAndGetJsonObject( "z_shieldcoinbase", wrapStringParameter(from), wrapStringParameter(to)); ShieldCoinbaseResponse shieldCoinbaseResponse = new ShieldCoinbaseResponse(); shieldCoinbaseResponse.operationid = objResponse.getString("operationid", null); shieldCoinbaseResponse.shieldedUTXOs = objResponse.getInt("shieldedUTXOs", -1); if (shieldCoinbaseResponse.shieldedUTXOs == -1) { shieldCoinbaseResponse.shieldedUTXOs = objResponse.getInt("shieldingUTXOs", -1); } shieldCoinbaseResponse.shieldedValue = objResponse.getDouble("shieldedValue", -1); if (shieldCoinbaseResponse.shieldedValue == -1) { shieldCoinbaseResponse.shieldedValue = objResponse.getDouble("shieldingValue", -1); } shieldCoinbaseResponse.remainingUTXOs = objResponse.getInt("remainingUTXOs", -1); shieldCoinbaseResponse.remainingValue = objResponse.getDouble("remainingValue", -1); if (shieldCoinbaseResponse.shieldedValue != -1) { return shieldCoinbaseResponse; } else { throw new WalletCallException("Unexpected z_shieldcoinbase response from wallet: " + objResponse.toString()); } }
/** * Gets Stats from input stream and closes the stream at the end. * @param is where data is present. It is closed at the end. * @return Stats object. * @throws IOException */ public static final Stats fromInputStream(final InputStream is) throws IOException { final Stats currentStats = new Stats(); try (final BufferedReader reader = new BufferedReader(new InputStreamReader(is))) { final JsonValue parse = Json.parse(reader); final JsonArray arrayOfStats = parse.asArray(); for (JsonValue value : arrayOfStats) { final JsonObject stat = value.asObject(); final JsonObject endpoint = stat.get("endpoint").asObject(); final String method = endpoint.getString("method", ""); final String path = endpoint.getString("path", ""); final int errors = stat.getInt("errors", 0); final int success = stat.getInt("success", 0); final double averagePrimaryDuration = stat.getDouble("averagePrimaryDuration", 0.0); final double averageCandidateDuration = stat.getDouble("averageCandidateDuration", 0.0); final List<ErrorDetail> errorDetailList = parseErrorDetails(stat); currentStats.stats.add( new Stat(method, path, errors, success, averagePrimaryDuration, averageCandidateDuration, errorDetailList) ); } } return currentStats; }
public static LwM2mNode deserialize(JsonObject o) { String kind = o.getString("kind", null); int id = o.getInt("id", LwM2mObjectInstance.UNDEFINED);
/** * Process an object. * @param object The object. * @param targetcl If not null, the traverser should make sure that the result object is compatible with the class loader, * e.g. by cloning the object using the class loaded from the target class loader. * @return The processed object. */ public Object process(Object object, Type type, List<ITraverseProcessor> processors, Traverser traverser, Map<Object, Object> traversed, boolean clone, ClassLoader targetcl, Object context) { Class<?> clazz = SReflect.getClass(type); JsonObject obj = (JsonObject)object; String classname = obj.getString("classname", null); String methodname = obj.getString("methodname", null); String filename = obj.getString("filename", null); int linenumber = obj.getInt("linenumber", 0); StackTraceElement ret = new StackTraceElement(classname, methodname, filename, linenumber); // traversed.put(object, ret); // ((JsonReadContext)context).addKnownObject(ret); JsonValue idx = (JsonValue)obj.get(JsonTraverser.ID_MARKER); if(idx!=null) ((JsonReadContext)context).addKnownObject(ret, idx.asInt()); return ret; } }
@Override public ObjectModel deserialize(JsonObject o) { if (o == null) return null; if (!o.isObject()) return null; int id = o.getInt("id", -1); if (id < 0) return null; String name = o.getString("name", null); String instancetype = o.getString("instancetype", null); boolean mandatory = o.getBoolean("mandatory", false); String description = o.getString("description", null); String version = o.getString("version", ObjectModel.DEFAULT_VERSION); List<ResourceModel> resourceSpecs = resourceModelSerDes.deserialize(o.get("resourcedefs").asArray()); return new ObjectModel(id, name, description, version, "multiple".equals(instancetype), mandatory, resourceSpecs); } }
@Override public ResourceModel deserialize(JsonObject o) { if (o == null) return null; if (!o.isObject()) return null; int id = o.getInt("id", -1); if (id < 0) return null; String name = o.getString("name", null); Operations operations = Operations.valueOf(o.getString("operations", null)); String instancetype = o.getString("instancetype", null); boolean mandatory = o.getBoolean("mandatory", false); Type type = Type.valueOf(o.getString("type", "").toUpperCase()); String range = o.getString("range", null); String units = o.getString("units", null); String description = o.getString("description", null); return new ResourceModel(id, name, operations, "multiple".equals(instancetype), mandatory, type, range, units, description); } }
this.diferenciaConfiguration.candidate = configuration.getString("candidate", ""); this.diferenciaConfiguration.secondary = configuration.getString("secondary", null); this.diferenciaConfiguration.port = configuration.getInt("port", 0); this.diferenciaConfiguration.prometheusPort = configuration.getInt("prometheusPort", 0); this.diferenciaConfiguration.adminPort = configuration.getInt("adminPort", 0); this.diferenciaConfiguration.serviceName = configuration.getString("serviceName", ""); this.diferenciaConfiguration.storeResults = configuration.getString("storeResults", null);
public static Registration deserialize(JsonObject jObj) { Registration.Builder b = new Registration.Builder(jObj.getString("regId", null), jObj.getString("ep", null), IdentitySerDes.deserialize(jObj.get("identity").asObject()), new InetSocketAddress(jObj.getString("regAddr", null), jObj.getInt("regPort", 0))); b.bindingMode(BindingMode.valueOf(jObj.getString("bnd", null))); b.lastUpdate(new Date(jObj.getLong("lastUp", 0)));
public static Registration deserialize(JsonObject jObj) { Registration.Builder b = new Registration.Builder(jObj.getString("regId", null), jObj.getString("ep", null), IdentitySerDes.deserialize(jObj.get("identity").asObject()), new InetSocketAddress(jObj.getString("regAddr", null), jObj.getInt("regPort", 0))); b.bindingMode(BindingMode.valueOf(jObj.getString("bnd", null))); b.lastUpdate(new Date(jObj.getLong("lastUp", 0)));
public void copyFromJSONObject(JsonObject obj) { // Wire protocol fields this.version = obj.getInt("ver", 1); this.from = obj.getString("from", ""); this.message = obj.getString("message", ""); this.sign = obj.getString("sign", ""); this.threadID = obj.getString("threadid", ""); this.returnAddress = obj.getString("returnaddress", ""); // Additional fields - may be missing, get default values this.transactionID = obj.getString("transactionID", ""); this.time = new Date(obj.getLong("time", 0)); this.direction = DIRECTION_TYPE.valueOf( obj.getString("direction", DIRECTION_TYPE.RECEIVED.toString())); this.verification = VERIFICATION_TYPE.valueOf( obj.getString("verification", VERIFICATION_TYPE.UNVERIFIED.toString())); if (obj.get("isanonymous") != null) { this.isAnonymous = obj.getBoolean("isanonymous", false); } else { // Determine from content if it is anonymous this.isAnonymous = obj.get("threadid") != null; } }
public void copyFromJSONObject(JsonObject obj) { // Wire protocol fields this.version = obj.getInt("ver", 1); this.from = obj.getString("from", ""); this.message = obj.getString("message", ""); this.sign = obj.getString("sign", ""); this.threadID = obj.getString("threadid", ""); this.returnAddress = obj.getString("returnaddress", ""); // Additional fields - may be missing, get default values this.transactionID = obj.getString("transactionID", ""); this.time = new Date(obj.getLong("time", 0)); this.direction = DIRECTION_TYPE.valueOf( obj.getString("direction", DIRECTION_TYPE.RECEIVED.toString())); this.verification = VERIFICATION_TYPE.valueOf( obj.getString("verification", VERIFICATION_TYPE.UNVERIFIED.toString())); if (obj.get("isanonymous") != null) { this.isAnonymous = obj.getBoolean("isanonymous", false); } else { // Determine from content if it is anonymous this.isAnonymous = obj.get("threadid") != null; } }
public static ObservationFull fromJson(JsonObject meta) { ObservationRequest req = new ObservationRequest(); req.setId(meta.getString("id", null)); req.setStartTimeMillis(meta.getLong("start", -1L)); req.setEndTimeMillis(meta.getLong("end", -1L)); req.setOutputSampleRate(meta.getInt("sampleRate", -1)); req.setInputSampleRate(meta.getInt("inputSampleRate", -1)); req.setSatelliteFrequency(meta.getLong("frequency", -1)); req.setActualFrequency(meta.getLong("actualFrequency", -1)); req.setBandwidth(meta.getLong("bandwidth", -1)); req.setDecoder(meta.getString("decoder", null)); req.setSatelliteId(meta.getString("satellite", null)); ObservationResult result = new ObservationResult(); result.setGain(meta.getString("gain", null)); result.setChannelA(meta.getString("channelA", null)); result.setChannelB(meta.getString("channelB", null)); JsonValue decodedPackets = meta.get("numberOfDecodedPackets"); if (decodedPackets != null) { result.setNumberOfDecodedPackets(decodedPackets.asLong()); } result.setaURL(meta.getString("aURL", null)); result.setDataURL(meta.getString("data", null)); result.setSpectogramURL(meta.getString("spectogramURL", null)); ObservationFull full = new ObservationFull(req); full.setResult(result); return full; }