List of usage examples for org.apache.commons.lang StringUtils isNotEmpty
public static boolean isNotEmpty(String str)
Checks if a String is not empty ("") and not null.
From source file:net.bible.service.format.osistohtml.taghandler.TagHandlerHelper.java
/** * see if an attribute exists and has a value * //from w w w . j a v a 2 s.c om * @param attributeName * @param attrs * @return */ public static boolean isAttr(String attributeName, Attributes attrs) { String attrValue = attrs.getValue(attributeName); return StringUtils.isNotEmpty(attrValue); }
From source file:net.jofm.format.NumberFormat.java
@Override protected String doFormat(Object value) { if (StringUtils.isNotEmpty(format)) { DecimalFormat formatter = new DecimalFormat(format); return formatter.format(value); } else {/* w w w . ja v a2 s. c o m*/ return value.toString(); } }
From source file:com.haulmont.cuba.core.config.type.IntegerListTypeFactory.java
@Override public Object build(String string) { List<Integer> integerList = new ArrayList<>(); if (StringUtils.isNotEmpty(string)) { String[] elements = string.split(" "); for (String element : elements) { if (StringUtils.isNotEmpty(element)) { try { Integer value = Integer.parseInt(element); integerList.add(value); } catch (NumberFormatException e) { log.debug("Invalid integer list property: " + string); return Collections.emptyList(); }//ww w . java 2 s.com } } } return integerList; }
From source file:com.epam.cme.storefront.util.MetaSanitizerUtil.java
/** * Takes a string of words, removes duplicates and returns a comma separated list of keywords as * a String//from w ww. ja v a 2 s . c o m * * @param s * Keywords to be sanitized * @return String of comma separated keywords */ public static String sanitizeKeywords(final String s) { final String clean = (StringUtils.isNotEmpty(s) ? Jsoup.parse(s).text() : ""); // Clean html final String[] sa = StringUtils.split(clean.replace("\"", "")); // Clean quotes // Remove duplicates String noDupes = ""; for (final String aSa : sa) { if (!noDupes.contains(aSa)) { noDupes += aSa + ","; } } if (!noDupes.isEmpty()) { noDupes = noDupes.substring(0, noDupes.length() - 1); } return noDupes; }
From source file:com.bstek.dorado.web.WebExpressionUtilsObject.java
public String url(String urlPattern) { if (StringUtils.isNotEmpty(urlPattern)) { if (urlPattern.charAt(0) == '>') { return PathUtils.concatPath(getContextPath(), urlPattern.substring(1)); }//from www . j a v a 2s. c o m } return urlPattern; }
From source file:com.doculibre.constellio.utils.connector.ConnectorPropertyInheritanceResolver.java
@SuppressWarnings("unchecked") public static <T extends Object> T newInheritedClassPropertyInstance(ConnectorInstance connectorInstance, String propertyName, Class[] paramTypes, Object[] args) { T inheritedClassPropertyInstance;/*from w ww. j a v a2 s .com*/ String propertyValue = getStringPropertyValue(connectorInstance, propertyName); if (StringUtils.isEmpty(propertyValue)) { propertyValue = getStringPropertyValue(connectorInstance.getConnectorType(), propertyName); } if (StringUtils.isNotEmpty(propertyValue)) { PluginAwareClassLoader pluginAwareClassLoader = new PluginAwareClassLoader(); try { Thread.currentThread().setContextClassLoader(pluginAwareClassLoader); Class<T> propertyValueClass = (Class<T>) Class.forName(propertyValue); Constructor<T> constructor = propertyValueClass.getConstructor(paramTypes); inheritedClassPropertyInstance = constructor.newInstance(args); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } catch (SecurityException e) { throw new RuntimeException(e); } catch (NoSuchMethodException e) { throw new RuntimeException(e); } catch (IllegalArgumentException e) { throw new RuntimeException(e); } catch (InstantiationException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } finally { Thread.currentThread().setContextClassLoader(pluginAwareClassLoader.getDefaultClassLoader()); } } else { inheritedClassPropertyInstance = null; } return inheritedClassPropertyInstance; }
From source file:com.easysoft.build.manager.BuildDetailiDataService.java
public void validBuildNo(String[] nos) { String rs = ""; for (String no : nos) { if (this.getBuildDetailDataNoByNo(no) == null) { rs = rs + "[" + no + "]"; }/*from ww w. j a v a2s . co m*/ } if (StringUtils.isNotEmpty(rs)) { throw new RuntimeException("??" + rs + "?"); } }
From source file:fr.hoteia.qalingo.web.handler.security.ExtUsernamePasswordAuthenticationFilter.java
@Override protected boolean requiresAuthentication(HttpServletRequest request, HttpServletResponse response) { String uri = request.getRequestURI(); int pathParamIndex = uri.indexOf(';'); if (pathParamIndex > 0) { // strip everything after the first semi-colon uri = uri.substring(0, pathParamIndex); }//from ww w . ja v a 2 s . c o m boolean requiresAuthentication = false; if (StringUtils.isNotEmpty(uri)) { requiresAuthentication = uri.contains(getFilterProcessesUrl()); } return requiresAuthentication; }
From source file:gr.seab.r2rml.beans.MainParser.java
public static void runParcer(String[] args) { Calendar c0 = Calendar.getInstance(); long t0 = c0.getTimeInMillis(); CommandLineParser cmdParser = new PosixParser(); Options cmdOptions = new Options(); cmdOptions.addOption("p", "properties", true, "define the properties file. Example: r2rml-parser -p r2rml.properties"); cmdOptions.addOption("h", "print help", false, "help"); String propertiesFile = "r2rml.properties"; try {/*from w w w . j a v a 2 s .com*/ if (StringUtils.isNotEmpty(propertiesFile)) { properties.load(new FileInputStream(propertiesFile)); log.info("Loaded properties from " + propertiesFile); if (args != null && args.length > 0 && args[0].equals("fixProperty")) { properties = fixProperty(properties); } } } catch (FileNotFoundException e) { //e.printStackTrace(); String err = "Properties file not found (" + propertiesFile + ")."; log.error(err); throw new RuntimeException(err); //System.exit(0); } catch (IOException e) { //e.printStackTrace(); String err = "Error reading properties file (" + propertiesFile + ")."; log.error(err); throw new RuntimeException(err); //System.exit(0); } ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("app-context.xml"); Database db = (Database) context.getBean("db"); db.setProperties(properties); Parser parser = (Parser) context.getBean("parser"); parser.setProperties(properties); MappingDocument mappingDocument = parser.parse(); mappingDocument.getTimestamps().add(t0); //0 Started mappingDocument.getTimestamps().add(Calendar.getInstance().getTimeInMillis()); //1 Finished parsing. Starting generating result model. Generator generator = (Generator) context.getBean("generator"); generator.setProperties(properties); generator.setResultModel(parser.getResultModel()); //Actually do the output generator.createTriples(mappingDocument); context.close(); Calendar c1 = Calendar.getInstance(); long t1 = c1.getTimeInMillis(); log.info("Finished in " + (t1 - t0) + " milliseconds. Done."); mappingDocument.getTimestamps().add(Calendar.getInstance().getTimeInMillis()); //5 Finished. //log.info("5 Finished."); //output the result for (int i = 0; i < mappingDocument.getTimestamps().size(); i++) { if (i > 0) { long l = (mappingDocument.getTimestamps().get(i).longValue() - mappingDocument.getTimestamps().get(i - 1).longValue()); //System.out.println(l); log.info(String.valueOf(l)); } } log.info("Parse. Generate in memory. Dump to disk/database. Log. - Alltogether in " + String.valueOf(mappingDocument.getTimestamps().get(5).longValue() - mappingDocument.getTimestamps().get(0).longValue()) + " msec."); log.info("Done."); System.out.println("Done."); }
From source file:energy.usef.core.adapter.YodaTimeAdapter.java
/** * Transforms a String (xsd:time) to a {@link LocalDateTime}. * //from www. j ava 2 s. c o m * @param timeString A String (xsd:time) * @return String (xsd:time) */ public static LocalTime parseTime(String timeString) { if (StringUtils.isNotEmpty(timeString)) { return new LocalTime(timeString); } return null; }