List of usage examples for org.springframework.util StringUtils hasText
public static boolean hasText(@Nullable String str)
From source file:Main.java
public static String joins(String[] arrays, String joinStr) { if (arrays == null) { return ""; }/* w w w. j a va 2 s. com*/ joinStr = StringUtils.hasText(joinStr) ? joinStr : ","; StringBuilder rs = new StringBuilder(); for (String e : arrays) { rs.append(joinStr).append(e); } return rs.length() > 0 ? rs.substring(1) : ""; }
From source file:com.example.JobUtil.java
public static Resource getResource(final String resourcePath) { if (resourcePath == null) { return null; }/*from w ww. j a v a2 s.c om*/ Resource resource = null; String profile = System.getProperty("spring.profiles.active"); if (!StringUtils.hasText(profile) || ("loc").equals(profile)) { resource = new ClassPathResource(resourcePath); return resource; } try { resource = new UrlResource(resourcePath); } catch (Exception e) { log.error("resource error : {}", e.toString()); return null; } return resource; }
From source file:org.opensprout.osaf.data.hibernate.CriteriaUtils.java
public static void ilike(Criteria c, String propertyName, String value, MatchMode matchMode) { if (StringUtils.hasText(value)) { c.add(Restrictions.ilike(propertyName, value, matchMode)); }// ww w .j ava 2 s. com }
From source file:nl.surfnet.coin.teams.util.PHPRegexConverter.java
/** * Strips the delimiter chars from the PHP regex * * @param phpPattern String with regular expression that may contain | as delimiter * @return cleaned up regex pattern, can be {@literal null} *//*from ww w .jav a2 s .co m*/ public static String convertPHPRegexPattern(String phpPattern) { if (StringUtils.hasText(phpPattern)) { return phpPattern.replaceFirst("^\\|(.*)\\|$", "$1"); } return phpPattern; }
From source file:org.cloudfoundry.identity.uaa.authentication.login.Prompt.java
public static Prompt valueOf(String text) { if (!StringUtils.hasText(text)) { return null; }// ww w. j a v a2 s . c o m String[] parts = text.split(":"); if (parts.length < 2) { return null; } String name = parts[0].replaceAll("\"", ""); String[] values = parts[1].replaceAll("\"", "").replaceAll("\\[", "").replaceAll("\\]", "").split(","); values = StringUtils.trimArrayElements(values); return new Prompt(name, values[0], values[1]); }
From source file:com.scf.web.context.spring.ProjectLog4jWebConfigurer.java
public static void initLogging(ServletContext servletContext, String location) { if (location != null) { try {//w w w.ja v a 2s. c om // Write log message to server log. servletContext.log("Initializing log4j from [" + location + "]"); // Check whether refresh interval was specified. String intervalString = servletContext.getInitParameter(REFRESH_INTERVAL_PARAM); if (StringUtils.hasText(intervalString)) { // Initialize with refresh interval, i.e. with log4j's watchdog thread, // checking the file in the background. try { long refreshInterval = Long.parseLong(intervalString); Log4jConfigurer.initLogging(location, refreshInterval); } catch (NumberFormatException ex) { throw new IllegalArgumentException( "Invalid 'log4jRefreshInterval' parameter: " + ex.getMessage()); } } else { // Initialize without refresh check, i.e. without log4j's watchdog thread. Log4jConfigurer.initLogging(location); } } catch (FileNotFoundException ex) { throw new IllegalArgumentException("Invalid 'log4jConfigLocation' parameter: " + ex.getMessage()); } } }
From source file:org.unitedinternet.cosmo.dav.property.ContentType.java
private static String mt(String type, String encoding) { final MediaType mediaType = MediaType.parseMediaType(type); if (StringUtils.hasText(encoding)) { return new MediaType(mediaType.getType(), mediaType.getSubtype(), Charset.forName(encoding)).toString(); }//from w w w. j ava 2 s . co m return mediaType.toString(); }
From source file:fi.hsl.parkandride.core.service.PasswordValidator.java
public static void validate(String password, Collection<Violation> violations) { if (!StringUtils.hasText(password) || !PATTERN.matcher(password).matches()) { violations.add(new Violation("BadPassword", "password", "Password with length of 8-15 must contain at least one digit, one lowercase and one uppercase character")); }//from www .jav a2 s .c om }
From source file:com.benfante.taglib.frontend.tags.BootstrapTagHelper.java
/** * Writes the opening '/*from w w w . ja v a2 s .c o m*/ * <code>span</code>' tag and forces a block tag so that field prefix/suffix * is written correctly. */ public static void writeInputTagDecorator(final TagWriter tagWriter, final String text) throws JspException { if (StringUtils.hasText(text)) { tagWriter.startTag("span"); tagWriter.writeAttribute("class", "input-group-addon"); tagWriter.appendValue(text); tagWriter.endTag(); tagWriter.forceBlock(); } }
From source file:com.iflytek.edu.cloud.frame.utils.ServiceUtil.java
public static String getRemoteAddr(HttpServletRequest request) { String remoteIp = request.getHeader(X_REAL_IP); //nginx???? if (StringUtils.hasText(remoteIp)) { return remoteIp; } else {//w ww. ja va 2 s . c o m remoteIp = request.getHeader(X_FORWARDED_FOR);//apache??? if (StringUtils.hasText(remoteIp)) { String[] ips = remoteIp.split(","); for (String ip : ips) { if (!"null".equalsIgnoreCase(ip)) { return ip; } } } return request.getRemoteAddr(); } }