List of usage examples for org.apache.commons.lang StringUtils isEmpty
public static boolean isEmpty(String str)
Checks if a String is empty ("") or null.
From source file:com.haulmont.cuba.gui.components.ValuePathHelper.java
public static String[] parse(String path) { if (!path.contains(".") && !path.contains("[")) return new String[] { path }; List<String> elements = new ArrayList<>(); int bracketCount = 0; StringBuilder buffer = new StringBuilder(); for (int i = 0; i < path.length(); i++) { char c = path.charAt(i); if (c == '[') { bracketCount++;/*from w w w. j a va 2s .c o m*/ continue; } if (c == ']') { bracketCount--; continue; } if ('.' != c || bracketCount > 0) buffer.append(c); if ('.' == c && bracketCount == 0) { String element = buffer.toString(); if (!StringUtils.isEmpty(element)) { elements.add(element); } else { throw new IllegalStateException("Wrong value path format"); } buffer = new StringBuilder(); } } elements.add(buffer.toString()); return elements.toArray(new String[elements.size()]); }
From source file:com.devnexus.ting.web.converter.StringToSpeaker.java
@Override public Speaker convert(String source) { if (StringUtils.isEmpty(source) || !StringUtils.isNumeric(source)) { return null; } else {/*w ww .j av a 2 s . c om*/ return new Speaker(Long.valueOf(source)); } }
From source file:com.pureinfo.tgirls.servlet.CountsServlet.java
@Override protected void doPost(HttpServletRequest _req, HttpServletResponse _resp) throws ServletException, IOException { String type = _req.getParameter("type"); if (StringUtils.isEmpty(type)) { logger.warn("type is empty. can not counts."); return;/* w ww . j ava 2 s .co m*/ } logger.debug("to counts type:" + type); cache.process(type); }
From source file:de.fhg.iais.asc.ui.i18n.LocalizedUI.java
public static JLabel createLabel(String key) { key = "Label." + key; String tooltipText = Messages.getString("Tooltip." + key, ""); JLabel label = new JLabel(Messages.getString(key)); if (!StringUtils.isEmpty(tooltipText)) { label.setToolTipText(tooltipText); }//from w ww . j ava 2s. com return label; }
From source file:com.enonic.cms.core.country.CountryXmlParser.java
private static CountryCode parseCountryCode(Element countryEl, int position) { String value = countryEl.getAttributeValue(ATTRNAME_COUNTRY_CODE); if (StringUtils.isEmpty(value)) { throw new InvalidCountryXmlException("Missing " + ATTRNAME_COUNTRY_CODE + " for country #" + position); }//from w w w . j a va 2 s . com return new CountryCode(value); }
From source file:com.nec.harvest.model.AbstractEntity.java
/** * Check a string is empty or null//w ww. j a va 2 s .co m * * @param text * @return */ @Transient protected static String value(String text) { return StringUtils.isEmpty(text) ? StringUtils.EMPTY : text; }
From source file:net.duckling.falcon.api.mq.impl.SimpleStringMatch.java
public String routingMatch(Map<String, String> regMap, String value) { if (StringUtils.isEmpty(value)) { return ""; }/*from w w w .j a v a 2 s . c o m*/ if (regMap.keySet().contains(value)) { return value; } String matchedReg = null; for (Map.Entry<String, String> entry : regMap.entrySet()) { Pattern m = Pattern.compile(entry.getValue()); Matcher matcher = m.matcher(value); while (matcher.find()) { if (matcher.start() == 0 && (matcher.end() == value.length())) { matchedReg = entry.getKey(); return matchedReg; } } } return null; }
From source file:net.jforum.core.tags.DisplayFormattedMessageTag.java
/** * @see javax.servlet.jsp.tagext.SimpleTagSupport#doTag() */// ww w . j a va 2 s . c o m @Override public void doTag() throws JspException, IOException { if (this.post == null && !StringUtils.isEmpty(this.rawMessage)) { this.post = new Post(); this.post.setText(this.rawMessage); } if (post == null) { return; } String text = post.getText(); PostOptions options = new PostOptions(this.post.isHtmlEnabled(), this.post.isSmiliesEnabled(), this.post.isBbCodeEnabled(), this.post.isSignatureEnabled(), this.request().getContextPath()); for (Formatter formatter : formatters) { text = formatter.format(text, options); } this.write(text); }
From source file:fr.hoteia.qalingo.web.mvc.viewbean.MenuViewBean.java
public String getAlt() { if (StringUtils.isEmpty(alt)) { return getName(); } return alt; }
From source file:net.jforum.services.PollService.java
public void associatePoll(Topic topic, List<PollOption> pollOptions) { if (topic.getPoll() == null) { return;/* www .j a v a 2 s . c om*/ } if (StringUtils.isEmpty(topic.getPoll().getLabel()) || pollOptions == null) { topic.setPoll(null); return; } topic.getPoll().setStartDate(new Date()); for (Iterator<PollOption> iterator = pollOptions.iterator(); iterator.hasNext();) { PollOption option = iterator.next(); if (StringUtils.isEmpty(option.getText())) { iterator.remove(); } else { option.setPoll(topic.getPoll()); } } if (pollOptions.size() == 0) { topic.setPoll(null); } else { topic.getPoll().setOptions(pollOptions); } }