public synchronized String getWalletTransactionTime(String txID) throws WalletCallException, IOException, InterruptedException { JsonObject jsonTransaction = this.executeCommandAndGetJsonObject( "gettransaction", wrapStringParameter(txID)); return String.valueOf(jsonTransaction.getLong("time", -1)); }
public synchronized String getWalletTransactionTime(String txID) throws WalletCallException, IOException, InterruptedException { JsonObject jsonTransaction = this.executeCommandAndGetJsonObject( "gettransaction", wrapStringParameter(txID)); return String.valueOf(jsonTransaction.getLong("time", -1)); }
public synchronized NetworkAndBlockchainInfo getNetworkAndBlockchainInfo() throws WalletCallException, IOException, InterruptedException { NetworkAndBlockchainInfo info = new NetworkAndBlockchainInfo(); String strNumCons = this.executeCommandAndGetSingleStringResponse("getconnectioncount"); info.numConnections = Integer.valueOf(strNumCons.trim()); String strBlockCount = this.executeCommandAndGetSingleStringResponse("getblockcount"); String lastBlockHash = this.executeCommandAndGetSingleStringResponse("getblockhash", strBlockCount.trim()); JsonObject lastBlock = this.executeCommandAndGetJsonObject("getblock", wrapStringParameter(lastBlockHash.trim())); info.lastBlockDate = new Date(Long.valueOf(lastBlock.getLong("time", -1) * 1000L)); return info; }
public synchronized NetworkAndBlockchainInfo getNetworkAndBlockchainInfo() throws WalletCallException, IOException, InterruptedException { NetworkAndBlockchainInfo info = new NetworkAndBlockchainInfo(); String strNumCons = this.executeCommandAndGetSingleStringResponse("getconnectioncount"); info.numConnections = Integer.valueOf(strNumCons.trim()); String strBlockCount = this.executeCommandAndGetSingleStringResponse("getblockcount"); info.lastBlockHeight = strBlockCount; String lastBlockHash = this.executeCommandAndGetSingleStringResponse("getblockhash", strBlockCount.trim()); JsonObject lastBlock = this.executeCommandAndGetJsonObject("getblock", wrapStringParameter(lastBlockHash.trim())); info.lastBlockDate = new Date(Long.valueOf(lastBlock.getLong("time", -1) * 1000L)); return info; }
private static Long readObservationId(HttpURLConnection con) throws IOException { JsonValue result = Json.parse(new InputStreamReader(con.getInputStream())); if (!result.isObject()) { LOG.info("malformed json"); return null; } JsonObject resultObj = result.asObject(); String status = resultObj.getString("status", null); if (status == null || !status.equalsIgnoreCase("SUCCESS")) { LOG.info("response error: " + resultObj); return null; } long id = resultObj.getLong("id", -1); if (id == -1) { return null; } return id; }
/** * 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("value", 0); Date ret = new Date(time); // 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; } }
long val = obj.getLong("value", 0);
/** * 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; } }
/** * 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; Level level = (Level)traverser.doTraverse(obj.get("level"), Level.class, traversed, processors, clone, targetcl, context); String msg = obj.getString("msg", null); long millis = obj.getLong("millis", 0); LogRecord ret = new LogRecord(level, msg); ret.setMillis(millis); // 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; } }
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))); b.lifeTimeInSec(jObj.getLong("lt", 0)); b.lwM2mVersion(jObj.getString("ver", "1.0")); b.registrationDate(new Date(jObj.getLong("regDate", 0))); if (jObj.get("sms") != null) { b.smsNumber(jObj.getString("sms", ""));
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))); b.lifeTimeInSec(jObj.getLong("lt", 0)); b.lwM2mVersion(jObj.getString("ver", "1.0")); b.registrationDate(new Date(jObj.getLong("regDate", 0))); if (jObj.get("sms") != null) { b.smsNumber(jObj.getString("sms", ""));
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; }
lifetime = v.getLong("lt", 0);
lifetime = v.getLong("lt", 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; } }