Example usage for org.apache.commons.lang3 StringUtils isBlank

List of usage examples for org.apache.commons.lang3 StringUtils isBlank

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isBlank.

Prototype

public static boolean isBlank(final CharSequence cs) 

Source Link

Document

Checks if a CharSequence is whitespace, empty ("") or null.

 StringUtils.isBlank(null)      = true StringUtils.isBlank("")        = true StringUtils.isBlank(" ")       = true StringUtils.isBlank("bob")     = false StringUtils.isBlank("  bob  ") = false 

Usage

From source file:com.thoughtworks.go.domain.DefaultCommentRenderer.java

public String render(String text) {
    if (StringUtils.isBlank(text)) {
        return "";
    }//from w w  w  . jav  a 2 s  .co m
    if (regex.isEmpty() || link.isEmpty()) {
        Comment comment = new Comment();
        comment.escapeAndAdd(text);
        return comment.render();
    }
    try {
        Matcher matcher = Pattern.compile(regex).matcher(text);
        int start = 0;
        Comment comment = new Comment();
        while (hasMatch(matcher)) {
            comment.escapeAndAdd(text.substring(start, matcher.start()));
            comment.add(dynamicLink(matcher));
            start = matcher.end();
        }
        comment.escapeAndAdd(text.substring(start));
        return comment.render();
    } catch (PatternSyntaxException e) {
        LOGGER.warn("Illegal regular expression: {} - {}", regex, e.getMessage());
    }
    return text;
}

From source file:gov.nih.nci.caintegrator.domain.application.AbstractGenomicCriterion.java

/**
 * @return the gene symbols.//  ww w . j  a  v  a2  s .co m
 */
public Set<String> getGeneSymbols() {
    Set<String> geneSymbols = new HashSet<String>();
    if (StringUtils.isBlank(geneSymbol)) {
        return geneSymbols;
    }
    geneSymbols.addAll(Arrays.asList(getGeneSymbol().replaceAll("\\s*", "").split(",")));
    return geneSymbols;
}

From source file:com.thoughtworks.go.server.web.TokenManager.java

public boolean verify(HttpServletRequest request) {
    String postedToken = request.getParameter(TOKEN);
    String expectedToken = (String) request.getSession().getAttribute(TOKEN);
    return !StringUtils.isBlank(postedToken) && !StringUtils.isBlank(expectedToken)
            && postedToken.equals(expectedToken);
}

From source file:cd.go.authentication.ldap.utils.Util.java

public static List<String> listFromCommaSeparatedString(String str) {
    if (StringUtils.isBlank(str)) {
        return Collections.emptyList();
    }//from  ww  w. ja v a  2 s .  c  o  m
    return Arrays.asList(str.split("\\s*,\\s*"));
}

From source file:de.blizzy.documentr.validation.BranchNameBlacklistValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (StringUtils.isBlank(value)) {
        return true;
    }//from  w ww  .j  av  a 2 s  . com

    return !Pattern.matches("^" + DocumentrConstants.BRANCH_NAMES_BLACKLIST_PATTERN + "$", value); //$NON-NLS-1$ //$NON-NLS-2$
}

From source file:com.esofthead.mycollab.common.domain.SimpleActivityStream.java

public String getCreatedUserFullName() {
    if (StringUtils.isBlank(createdUserFullName)) {
        return com.esofthead.mycollab.core.utils.StringUtils.extractNameFromEmail(getCreateduser());
    }//  w w w . j  av  a  2  s. com
    return createdUserFullName;
}

From source file:com.mycompany.crawlertest.GrabPage.java

private void processLinks(Elements links) {
    for (Element link : links) {
        String href = link.attr("href");
        if (StringUtils.isBlank(href) || href.startsWith("#")) {
            continue;
        }// w w w .  j  a va2s. co  m
        try {
            URL nextUrl = new URL(url, href);
            Uttils.URLS.add(href);
            urlList.add(nextUrl);
        } catch (MalformedURLException e) { // ignore bad urls
        }
    }
}

From source file:de.blizzy.documentr.validation.ProjectNameBlacklistValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (StringUtils.isBlank(value)) {
        return true;
    }/*  w  ww.  j  a va2  s  .co m*/

    return !Pattern.matches("^" + DocumentrConstants.PROJECT_NAMES_BLACKLIST_PATTERN + "$", value); //$NON-NLS-1$ //$NON-NLS-2$
}

From source file:com.jim.im.exception.ImJsonParseExceptionMapper.java

@Override
public Response toResponse(JsonParseException e) {
    ApiErrorCode errorCode = ApiErrorCode.PARAM_ERROR;

    String errorMsg = e.getMessage();
    if (StringUtils.isBlank(errorMsg)) {
        errorMsg = IMConstant.MSG_PARAM_ERROR;
    }/*w ww  .j  a  v a  2  s. com*/

    String requestId = RequestContext.get(IMConstant.REQUEST_ID);

    ApiErrorCodeException errorCodeException = new ApiErrorCodeException(requestId, errorCode, errorMsg, e);
    logger.error(requestId, errorCodeException);

    return RestResult.failure(requestId, errorCode.errorCode, errorMsg);
}

From source file:com.sonicle.webtop.core.app.util.ClassHelper.java

public static Class loadClass(boolean skipIfBlank, String className, Class requiredParentClass,
        String targetDescription) {
    if (skipIfBlank && StringUtils.isBlank(className)) {
        return null;
    } else {/*from  w  w w  . jav  a2  s  .  c  o m*/
        return loadClass(className, requiredParentClass, targetDescription);
    }
}