Examples of JsonObjectBuilder


Examples of javax.json.JsonObjectBuilder

        }
        return builder.build();
    }

    public JsonObject getBeanStatistics(String applicationName, String beanName) {
        JsonObjectBuilder builder = Json.createObjectBuilder();
        JsonObject components = collector.fetchMethods(applicationName, beanName);
        if (components == null) {
            return builder.addNull("-- no methods --").build();
        }
        Set<Map.Entry<String, JsonValue>> entrySet = components.entrySet();
        for (Map.Entry<String, JsonValue> component : entrySet) {
            String methodName = component.getKey();
            JsonObject methodStatistics = collector.fetchMethodStatistics(applicationName, beanName, methodName);
            if (beanName == null || methodStatistics == null) {
                LOG.info("!!!NULL -> Beanname: " + beanName + " -> " + methodStatistics);
            } else {
                builder.add(methodName, methodStatistics);
            }
        }
        return builder.build();
    }
View Full Code Here

Examples of javax.json.JsonObjectBuilder

    @Context
    ServletContext sc;

    @GET
    public JsonObject info() {
        JsonObjectBuilder builder = Json.createObjectBuilder();
        OneShot info = this.information.fetch();
        String version = "--", uptime = "--";
        if (info != null) {
            version = info.getVersion();
        }
        builder.add("version", version);
        if (info != null) {
            uptime = info.getUptime();
        }
        builder.add("uptime", uptime);
        return builder.build();
    }
View Full Code Here

Examples of javax.json.JsonObjectBuilder

    }

    @GET
    @Path("lightfish")
    public JsonObject lightfish() {
        JsonObjectBuilder builder = Json.createObjectBuilder();
        Properties properties = new Properties();
        InputStream is = this.sc.getResourceAsStream("/META-INF/maven/org.glassfish/lightfish/pom.properties");
        if (is != null) {
            try {
                properties.load(is);
            } catch (IOException ex) {
                throw new IllegalStateException("Cannot load properties: " + ex, ex);
            }
        }
        Set<Object> keySet = properties.keySet();
        for (Object object : keySet) {
            builder.add((String) object, (String) properties.get(object));
        }
        return builder.build();
    }
View Full Code Here

Examples of javax.json.JsonObjectBuilder

    @Inject
    MonitoringAdmin admin;

    @POST
    public JsonObject startPolling(JsonObject pollingInfo) {
        JsonObjectBuilder objectBuilder = Json.createObjectBuilder();
        int interval = pollingInfo.getInt(INTERVAL);
        configurator.setValue(INTERVAL, interval);
        String location = pollingInfo.getString(LOCATION, "localhost:4848");
        configurator.setValue(LOCATION, location);
        controller.restart();
View Full Code Here

Examples of javax.json.JsonObjectBuilder

    }

    @GET
    public JsonObject status() {
        JsonObjectBuilder objectBuilder = Json.createObjectBuilder();
        Date nextTimeout = controller.nextTimeout();
        String timeoutAsString = "-";
        if (nextTimeout != null) {
            timeoutAsString = nextTimeout.toString();
        }
        objectBuilder.add("nextTimeout", timeoutAsString).add(INTERVAL, configurator.getValue(INTERVAL));
        return objectBuilder.build();
    }
View Full Code Here

Examples of javax.json.JsonObjectBuilder

    @Override
    @NotNull(message = "Gist can't be NULL")
    public Gist create(@NotNull(message = "list of files can't be NULL")
        final Map<String, String> files, final boolean visible
    ) throws IOException {
        JsonObjectBuilder builder = Json.createObjectBuilder();
        for (final Map.Entry<String, String> file : files.entrySet()) {
            builder = builder.add(
                file.getKey(),
                Json.createObjectBuilder().add("content", file.getValue())
            );
        }
        final JsonStructure json = Json.createObjectBuilder()
View Full Code Here

Examples of javax.json.JsonObjectBuilder

    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);
            }
        }
View Full Code Here

Examples of javax.json.JsonObjectBuilder

  /* (non-Javadoc)
   * @see com.cloutree.modelevaluator.PredictiveModelResult#toJSON()
   */
  @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

Examples of javax.json.JsonObjectBuilder

        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());

        objThisIter.add(pat.first().toStringSimple(), o);
      }
      obj.add(objThisIter.build());
View Full Code Here

Examples of javax.json.JsonObjectBuilder

        IOUtils.ensureDir(new File(constVars.outDir + "/" + constVars.identifier + "/" + label));

        if (constVars.writeMatchedTokensFiles) {

          String matchedtokensfilename = constVars.outDir + "/" + constVars.identifier + "/" + label + "/tokensmatchedpatterns" + ".json";
          JsonObjectBuilder pats = Json.createObjectBuilder();
          for (Entry<E, Collection<Triple<String, Integer, Integer>>> en : tokensMatchedPat.entrySet()) {
            CollectionValuedMap<String, Pair<Integer, Integer>> matchedStrs = new CollectionValuedMap<String, Pair<Integer, Integer>>();
            for (Triple<String, Integer, Integer> en2 : en.getValue()) {
              allMatchedSents.add(en2.first());
              matchedStrs.add(en2.first(), new Pair<Integer, Integer>(en2.second(), en2.third()));
            }

            JsonObjectBuilder senttokens = Json.createObjectBuilder();
            for (Entry<String, Collection<Pair<Integer, Integer>>> sen : matchedStrs.entrySet()) {
              JsonArrayBuilder obj = Json.createArrayBuilder();
              for (Pair<Integer, Integer> sen2 : sen.getValue()) {
                JsonArrayBuilder startend = Json.createArrayBuilder();
                startend.add(sen2.first());
                startend.add(sen2.second());
                obj.add(startend);
              }
              senttokens.add(sen.getKey(), obj);
            }
            pats.add(en.getKey().toStringSimple(), senttokens);
          }
          IOUtils.writeStringToFile(pats.build().toString(), matchedtokensfilename, "utf8");

          // Writing the sentence json file -- tokens for each sentence
          JsonObjectBuilder senttokens = Json.createObjectBuilder();
          for (String sentId : allMatchedSents) {
            JsonArrayBuilder sent = Json.createArrayBuilder();
            for (CoreLabel l : Data.sents.get(sentId)) {
              sent.add(l.word());
            }
            senttokens.add(sentId, sent);
          }
          String sentfilename = constVars.outDir + "/" + constVars.identifier + "/sentences" + ".json";
          IOUtils.writeStringToFile(senttokens.build().toString(), sentfilename, "utf8");
        }
      }

    }
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.