List of usage examples for org.apache.commons.lang3 StringUtils isBlank
public static boolean isBlank(final CharSequence cs)
Checks if a CharSequence is whitespace, empty ("") or null.
StringUtils.isBlank(null) = true StringUtils.isBlank("") = true StringUtils.isBlank(" ") = true StringUtils.isBlank("bob") = false StringUtils.isBlank(" bob ") = false
From source file:learningresourcefinder.web.Slugify.java
private static String removeDuplicateWhiteSpaces(String input) { String ret = StringUtils.trim(input); if (StringUtils.isBlank(ret)) { return ""; }/*from w w w. j a v a 2 s. c om*/ return ret.replaceAll("\\s+", " "); }
From source file:me.repository.office.OfficeDao.java
public Page<Office> findOffices(Page<Office> pageObj, Office office) { DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Office.class); if (!StringUtils.isBlank(office.getName())) { detachedCriteria.add(Restrictions.like("name", "%" + office.getName() + "%")); }//from w ww . j a v a2 s . c o m if (!StringUtils.isBlank(office.getOfficeCode())) { detachedCriteria.add(Restrictions.like("officeCode", "%" + office.getOfficeCode() + "%")); } detachedCriteria.add(Restrictions.isNotNull("parentId"));// // detachedCriteria.add(Restrictions.isNotNull("parent.id"));// return find(pageObj, detachedCriteria); }
From source file:com.creditcloud.ump.model.ump.utils.UmpUtils.java
public static List<UmpSeqTransaction> parseSeqTrans(String transDetail) { List<UmpSeqTransaction> transList = new ArrayList<>(); if (StringUtils.isBlank(transDetail)) { return transList; }/*from ww w . jav a2s . c om*/ String[] transStrArray = StringUtils.split(transDetail, '|'); for (String transStr : transStrArray) { String[] fieldStrArray = transStr.split(","); Map<String, String> values = new HashMap<String, String>(); for (String fieldStr : fieldStrArray) { String[] pair = fieldStr.split("="); if (pair.length != 2) { logger.log(Level.WARNING, "cannot parse transaction field string:" + fieldStr + ", ignore"); continue; } else { values.put(pair[0], pair[1]); } } UmpSeqTransaction trans = new UmpSeqTransaction(); trans.setAccCheckDate(values.get("acc_check_date")); trans.setAmount(fromCents(values.get("amount"))); trans.setComAmt( values.get("com_amt") != null ? fromCents(values.get("com_amt")).setScale(2) : BigDecimal.ZERO); trans.setDcMark(UmpSeqCashFlow.getEnum(values.get("dc_mark"))); trans.setTransType(UmpBusiType.getEnum(values.get("trans_type"))); trans.setTransState(UmpSeqTransStatus.getEnum(values.get("trans_state"))); transList.add(trans); } return transList; }
From source file:de.pixida.logtest.engine.EmbeddedScript.java
public EmbeddedScript(final String aScript) { this.script = aScript; this.exists = !StringUtils.isBlank(this.script); }
From source file:io.lavagna.model.util.ShortNameGenerator.java
/** * <p>//from w w w. j a v a 2s.c o m * Generate a short name given the full project name. * * Total length returned is equal or less than 8. * </p> * * <p> * Heuristic: * </p> * <ul> * <li>if name is less or equals than 6 chars and is a single word, the short name will be UPPER(name)</li> * <li>if the project has multiple words, it will concatenate each words. If a word has a length more than 4: * <ul> * <li>it will take only the upper case characters if there are more than 1.</li> * <li>else it will take the first two characters.</li> * </ul> * </li> * </ul> * * @param name * @return */ public static String generateShortNameFrom(String name) { if (StringUtils.isBlank(name)) { return name; } String t = name.trim().replace("-", ""); String[] splitted = t.split("\\s+"); if (splitted.length == 1) { return splitted[0].substring(0, Math.min(6, splitted[0].length())).toUpperCase(Locale.ENGLISH); } StringBuilder sb = new StringBuilder(); for (String token : splitted) { if (token.length() <= 4) { sb.append(token); } else if (countUpperCase(token) > 1) { sb.append(takeFirstFourUpperCaseChars(token)); } else { sb.append(token.substring(0, 3)); } } return sb.toString().toUpperCase(Locale.ENGLISH).substring(0, Math.min(8, sb.length())); }
From source file:com.netsteadfast.greenstep.base.service.logic.BscBaseLogicServiceCommonSupport.java
public static OrganizationVO findOrganizationData( IOrganizationService<OrganizationVO, BbOrganization, String> service, String oid) throws ServiceException, Exception { if (StringUtils.isBlank(oid)) { throw new ServiceException(SysMessageUtil.get(GreenStepSysMsgConstants.PARAMS_BLANK)); }/*from w w w .ja v a2s. c o m*/ OrganizationVO organization = new OrganizationVO(); organization.setOid(oid); DefaultResult<OrganizationVO> orgResult = service.findObjectByOid(organization); if (orgResult.getValue() == null) { throw new ServiceException(orgResult.getSystemMessage().getValue()); } organization = orgResult.getValue(); return organization; }
From source file:com.ewcms.publication.freemarker.directive.page.skip.LastSkip.java
@Override public PageOut skip(Integer count, Integer number, String label, UriRuleable uriRule, Map<String, Object> uriParams) throws PublishException { label = StringUtils.isBlank(label) ? DEFAULT_LABEL : label; int last = count - 1; boolean active = (number != last); String url = uriRule.uri(putPageParam(uriParams, last)); return new PageOut(count, last, label, url, active); }
From source file:com.ewcms.publication.freemarker.directive.page.skip.FirstSkip.java
@Override public PageOut skip(Integer count, Integer number, String label, UriRuleable uriRule, Map<String, Object> uriParams) throws PublishException { label = StringUtils.isBlank(label) ? DEFAULT_LABEL : label; int first = 0; boolean active = (number != first); String url = uriRule.uri(putPageParam(uriParams, first)); return new PageOut(count, first, label, url, active); }
From source file:com.fengduo.bee.commons.core.lang.Argument.java
public static boolean isBlank(String argument) { return StringUtils.isBlank(argument); }
From source file:lolthx.autohome.buy.AutohomePriceListFetch.java
@Override public void parse(String result, Task task) throws Exception { if (StringUtils.isBlank(result)) { return;/*from w w w .j ava 2s .co m*/ } Date start = task.getStartDate(); Date end = task.getEndDate(); Document doc = Jsoup.parse(result); Elements lis = doc.select("li.price-item"); AutohomePriceInfoBean bean = new AutohomePriceInfoBean(); for (Element li : lis) { try { Elements postTimeEl = li.select("div.user-name span"); String postTime = ""; if (!postTimeEl.isEmpty()) { postTime = StringUtils.trim( StringUtils.substringBefore(postTimeEl.first().text(), "?").replaceAll("", "")); if (!isTime(postTime, start, end)) { continue; } } bean.setPostTime(postTime); bean.setUrl(task.getUrl()); bean.setForumId(StringUtils.substringBefore(task.getExtra(), ":")); bean.setProjectName(task.getProjectName()); bean.setKeyword(StringUtils.substringAfter(task.getExtra(), ":")); // post id Elements id = li.select("div.price-share a.share"); if (!id.isEmpty()) { String idStr = id.first().attr("data-target"); idStr = StringUtils.substringAfterLast(idStr, "_"); if (StringUtils.isBlank(idStr)) { continue; } bean.setId(idStr); } // Elements user = li.select("div.user-name a"); if (!user.isEmpty()) { String userUrl = user.first().absUrl("href"); String userId = StringUtils.substringAfterLast(userUrl, "/"); String userName = user.first().text(); bean.setUserId(userId); bean.setUserUrl(userUrl); bean.setUserName(userName); } Elements dataLis = li.select("div.price-item-bd li"); for (Element dataLi : dataLis) { String data = dataLi.text(); if (StringUtils.startsWith(data, "")) { bean.setCar(StringUtils.trim(StringUtils.substringAfter(data, ""))); } if (StringUtils.startsWith(data, "")) { bean.setPrice(StringUtils.trim(StringUtils.substringAfter(data, ""))); } if (StringUtils.startsWith(data, "")) { bean.setGuidePrice(StringUtils.trim(StringUtils.substringAfter(data, ""))); } if (StringUtils.startsWith(data, "?")) { bean.setTotalPrice(StringUtils.trim(StringUtils.substringAfter(data, ""))); } if (StringUtils.startsWith(data, "")) { bean.setPurchaseTax(StringUtils.trim(StringUtils.substringAfter(data, ""))); } if (StringUtils.startsWith(data, "?")) { bean.setCommercialInsurance(StringUtils.trim(StringUtils.substringAfter(data, ""))); } if (StringUtils.startsWith(data, "")) { bean.setVehicleUseTax(StringUtils.trim(StringUtils.substringAfter(data, ""))); } if (StringUtils.startsWith(data, "")) { bean.setCompulsoryInsurance(StringUtils.trim(StringUtils.substringAfter(data, ""))); } if (StringUtils.startsWith(data, "")) { bean.setLicenseFee(StringUtils.trim(StringUtils.substringAfter(data, ""))); } if (StringUtils.startsWith(data, "?")) { bean.setPromotion(StringUtils.trim(StringUtils.substringAfter(data, ""))); } if (StringUtils.startsWith(data, "")) { bean.setBuyTime(StringUtils.trim(StringUtils.substringAfter(data, ""))); } if (StringUtils.startsWith(data, "")) { String area = StringUtils.trim(StringUtils.substringAfter(data, "")); String[] pAndC = StringUtils.splitByWholeSeparator(area, ",", 2); if (pAndC.length == 1) { bean.setBuyProvince(pAndC[0]); bean.setBuyCity(pAndC[0]); } if (pAndC.length == 2) { bean.setBuyProvince(pAndC[0]); bean.setBuyCity(pAndC[1]); } } if (StringUtils.startsWith(data, "")) { Elements level = dataLi.select("span.level"); // if (!level.isEmpty()) { bean.setSellerComment(level.first().text()); } // ? Elements seller = dataLi.select("a.title"); if (!seller.isEmpty()) { String sellerUrl = seller.first().absUrl("href"); String sellerName = seller.first().text(); String sellerId = StringUtils.substringAfterLast(sellerUrl, "/"); bean.setSellerId(sellerId); bean.setSellerName(sellerName); bean.setSellerUrl(sellerUrl); } // ? Elements sellerPhone = dataLi.select("em.phone-num"); if (!sellerPhone.isEmpty()) { bean.setSellerPhone(sellerPhone.first().text()); } // ? // Elements sellerAddress = // dataLi.select("em.phone-num"); } if (StringUtils.startsWith(data, "?")) { bean.setBuyFeeling(StringUtils.trim(StringUtils.substringAfter(data, ""))); } } bean.saveOnNotExist(); } catch (Exception e) { e.printStackTrace(); continue; } } }