List of usage examples for org.json JSONArray getInt
public int getInt(int index) throws JSONException
From source file:edu.umass.cs.msocket.proxy.forwarder.ProxyLoadStatistics.java
/** * Return the number of open TCP connections from the serialized form of stats * generated by {@link #serializeLoadInformation()} * /*from w w w . ja v a2 s. c o m*/ * @param load * @return * @throws JSONException */ public static int getOpenTcpConnFromSerializedInfo(JSONArray load) throws JSONException { // TCP conn is the 1st element return load.getInt(0); }
From source file:edu.umass.cs.msocket.proxy.forwarder.ProxyLoadStatistics.java
/** * Return the throughput from the serialized form of stats generated by * {@link #serializeLoadInformation()}/* ww w .j a v a 2 s . c o m*/ * * @param load * @return * @throws JSONException */ public static int getThroughputFromSerializedInfo(JSONArray load) throws JSONException { // Throughput is the 2nd element return load.getInt(1); }
From source file:com.dubsar_dictionary.Dubsar.model.Word.java
@Override public void parseData(Object jsonResponse) throws JSONException { JSONArray response = (JSONArray) jsonResponse; mId = response.getInt(0); mName = new String(response.getString(1)); setPos(response.getString(2));//w w w . ja v a 2s. c o m setInflections(response.getString(3)); setFreqCnt(response.getInt(5)); JSONArray list = response.getJSONArray(4); mSenses = new ArrayList<Sense>(list.length()); for (int j = 0; j < list.length(); ++j) { JSONArray entry = list.getJSONArray(j); int senseId; String senseName; Sense sense; JSONArray _synonyms = entry.getJSONArray(1); ArrayList<Sense> synonyms = new ArrayList<Sense>(_synonyms.length()); for (int k = 0; k < _synonyms.length(); ++k) { JSONArray _synonym = _synonyms.getJSONArray(k); senseId = _synonym.getInt(0); senseName = _synonym.getString(1); sense = new Sense(senseId, senseName, getPartOfSpeech()); synonyms.add(sense); } senseId = entry.getInt(0); String gloss = entry.getString(2); sense = new Sense(senseId, gloss, synonyms, this); sense.setLexname(entry.getString(3)); if (!entry.isNull(4)) { sense.setMarker(entry.getString(4)); } sense.setFreqCnt(entry.getInt(5)); mSenses.add(sense); } }
From source file:org.uiautomation.ios.server.application.APPIOSApplication.java
public List<Integer> getDeviceFamily() { try {// w w w . j a va2 s. c o m JSONArray array = metadata.getJSONArray(DEVICE_FAMILLY); List<Integer> res = new ArrayList<Integer>(); for (int i = 0; i < array.length(); i++) { res.add(array.getInt(i)); } return res; } catch (JSONException e) { throw new WebDriverException("Cannot load device family", e); } }
From source file:org.uiautomation.ios.server.application.APPIOSApplication.java
public List<DeviceType> getSupportedDevices() { List<DeviceType> families = new ArrayList<DeviceType>(); String s = (String) getMetadata(IOSCapabilities.DEVICE_FAMILLY); try {//from w w w .j a v a 2s . c om JSONArray ar = new JSONArray(s); for (int i = 0; i < ar.length(); i++) { int f = ar.getInt(i); if (f == 1) { families.add(DeviceType.iphone); families.add(DeviceType.ipod); } else { families.add(DeviceType.ipad); } } return families; } catch (JSONException e) { throw new WebDriverException(e); } }
From source file:no.opentech.shoppinglist.file.JSONHandler.java
public ArrayList<Item> createItemListFromJSON(String json) { ArrayList<Item> itemList = new ArrayList<Item>(); JSONArray jsonItems; try {//from w w w . j a v a 2 s . co m jsonItems = new JSONArray(json); if ((jsonItems.length() % 6) != 0) return null; for (int i = 0; i < jsonItems.length(); i += 6) { Item item = new Item(); item.setName(jsonItems.getString(i)); item.setDescription(jsonItems.getString(i + 1)); item.setUsageCounter(jsonItems.getInt(i + 2)); item.setAvgNumberInLine(jsonItems.getInt(i + 3)); Date first = new Date(); first.setTime(jsonItems.getLong(i + 4)); Date last = new Date(); last.setTime(jsonItems.getLong(i + 5)); item.setFirstSeen(first); item.setLastSeen(last); itemList.add(item); } } catch (JSONException e) { return null; } return itemList; }
From source file:org.apache.cordova.dialogs.Notification.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArray of arguments for the plugin. * @param callbackContext The callback context used when calling back into JavaScript. * @return True when the action was valid, false otherwise. *//*from w w w . j a v a 2 s.co m*/ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { /* * Don't run any of these if the current activity is finishing * in order to avoid android.view.WindowManager$BadTokenException * crashing the app. Just return true here since false should only * be returned in the event of an invalid action. */ if (this.cordova.getActivity().isFinishing()) return true; if (action.equals("beep")) { this.beep(args.getLong(0)); } else if (action.equals("alert")) { this.alert(args.getString(0), args.getString(1), args.getString(2), callbackContext); return true; } else if (action.equals("confirm")) { this.confirm(args.getString(0), args.getString(1), args.getJSONArray(2), callbackContext); return true; } else if (action.equals("prompt")) { this.prompt(args.getString(0), args.getString(1), args.getJSONArray(2), args.getString(3), callbackContext); return true; } else if (action.equals("activityStart")) { this.activityStart(args.getString(0), args.getString(1)); } else if (action.equals("activityStop")) { this.activityStop(); } else if (action.equals("progressStart")) { this.progressStart(args.getString(0), args.getString(1)); } else if (action.equals("progressValue")) { this.progressValue(args.getInt(0)); } else if (action.equals("progressStop")) { this.progressStop(); } else { return false; } // Only alert and confirm are async. callbackContext.success(); return true; }
From source file:com.liferay.mobile.android.v7.assetvocabulary.AssetVocabularyService.java
public Integer getGroupVocabulariesCount(long groupId, String name) throws Exception { JSONObject _command = new JSONObject(); try {/*from ww w . j a va 2 s . c o m*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("name", checkNull(name)); _command.put("/assetvocabulary/get-group-vocabularies-count", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getInt(0); }
From source file:com.liferay.mobile.android.v7.assetvocabulary.AssetVocabularyService.java
public Integer getGroupVocabulariesCount(JSONArray groupIds) throws Exception { JSONObject _command = new JSONObject(); try {/*from w w w . ja v a2 s . c o m*/ JSONObject _params = new JSONObject(); _params.put("groupIds", checkNull(groupIds)); _command.put("/assetvocabulary/get-group-vocabularies-count", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getInt(0); }
From source file:com.liferay.mobile.android.v7.assetvocabulary.AssetVocabularyService.java
public Integer getGroupVocabulariesCount(long groupId) throws Exception { JSONObject _command = new JSONObject(); try {/*from ww w. ja v a 2 s .c o m*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _command.put("/assetvocabulary/get-group-vocabularies-count", _params); } catch (JSONException _je) { throw new Exception(_je); } JSONArray _result = session.invoke(_command); if (_result == null) { return null; } return _result.getInt(0); }