List of usage examples for org.apache.commons.lang3 StringUtils isNotEmpty
public static boolean isNotEmpty(final CharSequence cs)
Checks if a CharSequence is not empty ("") and not null.
StringUtils.isNotEmpty(null) = false StringUtils.isNotEmpty("") = false StringUtils.isNotEmpty(" ") = true StringUtils.isNotEmpty("bob") = true StringUtils.isNotEmpty(" bob ") = true
From source file:com.inkubator.hrm.dao.impl.LoanCanceledDaoImpl.java
private void doSearchByParam(LoanCanceledSearchParameter searchParameter, Criteria criteria) { if (StringUtils.isNotEmpty(searchParameter.getLoanSchema())) { criteria.createAlias("loanSchema", "loanSchema", JoinType.INNER_JOIN); criteria.add(Restrictions.like("loanSchema.name", searchParameter.getLoanSchema(), MatchMode.ANYWHERE)); }/*from w ww.j a v a 2 s . c om*/ if (StringUtils.isNotEmpty(searchParameter.getEmployee())) { criteria.createAlias("empData", "empData", JoinType.INNER_JOIN); criteria.createAlias("empData.bioData", "bioData", JoinType.INNER_JOIN); Disjunction disjunction = Restrictions.disjunction(); disjunction.add(Restrictions.like("empData.nik", searchParameter.getEmployee(), MatchMode.ANYWHERE)); disjunction .add(Restrictions.like("bioData.firstName", searchParameter.getEmployee(), MatchMode.ANYWHERE)); disjunction .add(Restrictions.like("bioData.lastName", searchParameter.getEmployee(), MatchMode.ANYWHERE)); criteria.add(disjunction); } criteria.add(Restrictions.isNotNull("id")); }
From source file:com.glaf.core.util.JsonUtils.java
public static Map<String, Object> decode(String str) { Map<String, Object> dataMap = new LinkedHashMap<String, Object>(); if (StringUtils.isNotEmpty(str) && (str.length() > 0 && str.charAt(0) == '{') && str.endsWith("}")) { try {// w ww . j a v a2s . c o m JSONObject jsonObject = (JSONObject) JSON.parse(str); Iterator<Entry<String, Object>> iterator = jsonObject.entrySet().iterator(); while (iterator.hasNext()) { Entry<String, Object> entry = iterator.next(); String key = (String) entry.getKey(); Object value = entry.getValue(); if (value != null) { if (value instanceof Object[]) { Object[] array = (Object[]) value; Collection<Object> collection = new java.util.ArrayList<Object>(); for (int i = 0; i < array.length; i++) { collection.add(array[i]); } dataMap.put(key, collection); } else if (value instanceof JSONArray) { JSONArray array = (JSONArray) value; Collection<Object> collection = new java.util.ArrayList<Object>(); for (int i = 0, len = array.size(); i < len; i++) { collection.add(array.get(i)); } dataMap.put(key, collection); } else if (value instanceof Collection<?>) { Collection<?> collection = (Collection<?>) value; dataMap.put(key, collection); } else if (value instanceof Map<?, ?>) { Map<?, ?> map = (Map<?, ?>) value; dataMap.put(key, map); } else { if ((!key.startsWith("x_filter_")) && key.toLowerCase().endsWith("date")) { String datetime = value.toString(); try { java.util.Date date = DateUtils.toDate(datetime); dataMap.put(key, date); } catch (Exception ex) { ex.printStackTrace(); dataMap.put(key, value); } } else { dataMap.put(key, value); } } } } } catch (JSONException ex) { ex.printStackTrace(); } } return dataMap; }
From source file:architecture.ee.web.community.struts2.action.SocialConnectAction.java
public String execute() throws Exception { HttpSession session = request.getSession(true); if (StringUtils.isNotEmpty(domainName)) { String domainNameInSession = (String) session.getAttribute(DOMAIN_NAME_KEY); log.debug("domainName: " + domainName); log.debug("domainNameInSession: " + domainNameInSession); log.debug(StringUtils.equals(domainName, domainNameInSession)); if (!StringUtils.equals(domainName, domainNameInSession)) { session.setAttribute(DOMAIN_NAME_KEY, domainName); }/* ww w . jav a2 s . c om*/ } Enumeration names = session.getAttributeNames(); while (names.hasMoreElements()) { String key = (String) names.nextElement(); Object value = session.getAttribute(key); log.debug(key + "=" + value); } return success(); }
From source file:com.github.htfv.utils.el.internal.StringFunctions.java
/** * Joins array of strings with a separator, ignoring any empty and * {@code null} strings.//from w ww.j a v a 2 s.co m * * @param separator * the separator string to use. * @param strings * the array of strings to join. * * @return the joined string. */ public static String join(final String separator, final String... strings) { final StringBuilder joinedString = new StringBuilder(); final int stringCount = strings.length; int i = 0; for (; i < stringCount; i += 1) { final String string = strings[i]; if (StringUtils.isNotEmpty(string)) { joinedString.append(string); break; } } for (i += 1; i < stringCount; i += 1) { final String string = strings[i]; if (StringUtils.isNotEmpty(string)) { joinedString.append(separator).append(string); } } return joinedString.toString(); }
From source file:com.opensymphony.xwork2.validator.validators.AbstractRangeValidator.java
public T getMin() { if (min != null) { return min; } else if (StringUtils.isNotEmpty(minExpression)) { return (T) parse(minExpression, type); } else {/*from w w w. j a v a2 s . co m*/ return null; } }
From source file:alfio.controller.api.admin.SpecialPriceApiController.java
@RequestMapping(value = "/events/{eventName}/categories/{categoryId}/link-codes") public List<SendCodeModification> linkAssigneeToCodes(@PathVariable("eventName") String eventName, @PathVariable("categoryId") int categoryId, @RequestBody UploadBase64FileModification file, Principal principal) throws IOException { Validate.isTrue(StringUtils.isNotEmpty(eventName)); try (InputStreamReader isr = new InputStreamReader(file.getInputStream()); CSVReader reader = new CSVReader(isr)) { List<SendCodeModification> content = reader.readAll().stream().map(line -> { Validate.isTrue(line.length >= 4); return new SendCodeModification(StringUtils.trimToNull(line[0]), trim(line[1]), trim(line[2]), trim(line[3]));/*from w ww .jav a 2s . c o m*/ }).collect(Collectors.toList()); return specialPriceManager.linkAssigneeToCode(content, eventName, categoryId, principal.getName()); } }
From source file:architecture.ee.web.community.struts2.action.PageAction.java
public String display() throws Exception { Page pageToUse = getTargetPage();//from ww w . j av a2s. co m if (pageToUse.getPageState() != PageState.PUBLISHED) { return NOT_FOUND; } if (StringUtils.isNotEmpty(pageToUse.getProperty("template", null))) { setTemplate(pageToUse.getProperty("template", null)); } return success(); }
From source file:com.funtl.framework.smoke.core.modules.act.utils.DateConverter.java
/** * Convert String to Date/*w w w.j a v a 2s .c o m*/ * * @param value * @return * @throws ParseException */ private Date doConvertToDate(Object value) throws ParseException { Date result = null; if (value instanceof String) { result = DateUtils.parseDate((String) value, new String[] { DATE_PATTERN, DATETIME_PATTERN, DATETIME_PATTERN_NO_SECOND, MONTH_PATTERN }); // all patterns failed, try a milliseconds constructor if (result == null && StringUtils.isNotEmpty((String) value)) { try { result = new Date(new Long((String) value).longValue()); } catch (Exception e) { logger.error("Converting from milliseconds to Date fails!"); e.printStackTrace(); } } } else if (value instanceof Object[]) { // let's try to convert the first element only Object[] array = (Object[]) value; if (array.length >= 1) { value = array[0]; result = doConvertToDate(value); } } else if (Date.class.isAssignableFrom(value.getClass())) { result = (Date) value; } return result; }
From source file:de.inetsource.jsfforum.beans.PostBean.java
@PostConstruct public void init() { Map<String, String> parameter = FacesContext.getCurrentInstance().getExternalContext() .getRequestParameterMap();//from ww w.ja v a2 s. com if (StringUtils.isNotEmpty(parameter.get("threadId"))) { threadId = Integer.valueOf(parameter.get("threadId")); thread = threadFacade.find(threadId); lazyModel = new LazyPostDataModel(thread, postFacade, StringUtils.isNotEmpty(parameter.get("lastPost"))); } newPost = new Post(); }