Example usage for com.google.gson JsonElement getAsString

List of usage examples for com.google.gson JsonElement getAsString

Introduction

In this page you can find the example usage for com.google.gson JsonElement getAsString.

Prototype

public String getAsString() 

Source Link

Document

convenience method to get this element as a string value.

Usage

From source file:com.luorrak.ouroboros.api.JsonParser.java

License:Open Source License

public String getThreadLastModified(JsonObject threadJson) {
    JsonElement lastModified = threadJson.get(THREAD_LAST_MODIFIED);
    return lastModified != null ? lastModified.getAsString() : null;
}

From source file:com.luorrak.ouroboros.api.JsonParser.java

License:Open Source License

public String getThreadId(JsonObject threadJson) {
    JsonElement id = threadJson.get(THREAD_ID);
    return id != null ? id.getAsString() : null;
}

From source file:com.luorrak.ouroboros.api.JsonParser.java

License:Open Source License

public String getThreadEmbed(JsonObject threadJson) {
    JsonElement embed = threadJson.get(THREAD_EMBED);
    return embed != null ? embed.getAsString() : null;
}

From source file:com.luorrak.ouroboros.api.JsonParser.java

License:Open Source License

private String getThreadImageHeight(JsonObject threadJson) {
    JsonElement imageHeight = threadJson.get(THREAD_IMAGE_HEIGHT);
    return imageHeight != null ? imageHeight.getAsString() : "0";
}

From source file:com.luorrak.ouroboros.api.JsonParser.java

License:Open Source License

private String getThreadImageWidth(JsonObject threadJson) {
    JsonElement imageWidth = threadJson.get(THREAD_IMAGE_WIDTH);
    return imageWidth != null ? imageWidth.getAsString() : "0";
}

From source file:com.luorrak.ouroboros.api.JsonParser.java

License:Open Source License

public String getSubmittedBoardName(JsonObject responseJson) {
    JsonElement redirect = responseJson.get(RESPONSE_REDIRECT_URL); // \/test\/res\/1234.html#4321
    String boardName = redirect.getAsString().split("/")[1];
    return boardName;
}

From source file:com.luorrak.ouroboros.api.JsonParser.java

License:Open Source License

public String getUserPostNo(JsonObject responseJson) {
    JsonElement id = responseJson.get(RESPONSE_NO); // \/test\/res\/1234.html#4321
    String userPostNo = id.getAsString();
    return userPostNo;
}

From source file:com.luorrak.ouroboros.util.NetworkHelper.java

License:Open Source License

private String captchaTest(JsonObject jsonObject) {
    JsonElement error = jsonObject.get("error");

    if (error == null) {
        return null;
    } else if (error.getAsString().contains("dnsbls_bypass.php")) {
        needDNSBLCaptcha = true;/*  ww w . ja va2s  .c  om*/
        return "needDNSBLCaptcha";
    } else if (error.getAsString().contains("entrypoint.php")) {
        genericCaptcha = true;
        return "Captcha";
    } else {
        return null;
    }
}

From source file:com.mapper.yelp.YelpQueryManager.java

License:Apache License

public void parseBusinessTag(YelpBusiness business, JsonElement element) {
    for (final Entry<String, JsonElement> entry : element.getAsJsonObject().entrySet()) {
        final String key = entry.getKey();
        final JsonElement value = entry.getValue();

        if (key.contains(DISPLAY_PHONE_TAG)) {
            business.setPhoneNumber(value.getAsString());
        } else if (key.contains(LOCATION_TAG)) {
            // Location
            for (final Entry<String, JsonElement> centry : value.getAsJsonObject().entrySet()) {
                final String k1 = centry.getKey();
                final JsonElement v1 = centry.getValue();

                if (k1.contains(ADDRESS_TAG)) {
                    String address = "";
                    for (final JsonElement e2 : v1.getAsJsonArray()) {
                        address += e2.getAsString() + " ";
                    }//from w w w  .j a va2s.  c o  m

                    business.setAddress(address);
                } else if (k1.contains(COORDINATE_TAG)) {
                    for (final Entry<String, JsonElement> loc : v1.getAsJsonObject().entrySet()) {
                        if (loc.getKey().contains(LATITUDE_TAG))
                            business.setLatitude(loc.getValue().getAsDouble());
                        else if (loc.getKey().contains(LONGITUDE_TAG))
                            business.setLongitude(loc.getValue().getAsDouble());
                    }
                } else if (k1.contains(CITY_TAG)) {
                    business.setCity(v1.getAsString());
                } else if (k1.contains(POSTAL_CODE_TAG)) {
                    business.setPostalCode(v1.getAsInt());
                } else if (k1.contains(STATE_TAG)) {
                    business.setState(v1.getAsString());
                }
            }
        } else if (key.contains(RATING_IMG_TAG)) {
            business.setRatingUrl(value.getAsString());
        } else if (key.contains(REVIEW_TAG)) {
            business.setReviewCount(value.getAsInt());
        } else if (key.contains(URL_TAG)) {
            business.setUrl(value.getAsString());
        } else if (key.contains(NAME_TAG)) {
            business.setName(value.getAsString());
        } else if (key.contains(IMAGE_URL_TAG)) {
            business.setImageUrl(value.getAsString());
        }
    }
}

From source file:com.mastertheboss.jmsbrowser.EJBBrowser.java

public List<QueueDTO> getListQueues() {

    String host = properties.getProperty("host");
    int port = Integer.parseInt(properties.getProperty("port"));
    System.out.println("PORT---->" + port);
    final ModelNode req = new ModelNode();
    req.get(ClientConstants.OP).set("read-children-resources");
    req.get("child-type").set("jms-queue");

    String mode = properties.getProperty("mode");
    if (mode.equals("domain")) {
        req.get(ClientConstants.OP_ADDR).add("profile", properties.getProperty("profile"));
    }//w  ww  . j  a v a  2s. co m
    req.get(ClientConstants.OP_ADDR).add("subsystem", "messaging");
    req.get(ClientConstants.OP_ADDR).add("hornetq-server", "default");

    ModelControllerClient client = null;
    List<QueueDTO> listQueues = new ArrayList();

    try {
        client = ModelControllerClient.Factory.create(InetAddress.getByName(host), port);
        final ModelNode resp = client.execute(new OperationBuilder(req).build());

        List<ModelNode> list = resp.get(ClientConstants.RESULT).asList();

        for (ModelNode node : list) {

            String json = node.toJSONString(true);
            JsonObject res = new JsonParser().parse(json).getAsJsonObject();
            Set<Map.Entry<String, JsonElement>> es = res.entrySet();
            for (Map.Entry<String, JsonElement> entry : es) {
                QueueDTO queue = new QueueDTO();
                queue.setName(entry.getKey());

                JsonElement element = entry.getValue();
                JsonObject obj = element.getAsJsonObject();
                JsonElement binding = obj.get("entries");
                queue.setEntry(binding.getAsString());

                listQueues.add(queue);
            }
        }

    } catch (Exception exc) {
        exc.printStackTrace();
    }
    return listQueues;
}