Examples of optInt()


Examples of org.apache.wink.json4j.JSONObject.optInt()

    public void test_optInt() {
        Exception ex = null;

        try {
            JSONObject jObject = new JSONObject("{\"int\":1}");
            assertTrue(jObject.optInt("int") == 1);
            assertTrue(jObject.optInt("int2", 2) == 2);
            assertTrue(jObject.optInt("int2") == 0);
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
View Full Code Here

Examples of org.codehaus.jettison.json.JSONArray.optInt()

        if (doTest.equals("true")) {
            final RexsterGraph g = (RexsterGraph) graphTest.generateGraph();
            ((RexsterGraphTest) graphTest).resetGraph();

            final JSONArray additionResults = g.execute("1+1");
            Assert.assertEquals(2, additionResults.optInt(0));

            g.addVertex("1");
            g.addVertex("2");
            g.addVertex("3");
View Full Code Here

Examples of org.codehaus.jettison.json.JSONObject.optInt()

        JSONObject json = GraphSONUtility.jsonFromElement(v, null, GraphSONMode.NORMAL);

        Assert.assertNotNull(json);
        Assert.assertTrue(json.has(GraphSONTokens._ID));
        Assert.assertEquals(1, json.optInt(GraphSONTokens._ID));
        Assert.assertTrue(json.has("keyLongArray"));

        JSONArray longArrayAsJSON = json.optJSONArray("keyLongArray");
        Assert.assertNotNull(longArrayAsJSON);
        Assert.assertEquals(3, longArrayAsJSON.length());
View Full Code Here

Examples of org.json.JSONArray.optInt()

  public List<RemoteWebElement> findElementsByCSSSelector(String selector) {
    JSONObject response = inspector.sendCommand(DOM.querySelectorAll(nodeId, selector));
    JSONArray nodesId = response.optJSONArray("nodeIds");
    ArrayList<RemoteWebElement> res = new ArrayList<RemoteWebElement>();
    for (int i = 0; i < nodesId.length(); i++) {
      NodeId id = new NodeId(nodesId.optInt(i));
      res.add(new RemoteWebElement(id, inspector));
    }
    return res;

  }
View Full Code Here

Examples of org.json.JSONObject.optInt()

        final JSONObject statistic = statisticRepository.get(Statistic.STATISTIC);
        if (null == statistic) {
            throw new RepositoryException("Not found statistic");
        }

        statistic.put(Statistic.STATISTIC_BLOG_ARTICLE_COUNT, statistic.optInt(Statistic.STATISTIC_BLOG_ARTICLE_COUNT) + 1);
        statisticRepository.update(Statistic.STATISTIC, statistic);
    }

    /**
     * Blog statistic published article count +1.
View Full Code Here

Examples of org.json.JSONObject.optInt()

        final JSONObject statistic = statisticRepository.get(Statistic.STATISTIC);
        if (null == statistic) {
            throw new RepositoryException("Not found statistic");
        }

        statistic.put(Statistic.STATISTIC_PUBLISHED_ARTICLE_COUNT, statistic.optInt(Statistic.STATISTIC_PUBLISHED_ARTICLE_COUNT) + 1);
        statisticRepository.update(Statistic.STATISTIC, statistic);
    }

    /**
     * Blog statistic article count -1.
View Full Code Here

Examples of org.json.JSONObject.optInt()

        final JSONObject page = get(id);
        if (null == page) {
            return null;
        }

        final Query query = new Query().addFilter(Page.PAGE_ORDER, FilterOperator.LESS_THAN, page.optInt(Page.PAGE_ORDER)).
                addSort(Page.PAGE_ORDER, SortDirection.DESCENDING).
                setCurrentPageNum(1).setPageSize(1).setPageCount(1);

        final JSONObject result = get(query);
        final JSONArray array = result.optJSONArray(Keys.RESULTS);
View Full Code Here

Examples of org.json.JSONObject.optInt()

        final JSONObject page = get(id);
        if (null == page) {
            return null;
        }

        final Query query = new Query().addFilter(Page.PAGE_ORDER, FilterOperator.GREATER_THAN, page.optInt(Page.PAGE_ORDER)).
                addSort(Page.PAGE_ORDER, SortDirection.ASCENDING).setCurrentPageNum(1).
                setPageSize(1).
                setPageCount(1);

        final JSONObject result = get(query);
View Full Code Here

Examples of org.json.JSONObject.optInt()

            final int blogCmtCnt = statistics.getPublishedBlogCommentCount();
            final int articleCmtCnt = article.getInt(ARTICLE_COMMENT_COUNT);
            statistics.setPublishedBlogCommentCount(blogCmtCnt - articleCmtCnt);

            final JSONObject author = userRepository.getByEmail(article.optString(Article.ARTICLE_AUTHOR_EMAIL));
            author.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, author.optInt(UserExt.USER_PUBLISHED_ARTICLE_COUNT) - 1);
            userRepository.update(author.optString(Keys.OBJECT_ID), author);

            transaction.commit();
        } catch (final Exception e) {
            if (transaction.isActive()) {
View Full Code Here

Examples of org.json.JSONObject.optInt()

                final int blogCmtCnt = statistics.getPublishedBlogCommentCount();
                final int articleCmtCnt = article.getInt(ARTICLE_COMMENT_COUNT);
                statistics.setPublishedBlogCommentCount(blogCmtCnt + articleCmtCnt);

                final JSONObject author = userRepository.getByEmail(article.optString(Article.ARTICLE_AUTHOR_EMAIL));
                author.put(UserExt.USER_PUBLISHED_ARTICLE_COUNT, author.optInt(UserExt.USER_PUBLISHED_ARTICLE_COUNT) + 1);
                userRepository.update(author.optString(Keys.OBJECT_ID), author);
            }

            if (publishNewArticle) {
                incArchiveDatePublishedRefCount(articleId);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.