public synchronized String[] getWalletAllPublicAddresses() throws WalletCallException, IOException, InterruptedException { JsonArray jsonReceivedOutputs = executeCommandAndGetJsonArray("listreceivedbyaddress", "0", "true"); Set<String> addresses = new HashSet<>(); for (int i = 0; i < jsonReceivedOutputs.size(); i++) { JsonObject outp = jsonReceivedOutputs.get(i).asObject(); addresses.add(outp.getString("address", "ERROR!")); } return addresses.toArray(new String[0]); }
public synchronized String[] getWalletPublicAddressesWithUnspentOutputs() throws WalletCallException, IOException, InterruptedException { JsonArray jsonUnspentOutputs = executeCommandAndGetJsonArray("listunspent", "0"); Set<String> addresses = new HashSet<>(); for (int i = 0; i < jsonUnspentOutputs.size(); i++) { JsonObject outp = jsonUnspentOutputs.get(i).asObject(); addresses.add(outp.getString("address", "ERROR!")); } return addresses.toArray(new String[0]); }
public synchronized String[] getWalletAllPublicAddresses() throws WalletCallException, IOException, InterruptedException { JsonArray jsonReceivedOutputs = executeCommandAndGetJsonArray("listreceivedbyaddress", "0", "true"); Set<String> addresses = new HashSet<>(); for (int i = 0; i < jsonReceivedOutputs.size(); i++) { JsonObject outp = jsonReceivedOutputs.get(i).asObject(); addresses.add(outp.getString("address", "ERROR!")); } return addresses.toArray(new String[0]); }
@SuppressWarnings("unchecked") @Override public T[] read(JsonValue jsonValue) throws Exception { JsonArray array = jsonValue.asArray(); T[] result = (T[]) Array.newInstance(clazz, array.size()); for (int i = 0; i < result.length; i++) { result[i] = getValue(array.get(i)); } return result; }
public synchronized JsonObject[] getTransactionMessagingDataForZaddress(String ZAddress) throws WalletCallException, IOException, InterruptedException { JsonArray jsonTransactions = executeCommandAndGetJsonArray( "z_listreceivedbyaddress", wrapStringParameter(ZAddress), "0"); List<JsonObject> transactions = new ArrayList<JsonObject>(); for (int i = 0; i < jsonTransactions.size(); i++) { JsonObject trans = jsonTransactions.get(i).asObject(); transactions.add(trans); } return transactions.toArray(new JsonObject[0]); }
public synchronized String[] getWalletPublicAddressesWithUnspentOutputs() throws WalletCallException, IOException, InterruptedException { JsonArray jsonUnspentOutputs = executeCommandAndGetJsonArray("listunspent", "0"); Set<String> addresses = new HashSet<>(); for (int i = 0; i < jsonUnspentOutputs.size(); i++) { JsonObject outp = jsonUnspentOutputs.get(i).asObject(); addresses.add(outp.getString("address", "ERROR!")); } return addresses.toArray(new String[0]); }
public synchronized JsonObject[] getTransactionMessagingDataForZaddress(String ZAddress) throws WalletCallException, IOException, InterruptedException { JsonArray jsonTransactions = executeCommandAndGetJsonArray( "z_listreceivedbyaddress", wrapStringParameter(ZAddress), "0"); List<JsonObject> transactions = new ArrayList<JsonObject>(); for (int i = 0; i < jsonTransactions.size(); i++) { JsonObject trans = jsonTransactions.get(i).asObject(); transactions.add(trans); } return transactions.toArray(new JsonObject[0]); }
private String [] toStringArray(JsonArray jsonarray){ String [] out = new String[jsonarray.size()]; for(int i=0; i<jsonarray.size(); i++) out[i] = jsonarray.get(i).asString(); return out; }
public synchronized boolean isCompletedOperationSuccessful(String opID) throws WalletCallException, IOException, InterruptedException { JsonArray response = this.executeCommandAndGetJsonArray( "z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]")); JsonObject jsonStatus = response.get(0).asObject(); String status = jsonStatus.getString("status", "ERROR"); Log.info("Operation " + opID + " status is " + response + "."); if (status.equalsIgnoreCase("success")) { return true; } else if (status.equalsIgnoreCase("error") || status.equalsIgnoreCase("failed")) { return false; } else { throw new WalletCallException("Unexpected final operation status response from wallet: " + response.toString()); } }
public synchronized String[] getWalletZAddresses() throws WalletCallException, IOException, InterruptedException { JsonArray jsonAddresses = executeCommandAndGetJsonArray("z_listaddresses", null); String strAddresses[] = new String[jsonAddresses.size()]; for (int i = 0; i < jsonAddresses.size(); i++) { strAddresses[i] = jsonAddresses.get(i).asString(); } return strAddresses; }
public synchronized String[] getWalletZAddresses() throws WalletCallException, IOException, InterruptedException { JsonArray jsonAddresses = executeCommandAndGetJsonArray("z_listaddresses", null); String strAddresses[] = new String[jsonAddresses.size()]; for (int i = 0; i < jsonAddresses.size(); i++) { strAddresses[i] = jsonAddresses.get(i).asString(); } return strAddresses; }
public synchronized String getOperationFinalErrorMessage(String opID) throws WalletCallException, IOException, InterruptedException { JsonArray response = this.executeCommandAndGetJsonArray( "z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]")); JsonObject jsonStatus = response.get(0).asObject(); JsonObject jsonError = jsonStatus.get("error").asObject(); return jsonError.getString("message", "ERROR!"); }
public synchronized String getOperationFinalErrorMessage(String opID) throws WalletCallException, IOException, InterruptedException { JsonArray response = this.executeCommandAndGetJsonArray( "z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]")); JsonObject jsonStatus = response.get(0).asObject(); JsonObject jsonError = jsonStatus.get("error").asObject(); return jsonError.getString("message", "ERROR!"); }
private void decomposeJSONValue(String name, JsonValue val, Map<String, String> map) { if (val.isObject()) { JsonObject obj = val.asObject(); for (String memberName : obj.names()) { this.decomposeJSONValue(name + "." + memberName, obj.get(memberName), map); } } else if (val.isArray()) { JsonArray arr = val.asArray(); for (int i = 0; i < arr.size(); i++) { this.decomposeJSONValue(name + "[" + i + "]", arr.get(i), map); } } else { map.put(name, val.toString()); } }
private BoxFile.Info getFile(BoxJSONResponse response) { JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); JsonArray array = (JsonArray) jsonObject.get("entries"); JsonObject fileObj = (JsonObject) array.get(0); BoxFile file = new BoxFile(this.getAPI(), fileObj.get("id").asString()); return file.new Info(fileObj); }
public synchronized String getSuccessfulOperationTXID(String opID) throws WalletCallException, IOException, InterruptedException { String TXID = null; JsonArray response = this.executeCommandAndGetJsonArray( "z_getoperationstatus", wrapStringParameter("[\"" + opID + "\"]")); JsonObject jsonStatus = response.get(0).asObject(); JsonValue opResultValue = jsonStatus.get("result"); if (opResultValue != null) { JsonObject opResult = opResultValue.asObject(); if (opResult.get("txid") != null) { TXID = opResult.get("txid").asString(); } } return TXID; }
private static JsonObject getObject(SkypeImpl skype, String username) throws ConnectionException { JsonArray array = Endpoints.PROFILE_INFO .open(skype) .expect(200, "While getting contact info") .as(JsonArray.class) .post(new JsonObject() .add("usernames", new JsonArray() .add(username) ) ); return array.get(0).asObject(); }
RealtimeServerConnection(BoxAPIConnection api) { BoxAPIRequest request = new BoxAPIRequest(api, EVENT_URL.build(api.getBaseURL()), "OPTIONS"); BoxJSONResponse response = (BoxJSONResponse) request.send(); JsonObject jsonObject = JsonObject.readFrom(response.getJSON()); JsonArray entries = jsonObject.get("entries").asArray(); JsonObject firstEntry = entries.get(0).asObject(); this.serverURLString = firstEntry.get("url").asString(); this.retries = Integer.parseInt(firstEntry.get("max_retries").asString()); this.timeout = firstEntry.get("retry_timeout").asInt(); this.api = api; }
@Test @Issue("issues/302") public void testSerializeSpecialCharacters() throws Exception { ConnectionsRegistry.INSTANCE.clear(); final String CONNECTION_URL = "jdbc:h2:c:\\work\\keycloak-3.0.0.CR1\\standalone\\data/keycloak;AUTO_SERVER=TRUE"; ConnectionsRegistry.INSTANCE.setDataSourceStatus(CONNECTION_URL,"sa", 0); StringWriter sw = new StringWriter(); ConnectionsRegistry.INSTANCE.writeTo(sw); String persistedConnectionsRegistry = sw.getBuffer().toString(); assertNotNull(persistedConnectionsRegistry); JsonValue connectionRegistryJson = Json.parse(persistedConnectionsRegistry); assertEquals( CONNECTION_URL, connectionRegistryJson.asObject().get("dataSources").asArray().get(0).asObject().get("url").asString() ); }
private void init(ForecastIO fio){ JsonValue jsonvalue; if(fio.hasAlerts()){ for(int i=0; i < NumberOfAlerts(); i++ ){ alert[i] = new Alert(); jsonvalue = fio.getAlerts().get(i); alert[i].setTitle( jsonvalue.asObject().get("title").asString() ); alert[i].setTime( jsonvalue.asObject().get("time").asLong() ); alert[i].setExpire( jsonvalue.asObject().get("expires").asLong() ); alert[i].setDescription( jsonvalue.asObject().get("description").asString() ); alert[i].setUri( jsonvalue.asObject().get("uri").asString() ); } } }