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:ch.cyberduck.core.idna.PunycodeConverter.java
/** * @return IDN normalized hostname//w w w . j a va 2s . c om */ public String convert(final String hostname) { if (!PreferencesFactory.get().getBoolean("connection.hostname.idn")) { return StringUtils.strip(hostname); } if (StringUtils.isNotEmpty(hostname)) { try { // Convenience function that implements the IDNToASCII operation as defined in // the IDNA RFC. This operation is done on complete domain names, e.g: "www.example.com". // It is important to note that this operation can fail. If it fails, then the input // domain name cannot be used as an Internationalized Domain Name and the application // should have methods defined to deal with the failure. // IDNA.DEFAULT Use default options, i.e., do not process unassigned code points // and do not use STD3 ASCII rules If unassigned code points are found // the operation fails with ParseException final String idn = IDN.toASCII(StringUtils.strip(hostname)); if (log.isDebugEnabled()) { if (!StringUtils.equals(StringUtils.strip(hostname), idn)) { log.debug(String.format("IDN hostname for %s is %s", hostname, idn)); } } if (StringUtils.isNotEmpty(idn)) { return idn; } } catch (IllegalArgumentException e) { log.warn(String.format("Failed to convert hostname %s to IDNA", hostname), e); } } return StringUtils.strip(hostname); }
From source file:com.hongqiang.shop.modules.cms.service.GuestbookService.java
public Page<Guestbook> find(Page<Guestbook> page, Guestbook guestbook) { DetachedCriteria dc = guestbookDao.createDetachedCriteria(); if (StringUtils.isNotEmpty(guestbook.getType())) { dc.add(Restrictions.eq("type", guestbook.getType())); }// w ww . j av a 2 s . co m if (StringUtils.isNotEmpty(guestbook.getContent())) { dc.add(Restrictions.like("content", "%" + guestbook.getContent() + "%")); } dc.add(Restrictions.eq(Guestbook.DEL_FLAG, guestbook.getDelFlag())); dc.addOrder(Order.desc("id")); return guestbookDao.find(page, dc); }
From source file:efx.util.converter.BigDecimalStringConverter.java
@Override protected Object cast(Object obj) { if (obj == null) { //?null,??????? return null; }/* w ww .j a v a2 s. co m*/ if (obj instanceof BigDecimal) { return obj.toString(); } else if (obj instanceof String) { String strValue = String.valueOf(obj); if (StringUtils.isNotEmpty(strValue)) { return new BigDecimal(strValue); } } return super.cast(obj); }
From source file:com.glaf.core.web.DateConvertEditor.java
public void setAsText(String text) { if (StringUtils.isNotEmpty(text)) { try {//from ww w .j a v a 2s.co m if (text.indexOf(":") == -1 && text.length() == 10) { setValue(this.dateFormat.parse(text)); } else if (text.indexOf(":") > 0 && text.length() == 19) { setValue(this.datetimeFormat.parse(text)); } else if (text.indexOf(":") > 0 && text.length() == 21) { text = text.replace(".0", ""); setValue(this.datetimeFormat.parse(text)); } else { throw new RuntimeException("Could not parse date, date format is error."); } } catch (ParseException ex) { throw new RuntimeException("Could not parse date", ex); } } else { setValue(null); } }
From source file:com.nridge.core.base.std.XMLUtl.java
public static void setAttrStrValue(Element anElement, String aName, String aValue) { if ((StringUtils.isNotEmpty(aName)) && (StringUtils.isNotEmpty(aValue))) anElement.setAttribute(aName, aValue); }
From source file:com.hongqiang.shop.modules.cms.service.SiteService.java
public Page<Site> find(Page<Site> page, Site site) { DetachedCriteria dc = siteDao.createDetachedCriteria(); if (StringUtils.isNotEmpty(site.getName())) { dc.add(Restrictions.like("name", "%" + site.getName() + "%")); }/* w w w . j ava2s . c om*/ dc.add(Restrictions.eq(Site.DEL_FLAG, site.getDelFlag())); //dc.addOrder(Order.asc("id")); return siteDao.find(page, dc); }
From source file:com.gammalabs.wifianalyzer.wifi.band.Country.java
Country() { countries = new TreeMap<>(); for (Locale locale : Locale.getAvailableLocales()) { String countryCode = locale.getCountry(); if (StringUtils.isNotEmpty(countryCode) && StringUtils.isAlpha(countryCode) && countryCode.length() == 2) { countries.put(StringUtils.capitalize(countryCode), locale); }/*w w w. j a va 2s . c o m*/ } }
From source file:com.netflix.spinnaker.echo.config.GooglePubsubCredentialsProvider.java
@Override public Credentials getCredentials() throws IOException { if (StringUtils.isNotEmpty(this.jsonPath)) { try {//from w w w. j a v a2 s. c o m return ServiceAccountCredentials.fromStream(new FileInputStream(this.jsonPath)); } catch (IOException e) { log.error("Could not import Google Pubsub json credentials: {}", e.getMessage()); } } else { try { return GoogleCredentials.getApplicationDefault(); } catch (IOException e) { log.error("Could not import default application credentials: {}", e.getMessage()); } } throw new IllegalStateException("Unable to authenticate to Google Pubsub."); }
From source file:com.aqnote.app.wifianalyzer.wifi.band.Country.java
public Country() { countries = new ArrayList<>(); for (Locale locale : Locale.getAvailableLocales()) { String countryCode = locale.getCountry(); if (StringUtils.isNotEmpty(countryCode)) { countries.add(locale);/* w w w . j a v a 2s . c o m*/ } } Collections.sort(countries, new LocaleCountryComparator()); }
From source file:com.bellman.bible.service.format.osistohtml.taghandler.FigureHandler.java
@Override public void start(Attributes attrs) { // Refer to Gen 3:14 in ESV for example use of type=x-indent String src = attrs.getValue(OSISUtil.ATTRIBUTE_FIGURE_SRC); if (StringUtils.isNotEmpty(src)) { writer.write("<img class='sword' src='" + parameters.getModuleBasePath() + "/" + src + "'/>"); }/*from w w w. jav a 2 s. c o m*/ }