Package javax.json

Examples of javax.json.JsonObjectBuilder$JsonObjectImpl


    @NotNull(message = "Hook is never NULL")
    public Hook create(
        @NotNull(message = "name can't be NULL") final String name,
        @NotNull(message = "config can't be NULL")
        final Map<String, String> config) throws IOException {
        final JsonObjectBuilder builder = Json.createObjectBuilder();
        for (final Map.Entry<String, String> entr : config.entrySet()) {
            builder.add(entr.getKey(), entr.getValue());
        }
        final JsonStructure json = Json.createObjectBuilder()
            .add("name", name)
            .add("config", builder)
            .build();
View Full Code Here


    @NotNull(message = "JSON is never NULL")
    public JsonObject json() throws IOException {
        final JsonObject obj = new JsonNode(
            this.storage.xml().nodes(this.xpath()).get(0)
        ).json();
        final JsonObjectBuilder json = Json.createObjectBuilder();
        for (final Map.Entry<String, JsonValue> val : obj.entrySet()) {
            json.add(val.getKey(), val.getValue());
        }
        return json
            .add(
                "comments",
                this.storage.xml().nodes(this.comment()).size()
        ).build();
    }
View Full Code Here

    @Override
    public void write(
        @NotNull(message = "file name can't be NULL") final String file,
        @NotNull(message = "file content can't be NULL") final String content)
        throws IOException {
        final JsonObjectBuilder builder = Json.createObjectBuilder()
            .add("content", content);
        final JsonObject json = Json.createObjectBuilder()
            .add("files", Json.createObjectBuilder().add(file, builder))
            .build();
        this.patch(json);
View Full Code Here

    @NotNull(message = "JSON is never NULL")
    public JsonObject json() throws IOException {
        final JsonObject obj = new JsonNode(
            this.storage.xml().nodes(this.xpath()).get(0)
        ).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)
            .add(
                "pull_request",
                Json.createObjectBuilder().addNull("html_url").build()
            )
View Full Code Here

     * @return JSON
     */
    @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
    @NotNull(message = "JSON is never NULL")
    public JsonObject json() {
        final JsonObjectBuilder builder = Json.createObjectBuilder();
        for (final XML child : this.xml.nodes("* ")) {
            final Node node = child.node();
            if (child.nodes("*").isEmpty()) {
                builder.add(node.getNodeName(), node.getTextContent());
            } else {
                builder.add(node.getNodeName(), new JsonNode(child).json());
            }
        }
        return builder.build();
    }
View Full Code Here

     * @throws Exception If some problem inside
     */
    private static JsonObject hook(final String name,
        final Map<String, String> config)
        throws Exception {
        final JsonObjectBuilder builder = Json.createObjectBuilder();
        for (final Map.Entry<String, String> entry : config.entrySet()) {
            builder.add(entry.getKey(), entry.getValue());
        }
        return Json.createObjectBuilder()
            .add("id", 1)
            .add("name", name)
            .add("config", builder)
View Full Code Here

    public JsonObject getApplicationContainerStatistics(String applicationName) {
        return collector.fetchApplicationStatistics(applicationName);
    }

    public JsonObject getBeanStatistics(String applicationName) {
        JsonObjectBuilder builder = Json.createObjectBuilder();
        JsonObject components = collector.fetchApplicationComponents(applicationName);
        Set<Map.Entry<String, JsonValue>> entrySet = components.entrySet();
        for (Map.Entry<String, JsonValue> entry : entrySet) {
            String beanName = entry.getKey();
            if (!"server".equals(beanName)) {
                final JsonObject beanStatistics = getBeanStatistics(applicationName, beanName);
                if (beanName == null || beanStatistics == null) {
                    LOG.info("!!!NULL -> Beanname: " + beanName + " -> " + beanStatistics);
                } else {
                    builder.add(beanName, beanStatistics);
                }
            }
        }
        return builder.build();
    }
View Full Code Here

        }
        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

    @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

    }

    @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

TOP

Related Classes of javax.json.JsonObjectBuilder$JsonObjectImpl

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.