List of usage examples for org.apache.commons.lang3 StringUtils trim
public static String trim(final String str)
Removes control characters (char <= 32) from both ends of this String, handling null by returning null .
The String is trimmed using String#trim() .
From source file:io.wcm.wcm.parsys.controller.CssBuilder.java
/** * Add CSS class item. Empty/Null items are ignore.d * @param cssClass Item//from w w w . j ava2 s. com */ public void add(String cssClass) { if (StringUtils.isBlank(cssClass)) { return; } String[] parts = StringUtils.split(cssClass, " "); for (String part : parts) { items.add(StringUtils.trim(part)); } }
From source file:com.thinkbiganalytics.policy.standardization.TrimStandardizer.java
@Override public String convertValue(String value) { return StringUtils.trim(value.toString()); }
From source file:com.cognifide.qa.bb.utils.PropertyUtils.java
/** * This util method gather system and class path properties, and returns them as <code>Properties</code> * object./*from w ww . j av a 2 s . com*/ * * @return Properties - object with all properties. */ public static Properties gatherProperties() { if (properties == null) { try { String parents = System.getProperty(ConfigKeys.CONFIGURATION_PATHS, "src/main/config"); String[] split = StringUtils.split(parents, ";"); properties = loadDefaultProperties(); for (String name : split) { File configParent = new File(StringUtils.trim(name)); loadProperties(configParent, properties); } overrideFromSystemProperties(properties); setSystemProperties(properties); overrideTimeouts(properties); } catch (IOException e) { LOG.error("Can't bind properties", e); } } return properties; }
From source file:de.micromata.genome.gwiki.jetty.CmdLineInput.java
public static boolean ask(String message, boolean defaultYes) { System.out.println(message);//from w ww . java 2 s .co m do { if (defaultYes == true) { System.out.print("([Yes]/No): "); } else { System.out.print("(Yes/[No]): "); } String inp = StringUtils.trim(readLine()); inp = inp.toLowerCase(); if (StringUtils.isEmpty(inp) == true) { return defaultYes; } if (inp.equalsIgnoreCase("y") == true || inp.equalsIgnoreCase("yes") == true) { return true; } if (inp.equalsIgnoreCase("n") == true || inp.equalsIgnoreCase("no") == true) { return false; } } while (true); }
From source file:com.fdorigo.rmfly.jpa.session.RecordFacade.java
public Record buildFromMaster(String id) { Record newRecord = em.find(Record.class, id); if (newRecord == null) { newRecord = new Record(id); final Master faaMasterRecord = em.find(Master.class, id); if (faaMasterRecord != null) { newRecord.setLastName(WordUtils.capitalizeFully(StringUtils.trim(faaMasterRecord.getName()))); newRecord.setAddressCity(WordUtils.capitalizeFully(StringUtils.trim(faaMasterRecord.getCity()))); newRecord.setAddressOne(WordUtils.capitalizeFully(StringUtils.trim(faaMasterRecord.getStreet()))); newRecord.setAddressTwo(WordUtils.capitalizeFully(StringUtils.trim(faaMasterRecord.getStreet2()))); newRecord.setAddressState(WordUtils.capitalizeFully(StringUtils.trim(faaMasterRecord.getState()))); newRecord.setAddressZip(StringUtils.trim(faaMasterRecord.getZip())); final Acftref faaAircraftRecord = em.find(Acftref.class, faaMasterRecord.getMfrmdlcode()); if (faaAircraftRecord != null) { newRecord.setAirplaneModel(WordUtils.capitalizeFully(faaAircraftRecord.getModel())); newRecord.setAirplaneMake(WordUtils.capitalizeFully(faaAircraftRecord.getMfrname())); }/* w w w . j a v a2 s. c o m*/ } } return newRecord; }
From source file:lolthx.autohome.buy.AutohomePriceListFetch.java
@Override public void parse(String result, Task task) throws Exception { if (StringUtils.isBlank(result)) { return;/* www . j a v a2s .c o 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; } } }
From source file:com.qcadoo.model.api.IntegerUtils.java
/** * Parse integer value from string./* ww w. ja v a 2 s .c o m*/ * * @param stringValue * value to be parsed * @return parsed integer number or null if given string is empty or blank * @throws NumberFormatException * if given string does not represent correct number. */ public static Integer parse(final String stringValue) { if (StringUtils.isBlank(stringValue)) { return null; } return Integer.parseInt(StringUtils.trim(stringValue)); }
From source file:de.micromata.mgc.jpa.hibernatesearch.impl.ListHibernateFieldInfoProvider.java
@Override public Map<String, SearchColumnMetadata> getAdditionallySearchFields(EntityMetadata entm, String params) { Map<String, SearchColumnMetadata> ret = new HashMap<>(); String[] fields = StringUtils.split(params, ','); for (String field : fields) { String fname = StringUtils.trim(field); ColumnMetadataBean cm = new ColumnMetadataBean(entm); cm.setName(fname);/* w ww . jav a2 s. com*/ cm.setJavaType(String.class); SearchColumnMetadataBean mb = new SearchColumnMetadataBean(fname, cm); mb.setIndexed(true); mb.setIndexType(String.class); ret.put(fname, mb); } return ret; }
From source file:com.yqboots.initializer.core.builder.excel.AbstractSheetBuilder.java
@Override public boolean supports(final Sheet sheet) { final String name = StringUtils.trim(sheet.getSheetName()); return StringUtils.startsWithIgnoreCase(name, this.sheetName); }
From source file:ch.cyberduck.core.StringAppender.java
public StringAppender append(final String message) { if (StringUtils.isBlank(message)) { return this; }//from www . jav a 2s. c o m if (buffer.length() > 0) { buffer.append(" "); } buffer.append(StringUtils.trim(message)); if (buffer.charAt(buffer.length() - 1) == '.') { return this; } if (buffer.charAt(buffer.length() - 1) == ':') { buffer.deleteCharAt(buffer.length() - 1); } if (!Pattern.matches("[.?!]", String.valueOf(buffer.charAt(buffer.length() - 1)))) { buffer.append(suffix); } return this; }