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:fr.xebia.management.config.ServletContextAwareMBeanServerDefinitionParser.java

@Override
protected String resolveId(Element element, AbstractBeanDefinition definition, ParserContext parserContext) {
    String id = element.getAttribute(ID_ATTRIBUTE);
    if (!StringUtils.hasText(id)) {
        id = MBEAN_SERVER_BEAN_NAME;//from ww  w. jav a  2 s.  c  o m
    }
    return id;
}

From source file:org.codehaus.mojo.hibernate3.processor.ProcessorUtil.java

/**
 * Supports the retrieval of properties from the maven property.
 *
 * @param processorsProperty the property
 * @return the list containing the synthesized classes
 */// w w  w  .  j ava 2s .c o m
public static List<Class<? extends GeneratedClassProcessor>> parseProcesssorsFromProperty(String delim,
        String processorsProperty) throws Throwable {
    List<Class<? extends GeneratedClassProcessor>> processorClasses = new ArrayList<Class<? extends GeneratedClassProcessor>>();
    if (StringUtils.hasText(processorsProperty)) {
        List<String> arrs = new ArrayList<String>();
        if (processorsProperty.contains(delim)) {
            String[] els = processorsProperty.split(delim);
            Collections.addAll(arrs, els);
        } else {
            arrs.add(processorsProperty);
        }
        for (String cn : arrs) {
            Class<? extends GeneratedClassProcessor> processorClazz = (Class<? extends GeneratedClassProcessor>) Class
                    .forName(cn);
            processorClasses.add(processorClazz);
        }
    }
    // required for everything else, basically
    processorClasses.add(RequiredImportProcessor.class);
    return processorClasses;
}

From source file:it.f2informatica.pagination.services.PageableFactoryImpl.java

@Override
public Optional<Sort> getSort(QueryParameters parameters) {
    final String sortColumn = parameters.getSortColumn();
    final String sortDirection = parameters.getSortDirection();

    return (StringUtils.hasText(sortColumn) && StringUtils.hasText(sortDirection))
            ? Optional.of(new Sort(getDirection(sortDirection), suppressUniquePrefixIfAny(sortColumn)))
            : Optional.<Sort>absent();
}

From source file:com.frank.search.solr.server.config.EmbeddedSolrServerBeanDefinitionParser.java

private void setSolrHome(Element element, BeanDefinitionBuilder builder) {
    String solrHome = element.getAttribute("solrHome");
    if (StringUtils.hasText(solrHome)) {
        builder.addPropertyValue("solrHome", solrHome);
    }//from   w w w.  j ava 2 s . co  m
}

From source file:com.roncoo.jui.common.dao.impl.DataDictionaryListDaoImpl.java

@Override
public Page<RcDataDictionaryList> listForPage(int currentPage, int numPerPage, String fieldCode,
        RcDataDictionaryList rcDataDictionaryList) {
    RcDataDictionaryListExample example = new RcDataDictionaryListExample();
    Criteria c = example.createCriteria();
    c.andFieldCodeEqualTo(fieldCode);/*  w ww  .  java  2  s  .  co m*/

    // 
    if (StringUtils.hasText(rcDataDictionaryList.getFieldKey())) {
        c.andFieldKeyEqualTo(rcDataDictionaryList.getFieldKey());
    }

    // ?
    example.setOrderByClause("sort asc, update_time desc");

    int totalCount = mapper.countByExample(example);
    numPerPage = SqlUtil.checkPageSize(numPerPage);
    currentPage = SqlUtil.checkPageCurrent(totalCount, numPerPage, currentPage);
    example.setLimitStart(SqlUtil.countOffset(currentPage, numPerPage));
    example.setPageSize(numPerPage);
    return new Page<RcDataDictionaryList>(totalCount, SqlUtil.countTotalPage(totalCount, numPerPage),
            currentPage, numPerPage, mapper.selectByExample(example));
}

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

/**
 * Returns the location headers (if any) specified by the Blueprint-Bundle header (if available). The returned
 * Strings can be sent to a {@link org.springframework.core.io.ResourceLoader} for loading the configurations.
 * //from  w ww .j av a 2 s .c  o  m
 * Different from {@link ConfigUtils#getLocationsFromHeader(String, String)} since "," is used for separating
 * clauses while ; is used inside a clause to allow parameters or directives besides paths.
 * 
 * Since the presence of the header, disables any processing this method will return null if the header is not
 * specified, an empty array if it's empty (disabled) or a populated array otherwise.
 */
public static String[] getBlueprintHeaderLocations(Dictionary<String, String> headers) {
    String header = getBlueprintHeader(headers);

    // no header specified
    if (header == null) {
        return null;
    }

    // empty header specified
    if (header.length() == 0) {
        return new String[0];
    }

    List<String> ctxEntries = new ArrayList<String>(4);
    if (StringUtils.hasText(header)) {
        String[] clauses = header.split(COMMA);
        for (String clause : clauses) {
            // split into directives
            String[] directives = clause.split(SEMI_COLON);
            if (!ObjectUtils.isEmpty(directives)) {
                // check if it's a path or not
                for (String directive : directives) {
                    if (!directive.contains(EQUALS)) {
                        ctxEntries.add(directive.trim());
                    }
                }
            }
        }
    }

    // replace * with a 'digestable' location
    for (int i = 0; i < ctxEntries.size(); i++) {
        String ctxEntry = ctxEntries.get(i);
        if (SpringOsgiConfigLocationUtils.CONFIG_WILDCARD.equals(ctxEntry))
            ctxEntry = "/META-INF/spring/*.xml";
    }

    return (String[]) ctxEntries.toArray(new String[ctxEntries.size()]);
}

From source file:it.f2informatica.webapp.utils.HttpRequest.java

/**
 * Returns the current locale associated to this request
 * if any has been selected, otherwise it will return the
 * default browser locale.//ww  w  .java 2  s . co  m
 *
 * @return the current locale
 */
public Locale getLocale() {
    String languageParam = getHttpServletRequest().getParameter(WebApplicationConfig.LANGUAGE);
    if (StringUtils.hasText(languageParam)) {
        return LocaleUtils.toLocale(languageParam);
    }
    Cookie cookie = getCookie(WebApplicationConfig.CURRENT_LOCALE_COOKIE);
    return (cookie != null) ? LocaleUtils.toLocale(cookie.getValue()) : getHttpServletRequest().getLocale();
}

From source file:com.example.securelogin.selenium.loginform.page.welcome.TopPage.java

public boolean isExpiredMessageShown() {
    return StringUtils.hasText(getExpiredMessage());
}

From source file:springfox.documentation.swagger.readers.operation.OperationHttpMethodReader.java

@Override
public void apply(OperationContext context) {
    HandlerMethod handlerMethod = context.getHandlerMethod();

    ApiOperation apiOperationAnnotation = handlerMethod.getMethodAnnotation(ApiOperation.class);

    if (apiOperationAnnotation != null && StringUtils.hasText(apiOperationAnnotation.httpMethod())) {
        String apiMethod = apiOperationAnnotation.httpMethod();
        try {//  w ww. jav a  2 s.  co m
            RequestMethod.valueOf(apiMethod);
            context.operationBuilder().method(HttpMethod.valueOf(apiMethod));
        } catch (IllegalArgumentException e) {
            log.error("Invalid http method: " + apiMethod + "Valid ones are [" + RequestMethod.values() + "]",
                    e);
        }
    }
}

From source file:nl.surfnet.coin.teams.domain.InvitationForm.java

public boolean hasCsvFile() {
    return csvFile != null && StringUtils.hasText(csvFile.getOriginalFilename());
}