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.bfd.harpc.loadbalance.LoadBalancerFactory.java
/** * ?//from w ww. jav a2 s . c o m * <p> * * @param strategyName * @return {@link LoadBalancingStrategy} */ private static <K, T> LoadBalancingStrategy<K> createLoadBalancingStrategy(String strategyName, HeartBeatManager<T> heartBeatManager) { LoadBalancingStrategy<K> strategy = null; if (StringUtils.isEmpty(strategyName) || "round".equals(strategyName)) { strategy = new RoundRobinStrategy<K>(); } else { strategy = new RandomStrategy<K>(); } return strategy; }
From source file:converters.StringToRentConverter.java
@Override public Rent convert(String text) { Rent result;//from w ww .j a v a 2 s .co m int id; try { if (StringUtils.isEmpty(text)) result = null; else { id = Integer.valueOf(text); result = RentRepository.findOne(id); } } catch (Throwable oops) { throw new IllegalArgumentException(oops); } return result; }
From source file:gov.nih.nci.cabig.caaers.utils.pdf.MedwatchUtils.java
public static int possibleElements(NodeList nodes, int n, String commaSeperatedXPath) { if (nodes == null || nodes.getLength() == 0) return 1; String[] xpath = StringUtils.isEmpty(commaSeperatedXPath) ? new String[] { "." } : commaSeperatedXPath.split(","); int l = 0;//www . j av a2 s . c o m int k = 1; for (int i = 0; i < nodes.getLength(); i++) { Node node = nodes.item(i); for (int j = 0; j < xpath.length; j++) { String s = evalXPathsOnNode(node, xpath[j]); l += StringUtils.length(s); } if (l >= n) return k; k++; } return k; }
From source file:com.cognifide.slice.cq.utils.PathUtils.java
public String getPagePathFromResourcePath(final String resourcePath) { if (StringUtils.isEmpty(resourcePath)) { return StringUtils.EMPTY; }/* w w w . j a v a 2 s. c om*/ int jcrContentPosition = resourcePath.lastIndexOf("/" + JcrConstants.JCR_CONTENT); if (0 > jcrContentPosition) { return resourcePath; // we are on page path } return resourcePath.substring(0, jcrContentPosition); }
From source file:converters.StringToGroupConverter.java
@Override public Group convert(String text) { Group result;//from w w w. j av a 2s . co m int id; try { if (StringUtils.isEmpty(text)) result = null; else { id = Integer.valueOf(text); result = groupRepository.findOne(id); } } catch (Throwable oops) { throw new IllegalArgumentException(oops); } return result; }
From source file:converters.StringToOwnerConverter.java
@Override public Owner convert(String text) { Owner result;/*w ww. j ava2 s .com*/ int id; try { if (StringUtils.isEmpty(text)) result = null; else { id = Integer.valueOf(text); result = ownerRepository.findOne(id); } } catch (Throwable oops) { throw new IllegalArgumentException(oops); } return result; }
From source file:com.haulmont.cuba.desktop.sys.layout.MigLayoutHelper.java
public static CC getExpandConstraints(String width, String height, BoxLayoutAdapter.FlowDirection direction) { CC cc = new CC(); if (direction == null || direction == BoxLayoutAdapter.FlowDirection.X && (StringUtils.isEmpty(height) || "-1px".equals(height) || height.endsWith("%"))) { applyWidth(cc, 100, Component.UNITS_PERCENTAGE, true); }// w w w .j a v a 2 s .c o m if (direction == null || direction == BoxLayoutAdapter.FlowDirection.Y && (StringUtils.isEmpty(width) || "-1px".equals(width) || width.endsWith("%"))) { applyHeight(cc, 100, Component.UNITS_PERCENTAGE, true); } return cc; }
From source file:eu.eidas.auth.commons.PropertiesLoader.java
/** * Loads the properties defined in an xml file with the format <//?xml version="1.0" encoding="UTF-8" * standalone="no"?> <//!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> <properties> * <comment>Comment</comment> <entry key="keyName">Some Value</entry> </properties> * * @param xmlFilePath the file path// ww w . j a v a2 s . c om * @return Object @Properties */ @Nonnull public static Properties loadPropertiesXMLFile(@Nonnull String xmlFilePath) { Properties props; InputStream fileProperties = null; try { if (StringUtils.isEmpty(xmlFilePath) || !StringUtils.endsWith(xmlFilePath, "xml")) { throw new InternalErrorEIDASException(EidasErrorKey.INTERNAL_ERROR.errorCode(), EidasErrorKey.INTERNAL_ERROR.errorMessage(), "Not valid file!"); } props = new Properties(); fileProperties = new FileInputStream(xmlFilePath); //load the xml file into properties format props.loadFromXML(fileProperties); return props; } catch (InternalErrorEIDASException e) { LOG.error("ERROR : " + e.getMessage()); throw e; } catch (Exception e) { LOG.error("ERROR : " + e.getMessage()); throw new InternalErrorEIDASException(EidasErrorKey.INTERNAL_ERROR.errorCode(), EidasErrorKey.INTERNAL_ERROR.errorMessage(), e); } finally { try { if (fileProperties != null) { fileProperties.close(); } } catch (IOException ioe) { LOG.error("error closing the file: " + ioe, ioe); } } }
From source file:jp.co.opentone.bsol.framework.core.extension.rome.feed.synd.ExtendedSyndEntryImpl.java
private static String removeInvalidChars(String s) { if (StringUtils.isEmpty(s)) { return s; }/*from ww w . j a v a 2 s. c o m*/ return XMLUtil.removeInvalidChars(s); }
From source file:com.mmj.app.web.tools.WebUserTools.java
public static String getImg() { return current() == null ? null : StringUtils.isEmpty(current().getImg()) ? "/images/image30.png" : current().getImg(); }