Example usage for org.json JSONArray getInt

List of usage examples for org.json JSONArray getInt

Introduction

In this page you can find the example usage for org.json JSONArray getInt.

Prototype

public int getInt(int index) throws JSONException 

Source Link

Document

Get the int value associated with an index.

Usage

From source file:com.liferay.mobile.android.v7.dlfileentry.DLFileEntryService.java

public Integer getGroupFileEntriesCount(long groupId, long userId, long rootFolderId) throws Exception {
    JSONObject _command = new JSONObject();

    try {//from www.j  ava2s .com
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("userId", userId);
        _params.put("rootFolderId", rootFolderId);

        _command.put("/dlfileentry/get-group-file-entries-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.dlfileentry.DLFileEntryService.java

public Integer getGroupFileEntriesCount(long groupId, long userId, long rootFolderId, JSONArray mimeTypes,
        int status) throws Exception {
    JSONObject _command = new JSONObject();

    try {//ww w.  j  av a  2 s  . c o  m
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("userId", userId);
        _params.put("rootFolderId", rootFolderId);
        _params.put("mimeTypes", checkNull(mimeTypes));
        _params.put("status", status);

        _command.put("/dlfileentry/get-group-file-entries-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.dlfileentry.DLFileEntryService.java

public Integer getGroupFileEntriesCount(long groupId, long userId, long repositoryId, long rootFolderId,
        JSONArray mimeTypes, int status) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from   w  w w .  j  a  v a 2 s  . c om*/
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("userId", userId);
        _params.put("repositoryId", repositoryId);
        _params.put("rootFolderId", rootFolderId);
        _params.put("mimeTypes", checkNull(mimeTypes));
        _params.put("status", status);

        _command.put("/dlfileentry/get-group-file-entries-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:net.geco.model.iojson.PersistentStore.java

public void importControls(JSONStore store, Registry registry) throws JSONException {
    if (store.has(K.CONTROLS)) { // MIRG 2.x -> 2.2
        JSONArray controls = store.getJSONArray(K.CONTROLS);
        for (int i = 0; i < controls.length(); i++) {
            JSONArray codeData = controls.getJSONArray(i);
            registry.setControlPenalty(codeData.getInt(0), new Date(codeData.getLong(1)));
        }//from ww w.  j  a v a  2  s .co m
    }
}

From source file:net.geco.model.iojson.PersistentStore.java

public void importCourses(JSONStore store, Registry registry, Factory factory) throws JSONException {
    JSONArray courses = store.getJSONArray(K.COURSES);
    for (int i = 0; i < courses.length(); i++) {
        JSONObject c = courses.getJSONObject(i);
        Course course = store.register(factory.createCourse(), c.getInt(K.ID));
        course.setName(c.getString(K.NAME));
        course.setLength(c.getInt(K.LENGTH));
        course.setClimb(c.getInt(K.CLIMB));
        course.setMassStartTime(new Date(c.optLong(K.START, TimeManager.NO_TIME_l))); // MIGR v2.x -> v2.2
        course.setCourseSet(store.retrieve(c.optInt(K.COURSESET, 0), CourseSet.class));
        JSONArray codez = c.getJSONArray(K.CODES);
        int[] codes = new int[codez.length()];
        for (int j = 0; j < codes.length; j++) {
            codes[j] = codez.getInt(j);
        }//from ww w .j  a v a 2  s  .  c o m
        course.setCodes(codes);
        if (c.has(K.SECTIONS)) {
            JSONArray sectionz = c.getJSONArray(K.SECTIONS);
            for (int j = 0; j < sectionz.length(); j++) {
                JSONObject sectionTuple = sectionz.getJSONObject(j);
                Section section = store.register(factory.createSection(), sectionTuple.getInt(K.ID));
                section.setStartIndex(sectionTuple.getInt(K.START_ID));
                section.setName(sectionTuple.getString(K.NAME));
                section.setType(SectionType.valueOf(sectionTuple.getString(K.TYPE)));
                section.setNeutralized(sectionTuple.optBoolean(K.NEUTRALIZED, false));
                course.putSection(section);
            }
            course.refreshSectionCodes();
        }
        registry.addCourse(course);
    }
    registry.ensureAutoCourse(factory);
}

From source file:net.geco.model.iojson.PersistentStore.java

public void importHeatSets(JSONStore store, Registry registry, Factory factory) throws JSONException {
    JSONArray heatsets = store.getJSONArray(K.HEATSETS);
    for (int i = 0; i < heatsets.length(); i++) {
        JSONObject h = heatsets.getJSONObject(i);
        HeatSet heatset = factory.createHeatSet();
        heatset.setName(h.getString(K.NAME));
        heatset.setQualifyingRank(h.getInt(K.RANK));
        heatset.setSetType(ResultType.valueOf(h.getString(K.TYPE)));
        JSONArray heatz = h.getJSONArray(K.HEATS);
        String[] heats = new String[heatz.length()];
        for (int j = 0; j < heats.length; j++) {
            heats[j] = heatz.getString(j);
        }/*www .j a va  2  s .co  m*/
        heatset.setHeatNames(heats);
        JSONArray poolz = h.getJSONArray(K.POOLS);
        Pool[] pools = new Pool[poolz.length()];
        for (int j = 0; j < pools.length; j++) {
            pools[j] = store.retrieve(poolz.getInt(j), Pool.class);
        }
        heatset.setSelectedPools(pools);
        registry.addHeatSet(heatset);
    }
}

From source file:net.geco.model.iojson.PersistentStore.java

public void importRunnersData(JSONStore store, Registry registry, Factory factory) throws JSONException {
    final int I_RUNNER = 0;
    final int I_ECARD = 1;
    final int I_RESULT = 2;
    JSONArray runnersData = store.getJSONArray(K.RUNNERS_DATA);
    for (int i = 0; i < runnersData.length(); i++) {
        JSONArray runnerTuple = runnersData.getJSONArray(i);

        JSONObject c = runnerTuple.getJSONObject(I_RUNNER);
        Runner runner = factory.createRunner();
        runner.setStartId(c.getInt(K.START_ID));
        runner.setFirstname(c.getString(K.FIRST));
        runner.setLastname(c.getString(K.LAST));
        runner.setEcard(c.getString(K.ECARD));
        runner.setClub(store.retrieve(c.getInt(K.CLUB), Club.class));
        runner.setCategory(store.retrieve(c.getInt(K.CAT), Category.class));
        runner.setCourse(store.retrieve(c.getInt(K.COURSE), Course.class));
        runner.setRegisteredStarttime(new Date(c.getLong(K.START)));
        runner.setArchiveId((Integer) c.opt(K.ARK));
        runner.setRentedEcard(c.optBoolean(K.RENT));
        runner.setNC(c.optBoolean(K.NC));
        registry.addRunner(runner);// w w w  .ja  v a  2 s .c  om

        JSONObject d = runnerTuple.getJSONObject(I_ECARD);
        RunnerRaceData raceData = factory.createRunnerRaceData();
        raceData.setStarttime(new Date(d.getLong(K.START)));
        raceData.setFinishtime(new Date(d.getLong(K.FINISH)));
        raceData.setControltime(new Date(d.getLong(K.CHECK)));
        raceData.setReadtime(new Date(d.getLong(K.READ)));
        JSONArray p = d.getJSONArray(K.PUNCHES);
        Punch[] punches = new Punch[p.length() / 2];
        for (int j = 0; j < punches.length; j++) {
            punches[j] = factory.createPunch();
            punches[j].setCode(p.getInt(2 * j));
            punches[j].setTime(new Date(p.getLong(2 * j + 1)));
        }
        raceData.setPunches(punches);
        raceData.setRunner(runner);
        registry.addRunnerData(raceData);

        JSONObject r = runnerTuple.getJSONObject(I_RESULT);
        TraceData traceData = factory.createTraceData();
        traceData.setNbMPs(r.getInt(K.MPS));
        traceData.setNbExtraneous(r.optInt(K.EXTRA)); // MIGR v2.x -> v2.3
        JSONArray t = r.getJSONArray(K.TRACE);
        Trace[] trace = new Trace[t.length() / 2];
        for (int j = 0; j < trace.length; j++) {
            trace[j] = factory.createTrace(t.getString(2 * j), new Date(t.getLong(2 * j + 1)));
        }
        if (r.has(K.SECTION_DATA)) {
            SectionTraceData sectionData = (SectionTraceData) traceData;
            JSONArray sections = r.getJSONArray(K.SECTION_DATA);
            for (int j = 0; j < sections.length(); j++) {
                JSONArray section = sections.getJSONArray(j);
                sectionData.putSectionAt(store.retrieve(section.getInt(0), Section.class), section.getInt(1));
            }
        }
        JSONArray neut = r.getJSONArray(K.NEUTRALIZED);
        for (int j = 0; j < neut.length(); j++) {
            trace[neut.getInt(j)].setNeutralized(true);
        }
        traceData.setTrace(trace);
        raceData.setTraceData(traceData);

        RunnerResult result = factory.createRunnerResult();
        result.setRaceTime(r.optLong(K.RACE_TIME, TimeManager.NO_TIME_l)); // MIGR v2.x -> v2.2
        result.setResultTime(r.getLong(K.TIME));
        result.setStatus(Status.valueOf(r.getString(K.STATUS)));
        result.setTimePenalty(r.getLong(K.PENALTY));
        result.setManualTimePenalty(r.optLong(K.MANUAL_PENALTY, 0)); // MIGR v2.x -> v2.3
        raceData.setResult(result);
    }
}

From source file:com.nextgis.firereporter.ScanexSubscriptionItem.java

protected void FillData(int nType, String sData) {
    String sCleanData = GetFiresService.removeJsonT(sData);
    try {//w w  w  .  j a va2  s  .  c  om
        JSONObject object = new JSONObject(sCleanData);
        String sStatus = object.getString("Status");
        if (sStatus.equals("OK")) {
            JSONArray jsonArray = object.getJSONArray("Result");
            for (int i = 0; i < jsonArray.length(); i++) {
                JSONArray jsonSubArray = jsonArray.getJSONArray(i);
                long nID = jsonSubArray.getLong(0);
                String sPtCoord = jsonSubArray.getString(1);
                int nConfidence = jsonSubArray.getInt(2);
                int nPower = jsonSubArray.getInt(3);
                String sURL1 = jsonSubArray.getString(4);
                String sURL2 = jsonSubArray.getString(5);
                String sType = jsonSubArray.getString(6);
                String sPlace = jsonSubArray.getString(7);
                String sDate = jsonSubArray.getString(8);
                String sMap = jsonSubArray.getString(9);

                if (!mmoItems.containsKey(nID)) {
                    ScanexNotificationItem Item = new ScanexNotificationItem(c, nID, sPtCoord, nConfidence,
                            nPower, sURL1, sURL2, sType, sPlace, sDate, sMap, R.drawable.ic_scan);
                    mmoItems.put(Item.GetId(), Item);
                    //notify changes
                    c.onNewNotifictation(GetId(), Item);
                    setHasNews(true);
                }
            }
        } else {
            SendError(object.getString("ErrorInfo"));
        }
    } catch (JSONException e) {
        SendError(e.getLocalizedMessage());
    }

    /*44({
       "Status": "OK",
       "ErrorInfo": "",
       "Result": [[1306601,
       "61.917, 63.090",
       68,
       27.4,
       "\u003ca href=\u0027http://maps.kosmosnimki.ru/TileService.ashx/apikeyV6IAK16QRG/mapT42E9?SERVICE=WMS&request=GetMap&version=1.3&layers=C7B2E6510209444E80673F3C37519F7E,FFE60CFA7DAF498381F811C08A5E8CF5,T42E9.A78AC25E0D924258B5AF40048C21F7E7_dt04102013&styles=&crs=EPSG:3395&transparent=FALSE&format=image/jpeg&width=460&height=460&bbox=6987987,8766592,7058307,8836912\u0027\u003e \u003cimg src=\u0027http://maps.kosmosnimki.ru/TileService.ashx/apikeyV6IAK16QRG/mapT42E9?SERVICE=WMS&request=GetMap&version=1.3&layers=C7B2E6510209444E80673F3C37519F7E,FFE60CFA7DAF498381F811C08A5E8CF5,T42E9.A78AC25E0D924258B5AF40048C21F7E7_dt04102013&styles=&crs=EPSG:3395&transparent=FALSE&format=image/jpeg&width=100&height=100&bbox=6987987,8766592,7058307,8836912\u0027 width=\u0027{4}\u0027 height=\u0027{5}\u0027 /\u003e\u003c/a\u003e",
       "\u003ca href=\u0027http://fires.kosmosnimki.ru/?x=63.09&y=61.917&z=11&dt=04.10.2013\u0027 target=\"_blank\"\u003eView on the map\u003c/a\u003e",
       "Fire",
       "",
       "\/Date(1380859500000)\/",
       "http://maps.kosmosnimki.ru/TileService.ashx/apikeyV6IAK16QRG/mapT42E9?SERVICE=WMS&request=GetMap&version=1.3&layers=C7B2E6510209444E80673F3C37519F7E,FFE60CFA7DAF498381F811C08A5E8CF5,T42E9.A78AC25E0D924258B5AF40048C21F7E7_dt04102013&styles=&crs=EPSG:3395&transparent=FALSE&format=image/jpeg&width=460&height=460&bbox=6987987,8766592,7058307,8836912",
       null]]
    })*/
}

From source file:com.liferay.mobile.android.v7.ddmstructureversion.DdmstructureversionService.java

public Integer getStructureVersionsCount(long structureId) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from   w ww  .java2 s .co  m*/
        JSONObject _params = new JSONObject();

        _params.put("structureId", structureId);

        _command.put("/ddm.ddmstructureversion/get-structure-versions-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.mbcategory.MBCategoryService.java

public Integer getCategoriesCount(long groupId, long parentCategoryId, int status) throws Exception {
    JSONObject _command = new JSONObject();

    try {/*from  www  . jav a 2  s .c  o  m*/
        JSONObject _params = new JSONObject();

        _params.put("groupId", groupId);
        _params.put("parentCategoryId", parentCategoryId);
        _params.put("status", status);

        _command.put("/mbcategory/get-categories-count", _params);
    } catch (JSONException _je) {
        throw new Exception(_je);
    }

    JSONArray _result = session.invoke(_command);

    if (_result == null) {
        return null;
    }

    return _result.getInt(0);
}