Package org.codehaus.jettison.json

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


                JSONArray jValues = jRepresentation.getJSONArray(key.toString());
                assertTrue("Fields MUST contain at least a single value!",jValues.length() > 0);
                for(int i=0;i<jValues.length();i++){
                    JSONObject fieldValue = jValues.optJSONObject(i);
                    assertNotNull("Values for field "+key+" does contain an value " +
                        "that is not an JSONObject "+jValues.optString(i),
                        fieldValue);
                    String[] value = new String[2];
                    value[0] = fieldValue.optString("value");
                    value[1] = null;
                    assertNotNull("All Field-values MUST have the 'value' property",value[0]);
View Full Code Here


        JSONArray addFields = jConstraint.optJSONArray("addFields");
        final List<String> fields;
        if(addFields != null && addFields.length() > 0){
            fields = new ArrayList<String>(addFields.length());
            for(int i=0;i<addFields.length();i++){
                String field = addFields.optString(i);
                if(field != null && !field.isEmpty()){
                    fields.add(NamespaceEnum.getFullName(field));
                }
            }
        } else {
View Full Code Here

        if(!jQuery.has("type")){
            types = Collections.emptySet();
        } else if((jTypes = jQuery.optJSONArray("type")) != null){
            types = new HashSet<String>(jTypes.length());
            for(int i=0;i<jTypes.length();i++){
                String type = NamespaceEnum.getFullName(jTypes.optString(i));
                if(type != null && !type.isEmpty()){
                    types.add(type);
                }
            }
        } else {
View Full Code Here

        if (graphElementDeleted != null) {
            if (keysToDelete != null && keysToDelete.length() > 0) {
                // just delete keys from the element
                for (int ix = 0; ix < keysToDelete.length(); ix++) {
                    graphElementDeleted.removeProperty(keysToDelete.optString(ix));
                }
            } else {
                // delete the whole element
                if (elementType.equals(Tokens.VERTEX)) {
                    graph.removeVertex((Vertex) graphElementDeleted);
View Full Code Here

        TinkerGraph testGraph = TinkerGraphFactory.createTinkerGraph();

        this.testGraphs = new ArrayList<GraphTestHolder>();
        for (int ix = 0; ix < jsonArray.length(); ix++) {
            ClientRequest graphRequest = ClientRequest.create().build(createUri("/" + jsonArray.optString(ix)), "GET");
            ClientResponse graphResponse = this.client.handle(graphRequest);

            JSONObject graphJson = graphResponse.getEntity(JSONObject.class);

            final JSONObject featuresJson = graphJson.optJSONObject("features");
View Full Code Here

                if (!testGraph.getGraphType().equals("com.thinkaurelius.titan.graphdb.database.StandardTitanGraph")) {
                    response = doGraphGet(testGraph, "keyindices/vertex");
                    JSONObject keyIndicesVertexJson = response.getEntity(JSONObject.class);
                    JSONArray keyIndicesVertexToDelete = keyIndicesVertexJson.optJSONArray(Tokens.RESULTS);
                    for (int ix = 0; ix < keyIndicesVertexToDelete.length(); ix++) {
                        this.client.handle(ClientRequest.create().build(createUri("/" + testGraph.getGraphName() + "/keyindices/vertex/" + encode(keyIndicesVertexToDelete.optString(ix))), "DELETE"));
                    }

                    response = doGraphGet(testGraph, "keyindices/edge");
                    JSONObject keyIndicesEdgeJson = response.getEntity(JSONObject.class);
                    JSONArray keyIndicesEdgeToDelete = keyIndicesEdgeJson.optJSONArray(Tokens.RESULTS);
View Full Code Here

                    response = doGraphGet(testGraph, "keyindices/edge");
                    JSONObject keyIndicesEdgeJson = response.getEntity(JSONObject.class);
                    JSONArray keyIndicesEdgeToDelete = keyIndicesEdgeJson.optJSONArray(Tokens.RESULTS);
                    for (int ix = 0; ix < keyIndicesEdgeToDelete.length(); ix++) {
                        this.client.handle(ClientRequest.create().build(createUri("/" + testGraph.getGraphName() + "/keyindices/edge/" + keyIndicesEdgeToDelete.optString(ix)), "DELETE"));
                    }
                }
            }
        } finally {
            super.tearDown();
View Full Code Here

        String[] labels = null;
        if (labelSet != null) {
            labels = new String[labelSet.length()];
            for (int ix = 0; ix < labelSet.length(); ix++) {
                labels[ix] = labelSet.optString(ix);
            }
        }
        return labels;
    }
View Full Code Here

        final JSONArray vertexKeys = jsonKeys.optJSONArray(Tokens.VERTEX);
        Assert.assertEquals(2, vertexKeys.length());

        final JSONArray edgeKeys = jsonKeys.optJSONArray(Tokens.EDGE);
        Assert.assertEquals(1, edgeKeys.length());
        Assert.assertEquals("weight", edgeKeys.optString(0));
    }

    @Test(expected = WebApplicationException.class)
    public void getIndexKeysNonIndexableGraph() {
        final KeyIndexResource resource = mockNonKeyIndexableGraph();
View Full Code Here

        Iterator<String> scripts = null;
        if (jsonArray != null) {
            List<String> scriptList = new ArrayList<String>();
            for (int ix = 0; ix < jsonArray.length(); ix++) {
                final String locationAndScriptFile = scriptLocation + File.separator + jsonArray.optString(ix) + ".gremlin";

                String script = cachedScripts.get(locationAndScriptFile);
                if (script == null) {
                    script = readFile(locationAndScriptFile);
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.