Package org.codehaus.jettison.json

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


        if (null != edges) {
            for (int i = 0; i < edges.length(); i++) {
                final JSONObject edge = edges.optJSONObject(i);
                FaunusEdge faunusEdge = null;
                if (direction.equals(Direction.IN)) {
                    faunusEdge = (FaunusEdge) graphson.edgeFromJson(edge, new FaunusVertex(edge.optLong(GraphSONTokens._OUT_V)), vertex);
                } else if (direction.equals(Direction.OUT)) {
                    faunusEdge = (FaunusEdge) graphson.edgeFromJson(edge, vertex, new FaunusVertex(edge.optLong(GraphSONTokens._IN_V)));
                }

                if (faunusEdge != null) {
View Full Code Here


                final JSONObject edge = edges.optJSONObject(i);
                FaunusEdge faunusEdge = null;
                if (direction.equals(Direction.IN)) {
                    faunusEdge = (FaunusEdge) graphson.edgeFromJson(edge, new FaunusVertex(edge.optLong(GraphSONTokens._OUT_V)), vertex);
                } else if (direction.equals(Direction.OUT)) {
                    faunusEdge = (FaunusEdge) graphson.edgeFromJson(edge, vertex, new FaunusVertex(edge.optLong(GraphSONTokens._IN_V)));
                }

                if (faunusEdge != null) {
                    vertex.addEdge(direction, faunusEdge);
                }
View Full Code Here

        try {
            final HttpURLConnection connection = HttpHelper.createConnection(
                    this.getRestCountEndpoint(), this.getAuthenticationHeaderValue());
            final JSONObject json = new JSONObject(convertStreamToString(connection.getInputStream()));

            return json.optLong(FaunusRexsterInputFormatExtension.EXTENSION_METHOD_COUNT);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage(), e);
        }
    }
View Full Code Here

        } else {
            directionReturnToken = RexsterTokens.SLASH_BOTHCOUNT;
        }

        final JSONObject jsonObject = RestHelper.get(buildUri(directionReturnToken));
        return jsonObject.optLong(RexsterTokens.TOTAL_SIZE);
    }

    public Object vertexIds() {
        final String directionReturnToken;
        if (this.direction == Direction.IN) {
View Full Code Here

        return StringFactory.indexString(this);
    }

    public long count(final String key, final Object value) {
        final JSONObject countJson = RestHelper.get(this.graph.getGraphURI() + RexsterTokens.SLASH_INDICES_SLASH + RestHelper.encode(this.indexName) + RexsterTokens.SLASH_COUNT + RexsterTokens.QUESTION + RexsterTokens.KEY_EQUALS + key + RexsterTokens.AND + RexsterTokens.VALUE_EQUALS + RestHelper.uriCast(value));
        return countJson.optLong("totalSize");
    }
}
View Full Code Here

        valueAsJson = json.optJSONObject("keyLong");
        Assert.assertNotNull(valueAsJson);
        Assert.assertTrue(valueAsJson.has(GraphSONTokens.TYPE));
        Assert.assertEquals(GraphSONTokens.TYPE_LONG, valueAsJson.optString(GraphSONTokens.TYPE));
        Assert.assertTrue(valueAsJson.has(GraphSONTokens.VALUE));
        Assert.assertEquals(1L, valueAsJson.optLong(GraphSONTokens.VALUE));

        valueAsJson = json.optJSONObject("keyInt");
        Assert.assertNotNull(valueAsJson);
        Assert.assertTrue(valueAsJson.has(GraphSONTokens.TYPE));
        Assert.assertEquals(GraphSONTokens.TYPE_INTEGER, valueAsJson.optString(GraphSONTokens.TYPE));
View Full Code Here

        Assert.assertTrue(json.has(GraphSONTokens._ID));
        Assert.assertEquals(1, json.optInt(GraphSONTokens._ID));
        Assert.assertTrue(json.has("keyString"));
        Assert.assertEquals("string", json.optString("keyString"));
        Assert.assertTrue(json.has("keyLong"));
        Assert.assertEquals(1L, json.optLong("keyLong"));
        Assert.assertTrue(json.has("keyInt"));
        Assert.assertEquals(2, json.optInt("keyInt"));
        Assert.assertTrue(json.has("keyFloat"));
        Assert.assertEquals(3.3f, (float) json.optDouble("keyFloat"), 0);
        Assert.assertTrue(json.has("keyExponentialDouble"));
View Full Code Here

            JSONObject valueAsJson = listAsJSON.optJSONObject(ix);
            Assert.assertNotNull(valueAsJson);
            Assert.assertTrue(valueAsJson.has(GraphSONTokens.TYPE));
            Assert.assertEquals(GraphSONTokens.TYPE_LONG, valueAsJson.optString(GraphSONTokens.TYPE));
            Assert.assertTrue(valueAsJson.has(GraphSONTokens.VALUE));
            Assert.assertEquals(1000L, valueAsJson.optLong(GraphSONTokens.VALUE));
        }
    }

    @Test
    public void jsonFromElementVertexIntListPropertiesNoKeysWithTypes() throws JSONException {
View Full Code Here

        final Vertex v = new VertexThatReturnsNull();
        final JSONObject json = GraphSONUtility.jsonFromElement(v, null, GraphSONMode.EXTENDED);

        Assert.assertNotNull(json);
        Assert.assertTrue(json.has(GraphSONTokens._ID));
        Assert.assertEquals(1234l, json.optLong(GraphSONTokens._ID));
        Assert.assertFalse(json.has("alwaysNull"));
    }

    /**
     * This test is kinda weird since a Blueprints graph can't have properties set to null, howerver that does not
View Full Code Here

        final Vertex v = new VertexThatReturnsNull();
        final JSONObject json = GraphSONUtility.jsonFromElement(v, null, GraphSONMode.NORMAL);

        Assert.assertNotNull(json);
        Assert.assertTrue(json.has(GraphSONTokens._ID));
        Assert.assertEquals(1234l, json.optLong(GraphSONTokens._ID));
        Assert.assertFalse(json.has("alwaysNull"));
    }

    @Test
    public void jsonFromElementNullsNoKeysNoTypes() throws JSONException {
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.