List of usage examples for org.springframework.util StringUtils hasText
public static boolean hasText(@Nullable String str)
From source file:com.consol.citrus.selenium.action.WebAction.java
@Override public void doExecute(TestContext context) { if (StringUtils.hasText(url)) { String convertedUrl = context.replaceDynamicContentInString(url); logger.info("navigating to url <{}>", convertedUrl); webClient.navigateTo(convertedUrl); }/*from w w w . ja va 2 s . c o m*/ }
From source file:org.wallride.web.controller.admin.comment.CommentSearchForm.java
public boolean isEmpty() { if (StringUtils.hasText(getKeyword())) { return false; } return true; }
From source file:com.ge.predix.uaa.token.lib.JsonUtils.java
public static <T> T readValue(final String s, final TypeReference<?> typeReference) { try {/* w w w . ja v a 2 s. com*/ if (StringUtils.hasText(s)) { return objectMapper.readValue(s, typeReference); } else { return null; } } catch (IOException e) { throw new JsonUtilException(e); } }
From source file:com.genius.admin.helper.DataStoreFactoryBean.java
@Override protected Datastore createInstance() throws Exception { if (StringUtils.hasText(user)) { return morphia.createDatastore(mongo, dbName, user, password.toCharArray()); }/* w ww .ja v a 2 s . c om*/ return morphia.createDatastore(mongo, dbName); }
From source file:org.springmodules.cache.util.SemicolonSeparatedPropertiesParser.java
/** * Creates a <code>java.util.Properties</code> from the specified String. * * @param text/*from ww w. ja v a2 s . com*/ * the String to parse. * @throws IllegalArgumentException * if the specified property does not match the regular expression * pattern defined in <code>KEY_VALUE_REGEX</code>. * @throws IllegalArgumentException * if the set of properties already contains the property specified * by the given String. * @return a new instance of <code>java.util.Properties</code> created from * the given text. */ public static Properties parseProperties(String text) throws IllegalArgumentException { String newText = text; if (!StringUtils.hasText(newText)) { return null; } if (newText.endsWith(PROPERTY_DELIMITER)) { // remove ';' at the end of the text (if applicable) newText = newText.substring(0, newText.length() - PROPERTY_DELIMITER.length()); if (!StringUtils.hasText(newText)) { return null; } } Properties properties = new Properties(); String[] propertiesAsText = StringUtils.delimitedListToStringArray(newText, PROPERTY_DELIMITER); int propertyCount = propertiesAsText.length; for (int i = 0; i < propertyCount; i++) { String property = propertiesAsText[i]; Match match = KEY_VALUE_REGEX.match(property); if (!match.isSuccessful()) { String message = "The String " + StringUtils.quote(property) + " should match the regular expression pattern " + StringUtils.quote(KEY_VALUE_REGEX.getPattern()); throw new IllegalArgumentException(message); } String[] groups = match.getGroups(); String key = groups[1].trim(); String value = groups[2].trim(); if (properties.containsKey(key)) { throw new IllegalArgumentException( "The property " + StringUtils.quote(key) + " is specified more than once"); } properties.setProperty(key, value); } return properties; }
From source file:org.openmrs.module.register.propertyeditor.HtmlFormEdiotr.java
public void setAsText(String text) throws IllegalArgumentException { HtmlFormEntryService htmlService = Context.getService(HtmlFormEntryService.class); if (StringUtils.hasText(text)) { try {//from www.j av a 2s . com setValue(htmlService.getHtmlForm(Integer.valueOf(text))); } catch (Exception ex) { log.error("Error setting text: " + text, ex); throw new IllegalArgumentException("Htmlform not found: " + ex.getMessage()); } } else { setValue(null); } }
From source file:org.openmrs.module.register.propertyeditor.RegisterTypeEditor.java
public void setAsText(String text) throws IllegalArgumentException { RegisterService registerService = Context.getService(RegisterService.class); if (StringUtils.hasText(text)) { try {//w ww . ja v a 2s .c o m setValue(registerService.getRegisterType(Integer.valueOf(text))); } catch (Exception ex) { log.error("Error setting text: " + text, ex); throw new IllegalArgumentException("RegisterType not found: " + ex.getMessage()); } } else { setValue(null); } }
From source file:org.xacml4j.spring.FunctionProvidersDefinitionParser.java
private static BeanDefinitionBuilder parseComponent(Element element) { BeanDefinitionBuilder component = BeanDefinitionBuilder.rootBeanDefinition(FunctionProvider.class); String clazz = element.getAttribute("class"); if (StringUtils.hasText(clazz)) { component.addPropertyValue("providerClass", clazz); }//from ww w. j a va 2 s . c om String ref = element.getAttribute("ref"); if (StringUtils.hasText(ref)) { component.addPropertyReference("providerInstance", ref); } return component; }
From source file:org.jasig.cas.authentication.principal.SimpleWebApplicationServiceImpl.java
public static SimpleWebApplicationServiceImpl createServiceFrom(final HttpServletRequest request, final HttpClient httpClient) { final String targetService = request.getParameter(CONST_PARAM_TARGET_SERVICE); final String method = request.getParameter(CONST_PARAM_METHOD); final String serviceToUse = StringUtils.hasText(targetService) ? targetService : request.getParameter(CONST_PARAM_SERVICE); if (!StringUtils.hasText(serviceToUse)) { return null; }//from w ww . java2s .co m final String id = cleanupUrl(serviceToUse); final String artifactId = request.getParameter(CONST_PARAM_TICKET); return new SimpleWebApplicationServiceImpl(id, serviceToUse, artifactId, "POST".equals(method) ? ResponseType.POST : ResponseType.REDIRECT, httpClient); }
From source file:net.prasenjit.auth.validation.StrongPasswordValidator.java
/** {@inheritDoc} */ @Override//from ww w . j a v a2 s .c om public boolean isValid(String value, ConstraintValidatorContext context) { if (!StringUtils.hasText(value)) return true; int upperCount = 0; int specialCount = 0; int lowerCount = 0; int numericCount = 0; for (int i = 0; i < value.length(); i++) { char current = value.charAt(i); if (Character.isDigit(current)) numericCount = 1; if (Character.isUpperCase(current)) upperCount = 1; if (Character.isLowerCase(current)) lowerCount = 1; if (!Character.isLetterOrDigit(current)) specialCount = 1; } return upperCount + lowerCount + numericCount + specialCount >= 2; }