Package javax.json

Examples of javax.json.JsonArrayBuilder$JsonArrayImpl


    @Override
    @NotNull(message = "iterable is never NULL")
    public Iterable<String> add(@NotNull(message = "emails is never NULL")
        final Iterable<String> emails) throws IOException {
        final JsonArrayBuilder json = Json.createArrayBuilder();
        for (final String email : emails) {
            json.add(email);
        }
        final List<JsonObject> array = this.request.method(Request.POST)
            .body().set(json.build()).back()
            .fetch().as(RestResponse.class)
            .assertStatus(HttpURLConnection.HTTP_CREATED)
            .as(JsonResponse.class)
            .json().readArray().getValuesAs(JsonObject.class);
        final Collection<String> result = new ArrayList<String>(array.size());
View Full Code Here


    }

    @Override
    public void remove(@NotNull(message = "emails is never NULL")
        final Iterable<String> emails) throws IOException {
        final JsonArrayBuilder json = Json.createArrayBuilder();
        for (final String email : emails) {
            json.add(email);
        }
        this.request.method(Request.DELETE)
            .body().set(json.build()).back()
            .fetch().as(RestResponse.class)
            .assertStatus(HttpURLConnection.HTTP_NO_CONTENT);
    }
View Full Code Here

        ).json();
        final JsonObjectBuilder json = Json.createObjectBuilder();
        for (final Map.Entry<String, JsonValue> val: obj.entrySet()) {
            json.add(val.getKey(), val.getValue());
        }
        final JsonArrayBuilder array = Json.createArrayBuilder();
        for (final Label label : this.labels().iterate()) {
            array.add(
                Json.createObjectBuilder().add("name", label.name()).build()
            );
        }
        return json
            .add("labels", array)
View Full Code Here

    }

    @Override
    public void add(@NotNull(message = "iterable of labels can't be NULL")
        final Iterable<String> labels) throws IOException {
        JsonArrayBuilder builder = Json.createArrayBuilder();
        for (final String label : labels) {
            builder = builder.add(label);
        }
        final JsonStructure json = builder.build();
        this.request.method(Request.POST)
            .body().set(json).back()
            .fetch()
            .as(RestResponse.class)
            .assertStatus(HttpURLConnection.HTTP_OK)
View Full Code Here

    }

    @Override
    public void replace(@NotNull(message = "iterable of labels can't be NULL")
        final Iterable<String> labels) throws IOException {
        JsonArrayBuilder builder = Json.createArrayBuilder();
        for (final String label : labels) {
            builder = builder.add(label);
        }
        final JsonStructure json = builder.build();
        this.request.method(Request.PUT)
            .body().set(json).back()
            .fetch()
            .as(RestResponse.class)
            .assertStatus(HttpURLConnection.HTTP_OK)
View Full Code Here

@Produces(MediaType.APPLICATION_JSON)
public class DocumentFilteringResource {

    @POST
    public JsonArray filter(final JsonArray properties) {
        final JsonArrayBuilder documents = Json.createArrayBuilder();
        final List<JsonString> propertyList = properties.getValuesAs(JsonString.class);

        for (final JsonObject jsonObject : DocumentStorage.getAll()) {
            final JsonObjectBuilder documentBuilder = Json.createObjectBuilder();

            for (final JsonString property : propertyList) {
                final String key = property.getString();

                if (jsonObject.containsKey(key)) {
                    documentBuilder.add(key, jsonObject.get(key));
                }
            }

            final JsonObject document = documentBuilder.build();
            if (!document.isEmpty()) {
                documents.add(document);
            }
        }

        return documents.build();
    }
View Full Code Here

@Produces(MediaType.APPLICATION_JSON)
public class DocumentResource {

    @GET
    public JsonArray getAll() {
        final JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
        for (final JsonObject document : DocumentStorage.getAll()) {
            arrayBuilder.add(document);
        }
        return arrayBuilder.build();
    }
View Full Code Here

    }

    @POST
    @Path("multiple")
    public JsonArray store(final JsonArray documents) {
        final JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();
        for (final JsonObject document : documents.getValuesAs(JsonObject.class)) {
            arrayBuilder.add(DocumentStorage.store(document));
        }
        return arrayBuilder.build();
    }
View Full Code Here

   */
  @Override
  public String toJSON() {
    JsonObjectBuilder builder = Json.createObjectBuilder();
   
    JsonArrayBuilder outputBuilder = Json.createArrayBuilder();
   
    // Output Values
    Set<String> outputKeys = this.outputValues.keySet();
    for(String outputKey : outputKeys) {
        Object val = this.outputValues.get(outputKey);
        if(val != null) {
      outputBuilder.add(Json.createObjectBuilder().add(outputKey, val.toString()));
        }
    }
    builder.add("outputValues", outputBuilder);
   
    JsonArrayBuilder predictedBuilder = Json.createArrayBuilder();
    Set<String> predictedKeys = this.predictedValues.keySet();
    for(String predictedKey : predictedKeys) {
        Object val = this.predictedValues.get(predictedKey);
        if(val != null) {
      predictedBuilder.add(Json.createObjectBuilder().add(predictedKey, val.toString()));
        }
    }
    builder.add("predictedValues", predictedBuilder);
   
    JsonArrayBuilder errorBuilder = Json.createArrayBuilder();
    for(String error : this.errors) {
        errorBuilder.add(error);
    }
    builder.add("errors", errorBuilder);
   
    JsonObject jsonObject = builder.build();
    return jsonObject.toString();
View Full Code Here

      IOUtils.ensureDir(new File(outputdir));

      String filename = outputdir + "/patterns" + ".json";

      JsonArrayBuilder obj = Json.createArrayBuilder();
      if (writtenPatInJustification.containsKey(label) && writtenPatInJustification.get(label)) {
        JsonReader jsonReader = Json.createReader(new BufferedInputStream(new FileInputStream(filename)));
        JsonArray objarr = jsonReader.readArray();
        jsonReader.close();
        for (JsonValue o : objarr)
          obj.add(o);
      } else
        obj = Json.createArrayBuilder();

      JsonObjectBuilder objThisIter = Json.createObjectBuilder();
      for (Pair<E, Double> pat : chosenPatSorted) {
        JsonObjectBuilder o = Json.createObjectBuilder();
        JsonArrayBuilder pos = Json.createArrayBuilder();
        JsonArrayBuilder neg = Json.createArrayBuilder();
        JsonArrayBuilder unlab = Json.createArrayBuilder();

        for (String w : posWords.get(pat.first()))
          pos.add(w);
        for (String w : negWords.get(pat.first()))
          neg.add(w);
        for (String w : unlabWords.get(pat.first()))
          unlab.add(w);

        o.add("Positive", pos);
        o.add("Negative", neg);
        o.add("Unlabeled", unlab);
        o.add("Score", pat.second());
View Full Code Here

TOP

Related Classes of javax.json.JsonArrayBuilder$JsonArrayImpl

Copyright © 2018 www.massapicom. 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.