当前位置: 首页>>代码示例>>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;未经允许,请勿转载。