當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectNode.has方法代碼示例

本文整理匯總了Java中org.codehaus.jackson.node.ObjectNode.has方法的典型用法代碼示例。如果您正苦於以下問題:Java ObjectNode.has方法的具體用法?Java ObjectNode.has怎麽用?Java ObjectNode.has使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.codehaus.jackson.node.ObjectNode的用法示例。


在下文中一共展示了ObjectNode.has方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCriteria

import org.codehaus.jackson.node.ObjectNode; //導入方法依賴的package包/類
public static Criteria getCriteria(ObjectNode rudeCriteria) throws Exception {
    Criteria criteria = new Criteria();
    if (rudeCriteria.has("criterions")) {
        ArrayNode criterions = (ArrayNode) rudeCriteria.get("criterions");
        if (criterions != null) {
            for (Iterator<JsonNode> it = criterions.iterator(); it.hasNext();) {
                criteria.addCriterion(parseCriterion((ObjectNode) it.next()));
            }
        }
    }

    if (rudeCriteria.has("orders")) {
        ArrayNode orders = (ArrayNode) rudeCriteria.get("orders");
        if (orders != null) {
            for (Iterator<JsonNode> it = orders.iterator(); it.hasNext();) {
                ObjectNode rudeCriterion = (ObjectNode) it.next();
                Order order = new Order(JsonUtils.getString(rudeCriterion, "property"), JsonUtils.getBoolean(rudeCriterion, "desc"));
                criteria.addOrder(order);
            }
        }
    }
    return criteria;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:24,代碼來源:CriterionUtils.java

示例2: extractUserData

import org.codehaus.jackson.node.ObjectNode; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
protected void extractUserData(ObjectNode jsonUser, ExternalUserVO userVO)
        throws AuthenticationServiceException {
    assertFieldsExist(jsonUser, JSON_PARAM_LOGIN, JSON_PARAM_EMAIL, JSON_PARAM_LAST_NAME,
            JSON_PARAM_FIRST_NAME);
    userVO.setExternalUserName(jsonUser.get(JSON_PARAM_LOGIN).asText());
    userVO.setEmail(jsonUser.get(JSON_PARAM_EMAIL).asText());
    userVO.setLastName(jsonUser.get(JSON_PARAM_LAST_NAME).asText());
    userVO.setFirstName(jsonUser.get(JSON_PARAM_FIRST_NAME).asText());
    if (jsonUser.has(JSON_PARAM_LANG)) {
        String lang = jsonUser.get(JSON_PARAM_LANG).asText();
        Locale locale = new Locale(lang);
        userVO.setDefaultLanguage(locale);
    }
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:19,代碼來源:ConfluenceAuthenticator.java

示例3: userValidation

import org.codehaus.jackson.node.ObjectNode; //導入方法依賴的package包/類
@PUT
@Path("/validate")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Response userValidation(User userData) {
    try {
        int flag = 0;
        String emailRcvd = "";

        final ObjectNode node = new ObjectMapper().readValue(userData.toString(), ObjectNode.class);

        if (node.has("email")) {
            emailRcvd = node.get("email").toString().replace("\"", "").trim();
        }

        ResultSet rs = dbobj.openConnection("select email from user");
        while (rs.next()) {
            String userEmail = rs.getString("email");
            if (emailRcvd.equals(userEmail)) {
                flag = 1;
                break;
            }
        }
        if (flag == 1) {
            resp.put("response", "false");
            return Response.ok(resp.toJSONString()).build();
        }
        dbobj.closeConnection(rs);
    } catch (SQLException | IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    resp.put("response", "true");
    return Response.ok(resp.toJSONString()).build();
}
 
開發者ID:akhildabral,項目名稱:SHIKSHAK,代碼行數:37,代碼來源:SignupService.java

示例4: assertFieldsExist

import org.codehaus.jackson.node.ObjectNode; //導入方法依賴的package包/類
/**
 * Test whether a provided JSON object has all the given members and throw an exception if not.
 *
 * @param jsonNode
 *            the JSON object
 * @param fieldNames
 *            the names of the members the object has to have
 * @throws AuthenticationServiceException
 *             in case one of the fields is missing
 */
protected void assertFieldsExist(ObjectNode jsonNode, String... fieldNames) {
    for (String fieldName : fieldNames) {
        if (!jsonNode.has(fieldName)) {
            throw new AuthenticationServiceException(
                    "JSON response is missing field " + fieldName);
        }
    }
}
 
開發者ID:Communote,項目名稱:communote-server,代碼行數:19,代碼來源:ExternalKenmeiApiAuthenticator.java


注:本文中的org.codehaus.jackson.node.ObjectNode.has方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。