List of usage examples for org.apache.commons.lang3 StringUtils trimToEmpty
public static String trimToEmpty(final String str)
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null .
From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java
/** * @return the prevOtherDescription */ public String getPrevOtherDescription() { return StringUtils.trimToEmpty(prevOtherDescription); }
From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java
/** * @return the prevRegionalCenterIndicator */ public String getPrevRegionalCenterIndicator() { return StringUtils.trimToEmpty(prevRegionalCenterIndicator); }
From source file:com.erudika.scoold.utils.ScooldUtils.java
public String sanitizeQueryString(String query, HttpServletRequest req) { String qf = getSpaceFilteredQuery(req); String defaultQuery = "*"; String q = StringUtils.trimToEmpty(query); if (qf.isEmpty() || qf.length() > 1) { q = q.replaceAll("[\\*\\?]", "").trim(); q = RegExUtils.removeAll(q, "AND"); q = RegExUtils.removeAll(q, "OR"); q = RegExUtils.removeAll(q, "NOT"); q = q.trim();/* w w w . j ava 2s . c o m*/ defaultQuery = ""; } if (qf.isEmpty()) { return defaultQuery; } else if ("*".equals(qf)) { return q; } else { if (q.isEmpty()) { return qf; } else { return qf + " AND " + q; } } }
From source file:com.github.binlee1990.spider.movie.spider.MovieCrawler.java
private void setFilmRelated(Document doc, Film film) { Elements keyElements = doc.select(".fm-minfo dt"); Elements valueElements = doc.select(".fm-minfo dd"); if (CollectionUtils.isNotEmpty(keyElements) && CollectionUtils.isNotEmpty(valueElements)) { int keyI = 0; for (; keyI < keyElements.size(); keyI++) { Element keyElement = keyElements.get(keyI); Element valueElement = valueElements.get(keyI); if (null != keyElement && null != valueElement) { String key = StringUtils.trimToEmpty(keyElement.text().toString()); if (StringUtils.isNotBlank(key)) { String value = StringUtils.trimToEmpty(valueElement.text().toString()); if (StringUtils.equalsIgnoreCase(key, "")) { Director director = createOrQueryDirector(value); if (null != director) { film.setDirectorId(director.getId()); }//from w ww. j ava2 s . com film.setDirector(value); } if (StringUtils.equalsIgnoreCase(key, "")) { } if (StringUtils.equalsIgnoreCase(key, "")) { } if (StringUtils.equalsIgnoreCase(key, "")) { String urlYear = getFilmUrlYear(doc, value); if (StringUtils.isNotBlank(urlYear)) { EnumYear enumYear = queryEnumYear(urlYear); if (null != enumYear) { film.setYearId(enumYear.getId()); } } Date releaseDate = getFilmReleaseDate(value); if (null != releaseDate) { film.setReleaseDate(releaseDate); } } if (StringUtils.equalsIgnoreCase(key, "")) { int length = getFilmLength(value); film.setLength(length); } if (StringUtils.equalsIgnoreCase(key, "??")) { if (StringUtils.isNotBlank(value)) { film.setAlias(value); } } } } } } }
From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java
/** * @return the sensitiveHlthInfoOnFileIndicator */ public String getSensitiveHlthInfoOnFileIndicator() { return StringUtils.trimToEmpty(sensitiveHlthInfoOnFileIndicator); }
From source file:kenh.xscript.impl.BaseElement.java
protected void saveVariable(String var, Object value, Object defaultValue) throws UnsupportedScriptException { boolean isFinal = false; boolean isPublic = false; if (this.getParent() instanceof Script) isPublic = true;/*from w w w. j av a2s. c o m*/ String varName = var; if (StringUtils.contains(var, " ")) { String[] all = StringUtils.split(var, " "); varName = StringUtils.trimToEmpty(all[all.length - 1]); if (StringUtils.isBlank(varName)) { UnsupportedScriptException ex = new UnsupportedScriptException(this, "Variable format incorrect. [" + var + "]"); throw ex; } for (int i = 0; i < all.length - 1; i++) { String s = StringUtils.trimToEmpty(all[i]); if (StringUtils.isBlank(s)) continue; if (s.equals(MODI_FINAL)) { isFinal = true; } else if (s.equals(MODI_PUBLIC)) { isPublic = true; } else { UnsupportedScriptException ex = new UnsupportedScriptException(this, "Unsupported modifier. [" + var + ", " + s + "]"); throw ex; } } } // if value if empty, use default value. if (value == null || ((value instanceof String) && ((String) value).equals(""))) { if (defaultValue != null) value = defaultValue; } setVariable(varName, value, isFinal, isPublic); }
From source file:ml.shifu.shifu.core.dtrain.DTrainUtils.java
/** * Get Boolean property value from map./*from w ww .java 2 s.co m*/ * If the value doesn't exist in the Map or the format is incorrect, use @defval as default * * @param params * input Map * @param key * the key to look up * @param defval * default value, if the key is not in the map or the value format is illegal * @return * Boolean value if the key exists and value format is correct * or defval */ public static Boolean getBoolean(Map<?, ?> params, String key, Boolean defval) { Boolean val = defval; if (MapUtils.isNotEmpty(params) && params.containsKey(key)) { Object obj = params.get(key); if (obj != null) { try { val = Boolean.valueOf(StringUtils.trimToEmpty(obj.toString())); } catch (Exception e) { LOG.warn("Export boolean value for {} in params, but got {}", key, obj, e); } } } return val; }
From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java
/** * @return the sensitivityIndicator */ @Override public String getSensitivityIndicator() { return StringUtils.trimToEmpty(sensitivityIndicator); }
From source file:com.webbfontaine.valuewebb.model.util.Utils.java
public static void setLocale(String language) { String notEmptyLanguage = StringUtils.defaultIfEmpty(StringUtils.trimToEmpty(language), EN).replaceAll("'", "");/*from w ww . ja va 2s. c o m*/ if (Constants.FR.equals(notEmptyLanguage)) { LocaleSelector.instance().setLocale(Locale.FRENCH); } else { if (Constants.EN.equals(notEmptyLanguage)) { LocaleSelector.instance().setLocale(Locale.ENGLISH); } else { LOGGER.warn("There is no support for locale {0}. English will be set.", notEmptyLanguage); LocaleSelector.instance().setLocale(Locale.ENGLISH); } } }
From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java
/** * @return the soUnableToDetermineCode */ public String getSoUnableToDetermineCode() { return StringUtils.trimToEmpty(soUnableToDetermineCode); }