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

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

Introduction

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

Prototype

public static String trimToEmpty(final String str) 

Source Link

Document

Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null .

Usage

From source file:com.github.binlee1990.spider.movie.spider.MovieCrawler.java

private void setFilmReviewCount(Elements countElements, FilmReview filmReview) {
    countElements.forEach(countElement -> {
        String countDesc = StringUtils.trimToEmpty(countElement.select(".fm-mu-label").text());
        String countStr = StringUtils.trimToEmpty(countElement.select(".fm-mu-number").text());
        if (StringUtils.isNotBlank(countDesc) && StringUtils.isNotBlank(countStr)) {
            int count = 0;
            try {
                count = Integer.parseInt(countStr);
            } catch (Exception e) {
            }/*from   w  w  w.  j a va  2s.  c o  m*/
            if (count < 0) {
                count = 0;
            }

            if (StringUtils.equalsIgnoreCase(countDesc, "")) {
                filmReview.setCountPlan(count);
            }
            if (StringUtils.equalsIgnoreCase(countDesc, "")) {
                filmReview.setCountWatched(count);
            }
            if (StringUtils.equalsIgnoreCase(countDesc, "")) {
                filmReview.setCountLike(count);
            }
            if (StringUtils.equalsIgnoreCase(countDesc, "?")) {
                filmReview.setCountDislike(count);
            }
        }
    });
}

From source file:net.community.chest.gitcloud.facade.frontend.git.GitController.java

String authenticate(HttpServletRequest req) throws IOException {
    Principal principal = req.getUserPrincipal(); // check if already authenticated
    String username = (principal == null) ? null : principal.getName();
    if (!StringUtils.isEmpty(username)) {
        if (logger.isDebugEnabled()) {
            logger.debug("authenticate(" + req.getMethod() + ")[" + req.getRequestURI() + "]["
                    + req.getQueryString() + "]" + " using principal=" + username);
        }/*  w w w  .j a v  a 2s .co  m*/

        return username;
    }

    // TODO try to authenticate by cookie (if feature allowed) - see GitBlit#authenticate
    String authorization = StringUtils.trimToEmpty(req.getHeader(AUTH.WWW_AUTH_RESP));
    if (StringUtils.isEmpty(authorization)) {
        if (logger.isDebugEnabled()) {
            logger.debug("authenticate(" + req.getMethod() + ")[" + req.getRequestURI() + "]["
                    + req.getQueryString() + "] no authorization data");
        }
        return null;
    }

    // TODO add support for more authorization schemes - including password-less HTTP
    if (!authorization.startsWith(AuthSchemes.BASIC)) {
        logger.warn("authenticate(" + req.getMethod() + ")[" + req.getRequestURI() + "][" + req.getQueryString()
                + "]" + " unsupported authentication scheme: " + authorization);
        return null;
    }

    String b64Credentials = authorization.substring(AuthSchemes.BASIC.length()).trim();
    byte[] credBytes = Base64.decodeBase64(b64Credentials);
    String credentials = new String(credBytes, Charset.forName("UTF-8"));
    String[] credValues = StringUtils.split(credentials, ':');
    Validate.isTrue(credValues.length == 2, "Bad " + AuthSchemes.BASIC + " credentials format: %s",
            credentials);

    username = StringUtils.trimToEmpty(credValues[0]);
    String password = StringUtils.trimToEmpty(credValues[1]);
    if (authenticate(username, password)) {
        return username;
    } else {
        return null;
    }
}

From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java

/**
 * @return the birthplaceVerifiedIndicator
 */
public String getBirthplaceVerifiedIndicator() {
    return StringUtils.trimToEmpty(birthplaceVerifiedIndicator);
}

From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java

/**
 * @return the childClientIndicatorVar
 */
public String getChildClientIndicatorVar() {
    return StringUtils.trimToEmpty(childClientIndicatorVar);
}

From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java

/**
 * @return the clientIndexNumber
 */
@Override
public String getClientIndexNumber() {
    return StringUtils.trimToEmpty(clientIndexNumber);
}

From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java

/**
 * @return the commentDescription
 */
public String getCommentDescription() {
    return StringUtils.trimToEmpty(commentDescription);
}

From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java

/**
 * @return the commonFirstName
 */
public String getCommonFirstName() {
    return StringUtils.trimToEmpty(commonFirstName);
}

From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java

/**
 * @return the commonLastName
 */
public String getCommonLastName() {
    return StringUtils.trimToEmpty(commonLastName);
}

From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java

/**
 * @return the commonMiddleName
 */
public String getCommonMiddleName() {
    return StringUtils.trimToEmpty(commonMiddleName);
}

From source file:gov.ca.cwds.data.persistence.cms.BaseClient.java

/**
 * @return the confidentialityInEffectIndicator
 */
public String getConfidentialityInEffectIndicator() {
    return StringUtils.trimToEmpty(confidentialityInEffectIndicator);
}