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:csns.web.editor.StandingPropertyEditor.java

@Override
public void setAsText(String text) throws IllegalArgumentException {
    if (StringUtils.hasText(text))
        setValue(standingDao.getStanding(Long.valueOf(text)));
}

From source file:uk.co.bssd.monitoring.spring.CsvFileLoggerBeanDefinitionParser.java

@Override
protected void doParse(Element element, BeanDefinitionBuilder bean) {
    String id = element.getAttribute("id");
    bean.addConstructorArgValue(id);/*from w w  w . j a  v  a  2s . c  o  m*/

    String filename = element.getAttribute("filename");

    if (!StringUtils.hasText(filename)) {
        filename = id + ".csv";
    }

    bean.addConstructorArgValue(filename);
}

From source file:org.cleverbus.core.common.asynch.LogContextHelper.java

/**
 * Set log context parameters, specifically:
 * <ul>//from  w  ww . j  a  v  a2s.com
 *     <li>{@link LogContextFilter#CTX_SOURCE_SYSTEM}
 *     <li>{@link LogContextFilter#CTX_CORRELATION_ID}
 *     <li>{@link LogContextFilter#CTX_PROCESS_ID}
 *     <li>{@link LogContextFilter#CTX_REQUEST_ID}
 * </ul>
 *
 * It's because child threads don't inherits this information from parent thread automatically.
 * If there is no request ID defined then new ID is created.
 *
 * @param message the message
 * @param requestId the request ID
 */
public static void setLogContextParams(Message message, @Nullable String requestId) {
    Assert.notNull(message, "the message must not be null");

    // source system
    Log.setContextValue(LogContextFilter.CTX_SOURCE_SYSTEM, message.getSourceSystem().getSystemName());

    // correlation ID
    Log.setContextValue(LogContextFilter.CTX_CORRELATION_ID, message.getCorrelationId());

    // process ID
    Log.setContextValue(LogContextFilter.CTX_PROCESS_ID, message.getProcessId());

    // request ID
    if (StringUtils.hasText(requestId)) {
        Log.setContextValue(LogContextFilter.CTX_REQUEST_ID, requestId);
    } else {
        Log.setContextValue(LogContextFilter.CTX_REQUEST_ID, new GUID().toString());
    }
}

From source file:org.hdiv.config.xml.ValidationBeanDefinitionParser.java

protected void doParse(Element element, BeanDefinitionBuilder bean) {

    String componentType = element.getAttribute("componentType");

    if (StringUtils.hasText(componentType)) {
        bean.addPropertyValue("componentType", componentType);

    }/*w ww .  ja  v  a2s .co  m*/

    NodeList list = element.getChildNodes();

    for (int i = 0; i < list.getLength(); i++) {
        Node node = list.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            if (node.getLocalName().equalsIgnoreCase("acceptedPattern")) {

                String value = node.getTextContent();
                if (StringUtils.hasText(value)) {
                    bean.addPropertyValue("acceptedPattern", value);
                }
            }

            if (node.getLocalName().equalsIgnoreCase("rejectedPattern")) {

                String value = node.getTextContent();
                if (StringUtils.hasText(value)) {
                    bean.addPropertyValue("rejectedPattern", value);
                }
            }
        }
    }

}

From source file:org.openmrs.module.idgen.propertyeditor.IdentifierSourceEditor.java

/**
 * @see PropertyEditorSupport#setAsText(String)
 *//*  ww w .j  ava  2  s  .  c o  m*/
public void setAsText(String text) throws IllegalArgumentException {
    if (StringUtils.hasText(text)) {
        try {
            IdentifierSourceService iss = Context.getService(IdentifierSourceService.class);
            setValue(iss.getIdentifierSource(Integer.valueOf(text)));
        } catch (Exception e) {
            throw new IllegalArgumentException("IdentifierSource not found for " + text, e);
        }
    } else {
        setValue(null);
    }
}

From source file:fr.univlorraine.mondossierweb.utils.PropertyUtils.java

/** Retourne l'index elasticSearch */
public static String getElasticSearchIndex() {
    String value = System.getProperty("context.param.elasticsearch.index");
    if (!StringUtils.hasText(value))
        throw new NullPointerException("param.elasticsearch.index cannot be null !");
    return value;
}

From source file:org.web4thejob.orm.validation.ServerPathValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (!StringUtils.hasText(value))
        return true;

    try {/*from  w ww  .  j  a  v a2s  .co m*/
        return ContextUtil.resourceExists(value) && ContextUtil.getResource(value).getFile().isDirectory();
    } catch (IOException e) {
        return false;
    }
}

From source file:com.consol.citrus.admin.converter.endpoint.ChannelEndpointConverter.java

@Override
public EndpointModel convert(ChannelEndpointModel model) {
    EndpointModel endpointModel = new EndpointModel(getEndpointType(), model.getId(),
            getSourceModelClass().getName());

    if (StringUtils.hasText(model.getChannelName())) {
        endpointModel.add(property("channelName", "Channel", model));
    } else {//from  www .  ja v a  2  s.c  o  m
        endpointModel.add(property("channel", model));
    }

    endpointModel.add(property("messagingTemplate", model).optionKey(MessagingTemplate.class.getName()));
    endpointModel.add(property("channelResolver", model).optionKey(DestinationResolver.class.getName()));

    addEndpointProperties(endpointModel, model);

    return endpointModel;
}

From source file:org.jasig.cas.web.flow.AbstractNonInteractiveCredentialsAction.java

protected final boolean isRenewPresent(final RequestContext context) {
    return StringUtils.hasText(context.getRequestParameters().get("renew"));
}

From source file:csns.web.controller.CourseController.java

@RequestMapping("/course/search")
public String search(@RequestParam(required = false) String term, ModelMap models) {
    if (StringUtils.hasText(term))
        models.addAttribute("courses", courseDao.searchCourses(term, -1));

    return "course/search";
}