/** * Get the int value associated with an index. * * @param index * The index must be between 0 and length() - 1. * @return The value. * @throws JSONException * If the key is not found or if the value is not a number. */ public int getInt(int index) throws JSONException { return this.getNumber(index).intValue(); }
/** * Get the double value associated with an index. * * @param index * The index must be between 0 and length() - 1. * @return The value. * @throws JSONException * If the key is not found or if the value cannot be converted * to a number. */ public double getDouble(int index) throws JSONException { return this.getNumber(index).doubleValue(); }
/** * Get the float value associated with a key. * * @param index * The index must be between 0 and length() - 1. * @return The numeric value. * @throws JSONException * if the key is not found or if the value is not a Number * object and cannot be converted to a number. */ public float getFloat(int index) throws JSONException { return this.getNumber(index).floatValue(); }
/** * Get the long value associated with an index. * * @param index * The index must be between 0 and length() - 1. * @return The value. * @throws JSONException * If the key is not found or if the value cannot be converted * to a number. */ public long getLong(int index) throws JSONException { return this.getNumber(index).longValue(); }
/** * Get the int value associated with an index. * * @param index * The index must be between 0 and length() - 1. * @return The value. * @throws JSONException * If the key is not found or if the value is not a number. */ public int getInt(int index) throws JSONException { return this.getNumber(index).intValue(); }
/** * Get the float value associated with a key. * * @param index * The index must be between 0 and length() - 1. * @return The numeric value. * @throws JSONException * if the key is not found or if the value is not a Number * object and cannot be converted to a number. */ public float getFloat(int index) throws JSONException { return this.getNumber(index).floatValue(); }
/** * Get the double value associated with an index. * * @param index * The index must be between 0 and length() - 1. * @return The value. * @throws JSONException * If the key is not found or if the value cannot be converted * to a number. */ public double getDouble(int index) throws JSONException { return this.getNumber(index).doubleValue(); }
/** * Get the long value associated with an index. * * @param index * The index must be between 0 and length() - 1. * @return The value. * @throws JSONException * If the key is not found or if the value cannot be converted * to a number. */ public long getLong(int index) throws JSONException { return this.getNumber(index).longValue(); }
private BitfinexOrderBookEntry jsonToRawOrderbookEntry(final JSONArray jsonArray) { final long orderId = jsonArray.getNumber(0).longValue(); final BigDecimal price = jsonArray.getBigDecimal(1); final BigDecimal amount = jsonArray.getBigDecimal(2); return new BitfinexOrderBookEntry(orderId, price, amount, null); }
private BitfinexExecutedTrade jsonToExecutedTrade(final JSONArray jsonArray) { final BitfinexExecutedTrade executedTrade = new BitfinexExecutedTrade(); final long id = jsonArray.getNumber(0).longValue(); executedTrade.setTradeId(id); final long timestamp = jsonArray.getNumber(1).longValue(); executedTrade.setTimestamp(timestamp); final BigDecimal amount = jsonArray.getBigDecimal(2); executedTrade.setAmount(amount); // Funding or Currency if (jsonArray.optNumber(4) != null) { final BigDecimal rate = jsonArray.getBigDecimal(3); executedTrade.setRate(rate); final Long period = jsonArray.getLong(4); executedTrade.setPeriod(period); } else { final BigDecimal price = jsonArray.getBigDecimal(3); executedTrade.setPrice(price); } return executedTrade; }