List of usage examples for org.json JSONArray getInt
public int getInt(int index) throws JSONException
From source file:com.liferay.mobile.android.v7.ddmstructure.DDMStructureService.java
public Integer searchCount(long companyId, JSONArray groupIds, long classNameId, String name, String description, String storageType, int type, int status, boolean andOperator) throws Exception { JSONObject _command = new JSONObject(); try {//from w w w . java 2 s . c o m JSONObject _params = new JSONObject(); _params.put("companyId", companyId); _params.put("groupIds", checkNull(groupIds)); _params.put("classNameId", classNameId); _params.put("name", checkNull(name)); _params.put("description", checkNull(description)); _params.put("storageType", checkNull(storageType)); _params.put("type", type); _params.put("status", status); _params.put("andOperator", andOperator); _command.put("/ddm.ddmstructure/search-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.ddmstructure.DDMStructureService.java
public Integer searchCount(long companyId, JSONArray groupIds, long classNameId, String keywords, int status) throws Exception { JSONObject _command = new JSONObject(); try {/*from ww w . j av a 2 s. c om*/ JSONObject _params = new JSONObject(); _params.put("companyId", companyId); _params.put("groupIds", checkNull(groupIds)); _params.put("classNameId", classNameId); _params.put("keywords", checkNull(keywords)); _params.put("status", status); _command.put("/ddm.ddmstructure/search-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.ecml.MidiOptions.java
/** Initialize the options from a json string * // w w w.ja va2 s. co m * @param jsonString */ public static MidiOptions fromJson(String jsonString) { if (jsonString == null) { return null; } MidiOptions options = new MidiOptions(); try { JSONObject json = new JSONObject(jsonString); JSONArray jsonTracks = json.getJSONArray("tracks"); options.tracks = new boolean[jsonTracks.length()]; for (int i = 0; i < options.tracks.length; i++) { options.tracks[i] = jsonTracks.getBoolean(i); } JSONArray jsonMute = json.getJSONArray("mute"); options.mute = new boolean[jsonMute.length()]; for (int i = 0; i < options.mute.length; i++) { options.mute[i] = jsonMute.getBoolean(i); } JSONArray jsonInstruments = json.getJSONArray("instruments"); options.instruments = new int[jsonInstruments.length()]; for (int i = 0; i < options.instruments.length; i++) { options.instruments[i] = jsonInstruments.getInt(i); } if (json.has("time")) { JSONObject jsonTime = json.getJSONObject("time"); int numer = jsonTime.getInt("numerator"); int denom = jsonTime.getInt("denominator"); int quarter = jsonTime.getInt("quarter"); int tempo = jsonTime.getInt("tempo"); options.time = new TimeSignature(numer, denom, quarter, tempo); } options.useDefaultInstruments = json.getBoolean("useDefaultInstruments"); options.scrollVert = json.getBoolean("scrollVert"); options.showPiano = json.getBoolean("showPiano"); options.showNoteColors = json.getBoolean("showNoteColors"); options.showLyrics = json.getBoolean("showLyrics"); options.delay = json.getInt("delay"); options.twoStaffs = json.getBoolean("twoStaffs"); options.showNoteLetters = json.getInt("showNoteLetters"); options.transpose = json.getInt("transpose"); options.key = json.getInt("key"); options.combineInterval = json.getInt("combineInterval"); options.shade1Color = json.getInt("shade1Color"); options.shade2Color = json.getInt("shade2Color"); options.showMeasures = json.getBoolean("showMeasures"); options.playMeasuresInLoop = json.getBoolean("playMeasuresInLoop"); options.playMeasuresInLoopStart = json.getInt("playMeasuresInLoopStart"); options.playMeasuresInLoopEnd = json.getInt("playMeasuresInLoopEnd"); } catch (Exception e) { return null; } return options; }
From source file:com.liferay.mobile.android.v62.assetcategory.AssetCategoryService.java
public Integer getVocabularyCategoriesCount(long groupId, long vocabularyId) throws Exception { JSONObject _command = new JSONObject(); try {// w w w . ja va 2s .c o m JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("vocabularyId", vocabularyId); _command.put("/assetcategory/get-vocabulary-categories-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.v62.assetcategory.AssetCategoryService.java
public Integer getVocabularyCategoriesCount(long groupId, String name, long vocabularyId) throws Exception { JSONObject _command = new JSONObject(); try {/*from w ww . j ava 2 s. co m*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("name", checkNull(name)); _params.put("vocabularyId", vocabularyId); _command.put("/assetcategory/get-vocabulary-categories-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.v62.assetcategory.AssetCategoryService.java
public Integer getVocabularyRootCategoriesCount(long groupId, long vocabularyId) throws Exception { JSONObject _command = new JSONObject(); try {/* w ww. j a v a 2s. c o m*/ JSONObject _params = new JSONObject(); _params.put("groupId", groupId); _params.put("vocabularyId", vocabularyId); _command.put("/assetcategory/get-vocabulary-root-categories-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:mr.robotto.engine.loader.components.mesh.MrMeshLoader.java
private void loadIndexData(MrBuffer buffer, JSONArray array) throws JSONException { for (int i = 0; i < array.length(); i++) { buffer.putShort((short) array.getInt(i)); }/*ww w.jav a 2s. c o m*/ }
From source file:io.ingame.squarecamera.CameraLauncher.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArry of arguments for the plugin. * @param callbackContext The callback id used when calling back into JavaScript. * @return A PluginResult object with a status and message. *//*from w ww.j ava 2 s . com*/ public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { this.callbackContext = callbackContext; if (action.equals("takePicture")) { int srcType = CAMERA; int destType = FILE_URI; this.saveToPhotoAlbum = false; this.targetHeight = 0; this.targetWidth = 0; this.encodingType = JPEG; this.mediaType = PICTURE; this.mQuality = 80; this.mQuality = args.getInt(0); destType = args.getInt(1); srcType = args.getInt(2); this.targetWidth = args.getInt(3); this.targetHeight = args.getInt(4); this.encodingType = args.getInt(5); this.mediaType = args.getInt(6); this.allowEdit = args.getBoolean(7); this.correctOrientation = args.getBoolean(8); this.saveToPhotoAlbum = args.getBoolean(9); // If the user specifies a 0 or smaller width/height // make it -1 so later comparisons succeed if (this.targetWidth < 1) { this.targetWidth = -1; } if (this.targetHeight < 1) { this.targetHeight = -1; } try { if (srcType == CAMERA) { this.takePicture(destType, encodingType); } else if ((srcType == PHOTOLIBRARY) || (srcType == SAVEDPHOTOALBUM)) { this.getImage(srcType, destType, encodingType); } } catch (IllegalArgumentException e) { callbackContext.error("Illegal Argument Exception"); PluginResult r = new PluginResult(PluginResult.Status.ERROR); callbackContext.sendPluginResult(r); return true; } PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT); r.setKeepCallback(true); callbackContext.sendPluginResult(r); return true; } return false; }
From source file:com.gmail.boiledorange73.ut.map.MapActivityBase.java
/** * Called when JS sends the message.//from w w w .java2 s .c o m * * @param bridge * Receiver instance. * @param code * The code name. This looks like the name of function. * @param message * The message. This looks like the argument of function. This is * usually expressed as JSON. */ @Override public void onArriveMessage(JSBridge bridge, String code, String message) { if (code == null) { } else if (code.equals("onLoad")) { this.mMaptypeList = new ArrayList<ValueText<String>>(); this.mLoaded = true; // executes queued commands. this.execute(null); JSONArray json = null; try { json = new JSONArray(message); } catch (JSONException e) { e.printStackTrace(); } if (json != null) { for (int n = 0; n < json.length(); n++) { JSONObject one = null; try { one = json.getJSONObject(n); } catch (JSONException e) { e.printStackTrace(); } if (one != null) { String id = null, name = null; try { id = one.getString("id"); name = one.getString("name"); } catch (JSONException e) { e.printStackTrace(); } if (id != null && name != null) { this.mMaptypeList.add(new ValueText<String>(id, name)); } } } } // restores map state (2013/08/07) if (this.mInternalMapState != null) { this.restoreMapState(this.mInternalMapState.id, this.mInternalMapState.lon, this.mInternalMapState.lat, this.mInternalMapState.z); this.mInternalMapState = null; } // request to create menu items. this.invalidateOptionsMenuIfPossible(); } else if (code.equals("getCurrentMapState")) { if (message == null || !(message.length() > 0)) { // DOES NOTHING } else { try { JSONObject json = new JSONObject(message); this.mInternalMapState = new MapState(); this.mInternalMapState.id = json.getString("id"); this.mInternalMapState.lat = json.getDouble("lat"); this.mInternalMapState.lon = json.getDouble("lon"); this.mInternalMapState.z = json.getInt("z"); } catch (JSONException e) { e.printStackTrace(); } } this.mWaitingForgetCurrentMapState = false; } else if (code.equals("getCurrentZoomState")) { if (message == null) { // DOES NOTHING } else { try { JSONObject json = new JSONObject(message); this.mZoomState = new ZoomState(); this.mZoomState.minzoom = json.getInt("minzoom"); this.mZoomState.maxzoom = json.getInt("maxzoom"); this.mZoomState.currentzoom = json.getInt("currentzoom"); } catch (JSONException e) { e.printStackTrace(); } this.mWaitingForgetCurrentZoomState = false; } } else if (code.equals("alert")) { // shows alert text. (new AlertDialog.Builder(this)).setTitle(this.getTitle()).setMessage(message != null ? message : "") .setCancelable(true).setPositiveButton(android.R.string.ok, null).show(); } }
From source file:com.dubsar_dictionary.Dubsar.model.Sense.java
@Override public void parseData(Object jsonResponse) throws JSONException { JSONArray response = (JSONArray) jsonResponse; JSONArray _word = response.getJSONArray(1); JSONArray _synset = response.getJSONArray(2); int wordId = _word.getInt(0); String wordName = _word.getString(1); String wordPos = _word.getString(2); int synsetId = _synset.getInt(0); mGloss = new String(_synset.getString(1)); setPos(wordPos);// www.j a v a 2 s. c o m mWord = new Word(wordId, wordName, getPartOfSpeech()); mName = new String(wordName); mSynset = new Synset(synsetId, mGloss, getPartOfSpeech()); mIsWeakWordReference = mIsWeakSynsetReference = false; mWordReference = null; mSynsetReference = null; setLexname(response.getString(3)); getSynset().setLexname(getLexname()); if (!response.isNull(4)) { setMarker(response.getString(4)); } setFreqCnt(response.getInt(5)); JSONArray _synonyms = response.getJSONArray(6); mSynonyms = new ArrayList<Sense>(_synonyms.length()); int j; int senseId; String senseName; for (j = 0; j < _synonyms.length(); ++j) { JSONArray _synonym = _synonyms.getJSONArray(j); senseId = _synonym.getInt(0); senseName = _synonym.getString(1); String marker = null; if (!_synonym.isNull(2)) { marker = _synonym.getString(2); } int freqCnt = _synonym.getInt(3); Sense synonym = new Sense(senseId, senseName, getSynset()); synonym.setMarker(marker); synonym.setFreqCnt(freqCnt); mSynonyms.add(synonym); } JSONArray _verbFrames = response.getJSONArray(7); mVerbFrames = new ArrayList<String>(_verbFrames.length()); for (j = 0; j < _verbFrames.length(); ++j) { String frame = _verbFrames.getString(j); // Replace %s in verb frames with the name of the word // TODO: Make that a bold span. StringBuffer buffer = new StringBuffer(); Formatter formatter = new Formatter(buffer); formatter.format(frame, new Object[] { getName() }); formatter.close(); mVerbFrames.add(buffer.toString()); } JSONArray _samples = response.getJSONArray(8); mSamples = new ArrayList<String>(_samples.length()); for (j = 0; j < _samples.length(); ++j) { mSamples.add(_samples.getString(j)); } parsePointers(response.getJSONArray(9)); }