List of usage examples for org.springframework.util StringUtils hasText
public static boolean hasText(@Nullable String str)
From source file:com.iflytek.edu.cloud.frame.web.filter.HttpRequestRateLimiterFilter.java
@Override public void init(FilterConfig filterConfig) throws ServletException { String value = filterConfig.getInitParameter("permitsPerSecond"); int permitsPerSecond = DEFAULT_PERMITS_PER_SECOND; if (StringUtils.hasText(value)) permitsPerSecond = Integer.valueOf(value); limiter = RateLimiter.create(permitsPerSecond); LOGGER.info("?http{}", permitsPerSecond); }
From source file:com.aw.swing.mvp.validation.support.AWDefaultRulesSource.java
/** * Build the rule object for the required rule * * @return/*from www. ja va 2 s . c o m*/ */ public void isRequired(Object propertyValidator) { BindingComponent inputComponent = ((PropertyValidator) propertyValidator).getBindingComponent(); Object value = inputComponent.getValue(); // if (value== null || !ValidationUtils.isNotEmpty(value.toString().trim())) { if (!inputComponent.isUiReadOnly() && (value == null || !StringUtils.hasText(value.toString().trim()))) { if (logger.isInfoEnabled()) { logger.info("isRequired validation " + inputComponent.getFieldName() + " [FAIL]"); } throw new AWValidationException("sw.error.isrequerid", Arrays.asList(new Object[] { inputComponent })); } }
From source file:fr.xebia.springframework.security.config.AuditAspectDefinitionParser.java
@Override protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) throws BeanDefinitionStoreException { String id = super.resolveId(element, definition, parserContext); if (!StringUtils.hasText(id)) { id = "auditAspect"; }/*from w w w . j a va 2 s.co m*/ return id; }
From source file:org.owasp.webgoat.plugin.challenge1.Assignment1.java
public static boolean containsHeader(HttpServletRequest request) { return StringUtils.hasText(request.getHeader("X-Forwarded-For")); }
From source file:com.bg.jtown.social.twitter.TweetAfterConnectInterceptor.java
public void preConnect(ConnectionFactory<Twitter> provider, MultiValueMap<String, String> parameters, WebRequest request) {//from www.j a v a 2 s .co m if (StringUtils.hasText(request.getParameter(POST_TWEET_PARAMETER))) { request.setAttribute(POST_TWEET_ATTRIBUTE, Boolean.TRUE, WebRequest.SCOPE_SESSION); } }
From source file:org.openmrs.module.idgen.validator.SequentialIdentifierGeneratorValidator.java
/** * @see Validator#validate(Object, Errors) *//* w w w . j a v a 2 s .c o m*/ public void validate(Object o, Errors errors) { super.validate(o, errors); SequentialIdentifierGenerator source = (SequentialIdentifierGenerator) o; // FirstIdentifierBase is required if (!StringUtils.hasText(source.getFirstIdentifierBase())) { errors.reject("First Identifier Base is required"); } if (source.getIdentifierType() == null) { errors.reject("Identifier Type is required"); } else { String prefix = (source.getPrefix() == null ? "" : source.getPrefix()); String suffix = (source.getSuffix() == null ? "" : source.getSuffix()); String firstId = prefix + source.getFirstIdentifierBase() + suffix; if (StringUtils.hasText(source.getIdentifierType().getValidator())) { try { Class<?> validatorClass = Context.loadClass(source.getIdentifierType().getValidator()); IdentifierValidator v = (IdentifierValidator) validatorClass.newInstance(); firstId = v.getValidIdentifier(firstId); } catch (UnallowedIdentifierException uie) { errors.reject("Invalid identifier. " + uie.getMessage() + ""); } catch (Exception e) { log.error("Error loading validator class " + source.getIdentifierType().getValidator(), e); errors.reject( "Validator named " + source.getIdentifierType().getValidator() + " cannot be loaded"); } } if (source.getMinLength() != null && source.getMinLength() > 0) { if (source.getMinLength() > firstId.length()) { errors.reject("Invalid configuration. First identifier generated would be '" + firstId + "' which is shorter than minimum length of " + source.getMinLength()); } } if (source.getMaxLength() != null && source.getMaxLength() > 0) { if (source.getMaxLength() < firstId.length()) { errors.reject("Invalid configuration. First identifier generated would be '" + firstId + "' which exceeds maximum length of " + source.getMaxLength()); } } } }
From source file:biz.c24.io.spring.batch.config.BatchItemReaderParser.java
@Override protected void doParse(Element element, BeanDefinitionBuilder bean) { // Optional//from w w w.j a va 2s . com String scope = element.getAttribute("scope"); if (StringUtils.hasText(scope)) { bean.setScope(scope); } else { // Default to step scope bean.setScope("step"); } // Mandatory String sourceRef = element.getAttribute("source-ref"); bean.addPropertyReference("source", sourceRef); // Mandatory String modelRef = element.getAttribute("model-ref"); bean.addPropertyReference("model", modelRef); // Optional String validate = element.getAttribute("validate"); if (StringUtils.hasText(validate)) { bean.addPropertyValue("validate", validate); } }
From source file:example.app.model.Customer.java
public boolean hasAccount() { return StringUtils.hasText(getAccountNumber()); }
From source file:net.paslavsky.springrest.SpringRestClientBeanDefinitionParser.java
@Override protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(CLASS_NAME); builder.addConstructorArgValue(element.getAttribute("class")); String authManagerName = element.getAttribute("authentication-manager"); if (StringUtils.hasText(authManagerName)) { builder.addPropertyReference("authenticationManager", authManagerName); }//www. j a va 2s.co m String baseUrl = element.getAttribute("base-url"); if (StringUtils.hasText(baseUrl)) { builder.addPropertyValue("baseUrl", baseUrl); } return builder.getBeanDefinition(); }
From source file:io.pivotal.spring.cloud.service.eureka.SanitizingEurekaInstanceConfigBean.java
@Override public void setEnvironment(Environment environment) { super.setEnvironment(environment); // set some defaults from the environment, but allow the defaults to use // relaxed binding String springAppName = getSpringApplicationName(); String eurekaInstanceAppname = getEurekaInstanceAppnameProperty(); if (StringUtils.hasText(eurekaInstanceAppname)) { // default to eureka.instance.appname if defined setVirtualHostName(eurekaInstanceAppname); setSecureVirtualHostName(eurekaInstanceAppname); } else if (StringUtils.hasText(springAppName)) { // default to a hostname-sanitized spring application name String sanitizedAppName = sanitizeHostname(springAppName); if (!springAppName.equals(sanitizedAppName)) { LOGGER.warning("Spring application name '" + springAppName + "' was sanitized to produce eureka.instance.appname '" + sanitizedAppName + "'"); }/*from ww w . j a v a2 s . com*/ setAppname(sanitizedAppName); setVirtualHostName(sanitizedAppName); setSecureVirtualHostName(sanitizedAppName); } }