Example usage for org.springframework.util StringUtils hasText

List of usage examples for org.springframework.util StringUtils hasText

Introduction

In this page you can find the example usage for org.springframework.util StringUtils hasText.

Prototype

public static boolean hasText(@Nullable String str) 

Source Link

Document

Check whether the given String contains actual text.

Usage

From source file:com.gradecak.alfresco.mvc.converter.QnameDeserializer.java

@Override
public QName deserialize(JsonParser jp, DeserializationContext ctxt)
        throws IOException, JsonProcessingException {

    String qname = jp.getText();//from w  w w  . j a v a 2  s  . co m
    if (StringUtils.hasText(qname)) {
        return QName.createQName(qname, serviceRegistry.getNamespaceService());
    }

    throw ctxt.mappingException("Expected a valid QName string representation");
}

From source file:nl.surfnet.coin.teams.service.impl.InvitationValidator.java

/**
 * {@inheritDoc}/*from ww  w.j ava2s.  c o m*/
 */
@Override
public void validate(Object target, Errors errors) {
    Invitation invitation = (Invitation) target;

    if (!StringUtils.hasText(invitation.getEmail())) {
        errors.rejectValue("email", "error.RequiredField");
    }

    if (!EMAIL_VALIDATOR.isValid(invitation.getEmail(), null)) {
        errors.rejectValue("email", "error.IncorrectEmailFormat");
    }
}

From source file:org.openregistry.core.web.SearchCriteriaValidator.java

public final void validate(final Object o, final Errors errors) {
    final SearchCriteria searchCriteria = (SearchCriteria) o;

    if (StringUtils.hasText(searchCriteria.getIdentifierValue())
            || StringUtils.hasText(searchCriteria.getName())
            || StringUtils.hasText(searchCriteria.getFamilyName())
            || StringUtils.hasText(searchCriteria.getGivenName()) || searchCriteria.getDateOfBirth() != null) {
        return;/*w ww. ja  v a2 s.  com*/
    }

    errors.reject("search.criteria.empty");
}

From source file:org.eclipse.virgo.ide.beans.core.internal.locate.SpringOsgiConfigLocationUtils.java

/**
 * Similar to {@link #getHeaderLocations(Dictionary)} but looks at a specified header directly.
 *///  w ww.  j  a va  2s.  com
public static String[] getLocationsFromHeader(String header, String defaultValue) {

    String[] ctxEntries;
    if (StringUtils.hasText(header) && !(';' == header.charAt(0))) {
        // get the config locations
        String locations = StringUtils.tokenizeToStringArray(header, DIRECTIVE_SEPARATOR)[0];
        // parse it into individual token
        ctxEntries = StringUtils.tokenizeToStringArray(locations, CONTEXT_LOCATION_SEPARATOR);

        // replace * with a 'digestable' location
        for (int i = 0; i < ctxEntries.length; i++) {
            if (CONFIG_WILDCARD.equals(ctxEntries[i]))
                ctxEntries[i] = defaultValue;
        }
    } else {
        ctxEntries = new String[] { defaultValue };
    }

    return ctxEntries;
}

From source file:com.phoenixnap.oss.ramlapisync.generation.rules.basic.PackageRule.java

@Override
public JPackage apply(ApiResourceMetadata controllerMetadata, JCodeModel generatableType) {
    if (StringUtils.hasText(controllerMetadata.getBasePackage())) {
        return generatableType._package(controllerMetadata.getBasePackage());
    }//from  w  ww.jav a 2 s.  c  om
    return generatableType.rootPackage();
}

From source file:com.springsource.greenhouse.connect.TwitterConnectInterceptor.java

public void preConnect(ConnectionFactory<Twitter> connectionFactory, MultiValueMap<String, String> params,
        WebRequest request) {/*w w w.j  a  va 2s .c  o  m*/
    if (StringUtils.hasText(request.getParameter(POST_TWEET_PARAMETER))) {
        request.setAttribute(POST_TWEET_ATTRIBUTE, Boolean.TRUE, WebRequest.SCOPE_SESSION);
    }
}

From source file:org.springdata.ehcache.config.xml.CacheParser.java

@Override
protected void doParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {

    String name = element.getAttribute("name");
    if (StringUtils.hasText(name)) {
        builder.addPropertyValue("name", name);
    }// w  w w . j a  va2 s  . co m

    String cacheManagerRef = element.getAttribute("cache-manager-ref");
    if (!StringUtils.hasText(cacheManagerRef)) {
        cacheManagerRef = ConfigConstants.CACHE_MANAGER_DEFAULT_ID;
    }
    builder.addPropertyReference("cacheManager", cacheManagerRef);

    postProcess(builder, element);
}

From source file:org.openmrs.module.orderextension.util.OrderSetEditor.java

/**
 * @see PropertyEditorSupport#setAsText(String)
 *//*from w w w.jav a  2 s  .  co  m*/
public void setAsText(String text) throws IllegalArgumentException {
    OrderExtensionService svc = Context.getService(OrderExtensionService.class);
    if (StringUtils.hasText(text)) {
        try {
            setValue(svc.getOrderSet(Integer.valueOf(text)));
        } catch (Exception ex) {
            setValue(svc.getOrderSetByUuid(text));
            if (getValue() == null) {
                log.error("Error setting text: " + text, ex);
                throw new IllegalArgumentException("Order Set not found: " + ex.getMessage());
            }
        }
    } else {
        setValue(null);
    }
}

From source file:org.osmsurround.ra.report.RelationInfo.java

public String getLabel() {
    return StringUtils.hasText(name) ? name : "Relation ID " + relationId;
}

From source file:org.cloudfoundry.identity.uaa.error.JsonAwareAuthenticationEntryPoint.java

public void afterPropertiesSet() throws Exception {
    Assert.state(StringUtils.hasText(realmName), "realmName must be specified");
}