Java Code Examples for org.apache.commons.lang3.StringUtils.isAnyEmpty()

The following are Jave code examples for showing how to use isAnyEmpty() of the org.apache.commons.lang3.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: azeroth   File: HttpUtils.java   View Source Code Vote up 7 votes
public static String buildQuery(Map<String, String> params, String charset) throws IOException {
    if (params == null || params.isEmpty()) {
        return null;
    }

    StringBuilder query = new StringBuilder();
    Set<Entry<String, String>> entries = params.entrySet();
    boolean hasParam = false;

    for (Entry<String, String> entry : entries) {
        String name = entry.getKey();
        String value = entry.getValue();
        // 忽略参数名或参数值为空的参数
        if (StringUtils.isAnyEmpty(name, value)) {
            if (hasParam) {
                query.append("&");
            } else {
                hasParam = true;
            }

            query.append(name).append("=").append(URLEncoder.encode(value, charset));
        }
    }

    return query.toString();
}
 
Example 2
Project: azeroth   File: HttpUtils.java   View Source Code Vote up 6 votes
public static String buildQuery(Map<String, String> params, String charset) throws IOException {
    if (params == null || params.isEmpty()) {
        return null;
    }

    StringBuilder query = new StringBuilder();
    Set<Entry<String, String>> entries = params.entrySet();
    boolean hasParam = false;

    for (Entry<String, String> entry : entries) {
        String name = entry.getKey();
        String value = entry.getValue();
        // 忽略参数名或参数值为空的参数
        if (StringUtils.isAnyEmpty(name, value)) {
            if (hasParam) {
                query.append("&");
            } else {
                hasParam = true;
            }

            query.append(name).append("=").append(URLEncoder.encode(value, charset));
        }
    }

    return query.toString();
}
 
Example 3
Project: dooo   File: IndexController.java   View Source Code Vote up 6 votes
@RequestMapping(value = "login", method = RequestMethod.POST)
@ResponseBody
public ReturnT<String> loginDo(HttpServletRequest request, HttpServletResponse response, @RequestParam("user") String user) {
    if (!PermissionInterceptor.ifLogin(request)) {
        if (StringUtils.isAnyEmpty(user)) {
            return ReturnT.FAIL;
        }
        JSONObject jsonObject = JSONObject.parseObject(user);
        UserAuthDO user1 = JSONObject.toJavaObject(jsonObject, UserAuthDO.class);
        User user2 = userService.getByName(user1.getName());
        if (user2 != null) {
            if (user2.getPass().equals(user1.getPass())) {
                PermissionInterceptor.login(response, user2);
                return ReturnT.SUCCESS;
            }
            return ReturnT.FAIL;
        }
    }
    return ReturnT.FAIL;
}
 
Example 4
Project: buenojo   File: TagPoolCSVParser.java   View Source Code Vote up 5 votes
private List<TagPool> createTagPool(CSVParser parser) throws BuenOjoCSVParserException{
	ArrayList<TagPool> list = new ArrayList<>();
	for (CSVRecord record : parser) {
		String name = record.get(TagPoolColumn.TAG.ordinal()).toString();

     	Tag tag = tagMap.get(name);
     	

     	for (int i = TagPoolColumn.SIMILAR_1.ordinal(); (i <record.size()) && i <= TagPoolColumn.SIMILAR_3.ordinal(); i++) {
     		String similarTagName = record.get(i);
     		if (similarTagName != null && !StringUtils.isAnyEmpty(similarTagName)){
     			Tag similarTag = tagMap.get(similarTagName);
     			
     			if (similarTag != null){
	     			TagPool tagPool = new TagPool();
	     			tagPool.setTag(tag);
	     			tagPool.setSimilarTag(similarTag);
	     			tagPool.setSimilarity(i);
	     			list.add(tagPool);
     			} else {
     				throw new BuenOjoCSVParserException("no se pudo obtener la etiqueta con nombre: '"+similarTagName+"'");
     			}
     		}
     	}
	}
	return list;
	
}