/** * Get extra long value. * @param key The key of the stored value. * @return The stored value. * @throws JSONException If the mapping doesn't exist or is not the required type. */ public long getExtraLong(String key) throws JSONException { return mExtraData.getLong(key); }
/** * Get extra long value. * @param key The key of the stored value. * @return The stored value. * @throws JSONException If the mapping doesn't exist or is not the required type. */ public long getExtraLong(String key) throws JSONException { return mExtraData.getLong(key); }
/** * Restore internal state from JSONObject stored at earlier * checkpoint-time. * * @param json JSONObject * @throws JSONException */ protected void fromCheckpointJson(JSONObject json) throws JSONException { uriCount.set(json.getLong("uriCount")); }
public long getTimeLimit() { long timebox = 0; try { timebox = mConf.getLong("timeLim"); } catch (JSONException e) { throw new RuntimeException(e); } return timebox; }
/** * Check if the authentication is still valid * @return true if the Authentication is still valid or does not have an expire time set. false otherwise */ public boolean checkExpireTime() { return !this.json.has("expires_on") || this.json.getLong("expires_on") > Instant.now().getEpochSecond(); }
public static Result parse(String body, int vote) throws JSONException { Result result = new Result(); JSONObject jo = new JSONObject(body); result.id = jo.getLong("comment_id"); result.score = jo.getInt("comment_score"); result.vote = jo.getInt("comment_vote"); result.expectVote = vote; return result; } }
@SuppressWarnings("unchecked") public static void putAllLongs(Map<String,Long> targetMap, JSONObject sourceJson) throws JSONException { for(String k : new Iteratorable<String>(sourceJson.keys())) { targetMap.put(k, sourceJson.getLong(k)); } }
@SuppressWarnings("unchecked") public static void putAllAtomicLongs(Map<String,AtomicLong> targetMap, JSONObject sourceJson) throws JSONException { for(String k : new Iteratorable<String>(sourceJson.keys())) { targetMap.put(k, new AtomicLong(sourceJson.getLong(k))); } } }
@Override protected void fromCheckpointJson(JSONObject json) throws JSONException { super.fromCheckpointJson(json); numberOfLinksExtracted.set(json.getLong("numberOfLinksExtracted")); }
/** Add or update an existing model. Used for syncing and merging. */ public void update(JSONObject m) { try { mModels.put(m.getLong("id"), m); } catch (JSONException e) { throw new RuntimeException(e); } // mark registry changed, but don't bump mod time save(); }
public void updateConf(JSONObject g) { try { mDconf.put(g.getLong("id"), g); } catch (JSONException e) { throw new RuntimeException(e); } save(); }
/** * The currently selected did. */ public long selected() { try { return mCol.getConf().getLong("curDeck"); } catch (JSONException e) { throw new RuntimeException(e); } }
private static void readSettingFromCache(UserSetting userSetting) { validateInitialized(); try { String settingStr = userSettingPref.getString(userSetting.keyInCache, ""); if (!settingStr.isEmpty()) { JSONObject setting = new JSONObject(settingStr); userSetting.value = setting.getBoolean(VALUE); userSetting.lastTS = setting.getLong(LAST_TIMESTAMP); } } catch (JSONException je) { Utility.logd(TAG, je); } }
/** Convert username to UserID. */ private String getUserID(String username) throws IOException { LOGGER.info("Fetching user ID for " + username); JSONObject json = new Http("https://api.500px.com/v1/" + "users/show" + "?username=" + username + "&consumer_key=" + CONSUMER_KEY) .getJSON(); return Long.toString(json.getJSONObject("user").getLong("id")); }
public int _deckNewLimitSingle(JSONObject g) { try { if (g.getInt("dyn") != 0) { return mReportLimit; } JSONObject c = mCol.getDecks().confForDid(g.getLong("id")); return Math.max(0, c.getJSONObject("new").getInt("perDay") - g.getJSONArray("newToday").getInt(1)); } catch (JSONException e) { throw new RuntimeException(e); } }
private int _deckRevLimitSingle(JSONObject d) { try { if (d.getInt("dyn") != 0) { return mReportLimit; } JSONObject c = mCol.getDecks().confForDid(d.getLong("id")); return Math.max(0, c.getJSONObject("rev").getInt("perDay") - d.getJSONArray("revToday").getInt(1)); } catch (JSONException e) { throw new RuntimeException(e); } }
private void maybeAddToActive() { // reselect current deck, or default if current has disappeared JSONObject c = current(); try { select(c.getLong("id")); } catch (JSONException e) { throw new RuntimeException(e); } }
/** Note ids for M */ public ArrayList<Long> nids(JSONObject m) { try { return mCol.getDb().queryColumn(Long.class, "SELECT id FROM notes WHERE mid = " + m.getLong("id"), 0); } catch (JSONException e) { throw new RuntimeException(e); } }
/** * Number of notes using m * @param m The model to the count the notes of. * @return The number of notes with that model. */ public int useCount(JSONObject m) { try { return mCol.getDb().queryScalar("select count() from notes where mid = " + m.getLong("id")); } catch (JSONException e) { throw new RuntimeException(e); } }
protected long getParentDid() { long deckID; try { deckID = getCol().getDecks().current().getLong("id"); } catch (JSONException e) { throw new RuntimeException(e); } return deckID; }