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

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

Introduction

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

Prototype

public static boolean isBlank(String str) 

Source Link

Document

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

Usage

From source file:com.ewcms.publication.freemarker.directive.page.SkipPageNext.java

@Override
public PageOut skip(Integer count, Integer number, String label, UriRuleable rule) throws TemplateException {
    label = StringUtils.isBlank(label) ? DEFAULT_LABEL : label;
    ++number;//from  w  w  w  .ja va  2s  .  c om
    boolean active = (number < count);
    int next = number >= count ? count - 1 : number;
    GeneratorUrl generatorUrl = new GeneratorUrl(rule, number);
    String url = generatorUrl.getUriValue(next);

    return new PageOut(count, next, label, url, active);
}

From source file:com.jstar.eclipse.objects.JavaFilePersistentProperties.java

public static String getJStarRootFolder(final JavaProject project) {
    final String jStarRootFolder = getProperty(project.getProject().getResource(), JSTAR_ROOT_FOLDER);

    if (StringUtils.isBlank(jStarRootFolder)) {
        throw new NoJStarRootFolderException();
    }/*from   w w w . ja  va 2 s .  co m*/

    return jStarRootFolder;
}

From source file:com.autentia.common.util.PasswordUtils.java

public static String generatePasswordHistory(final String password, String passwordHistory) {

    final StringBuilder pwdBuilder = new StringBuilder(password);

    if (!StringUtils.isBlank(passwordHistory)) {
        final String[] pwds = passwordHistory.split(EMPTY_SPACE);

        if (pwds.length > 0) {
            pwdBuilder.append(EMPTY_SPACE).append(pwds[0]);
        }//www .j ava2s . c  om

        if (pwds.length > 1) {
            pwdBuilder.append(EMPTY_SPACE).append(pwds[1]);
        }
    }

    return pwdBuilder.toString();
}

From source file:com.streamreduce.util.HashtagUtil.java

/**
 * Normalizes a string meant to be used as hashtag. Ensures that the returned string is suitable for use as a
 * hashtag by transforming the passed in string to
 * <ul>//w w w  .  ja v  a  2  s .  c o  m
 * <li>trim all leading/trailing whitespace</li>
 * <li>including a # as the first character</li>
 * <li>making all character in the String lower case</li>
 * </ul>
 *
 * @param text The string to be normalized in to a hashtag
 * @return the hashtag normalized String, or a null or empty string if either null or "" are passed in
 */
public static String normalizeTag(String text) {
    if (!StringUtils.isBlank(text)) {
        text = text.trim();
        // if there is no # symbol add it.
        if (!(text.charAt(0) == '#')) {
            text = "#" + text;
        }
        text = text.toLowerCase();
    }
    return text;
}

From source file:com.betfair.cougar.core.impl.AppNameValidation.java

public AppNameValidation(String appName) {
    if (StringUtils.isBlank(appName)) {
        throw new IllegalArgumentException("'cougar.app.name' is a mandatory property");
    }//from www. jav  a 2  s. com
    if (appName.startsWith("-")) {
        throw new IllegalArgumentException("'cougar.app.name' must not start with a '-': '" + appName + "'");
    }
}

From source file:com.ewcms.publication.freemarker.directive.page.SkipPagePrevious.java

@Override
public PageOut skip(Integer count, Integer number, String label, UriRuleable rule) throws TemplateException {

    label = StringUtils.isBlank(label) ? DEFAULT_LABEL : label;
    --number;//from w w w  .  j  a  va2  s.  co m
    boolean active = (number >= 0);
    int prev = number <= 0 ? 0 : (number);
    GeneratorUrl generatorUrl = new GeneratorUrl(rule, number);
    String url = generatorUrl.getUriValue(prev);

    return new PageOut(count, prev, label, url, active);
}

From source file:com.jodo.notify.util.JacksonUtil.java

@SuppressWarnings("unchecked")
public static <T> T toJava(String str, TypeReference<T> typeRef) {
    if (StringUtils.isBlank(str)) {
        return null;
    }/*www.  ja  va  2s . c om*/
    try {
        return (T) mapper.readValue(str, typeRef);
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("String       " + str + "    can not be parse to " + typeRef.getClass().getName());
        throw new RuntimeException(e);
    }
}

From source file:de.tudarmstadt.ukp.csniper.webapp.evaluation.model.Mark.java

public static Mark fromString(String aTitle) {
    if (StringUtils.isBlank(aTitle)) {
        return NA;
    } else {/*from w  ww  . j  av a2  s .c  om*/
        return valueOf(aTitle.toUpperCase());
    }
}

From source file:com.carlomicieli.jtrains.value.constants.Visibility.java

/**
 * Parses the string argument as a {@code Visibility}.
 *
 * @param vis        the string to be parsed
 * @param defaultVis the default {@code Visibility} value
 * @return a {@code Visibility} value/*from  w ww  . j  a v a 2 s . c om*/
 */
public static Visibility parse(String vis, Visibility defaultVis) {
    if (StringUtils.isBlank(vis)) {
        return defaultVis;
    }
    return EnumUtils.parseEnum(Visibility.class, vis);
}

From source file:com.switchfly.inputvalidation.validator.UrlValidator.java

@Override
public boolean execute(String content) {
    if (StringUtils.isBlank(content)) {
        return false;
    }//w ww .  j a v  a  2s  .c om
    String[] schemes = { "http", "https" };
    org.apache.commons.validator.UrlValidator urlValidator = new org.apache.commons.validator.UrlValidator(
            schemes, org.apache.commons.validator.UrlValidator.ALLOW_2_SLASHES);

    if (content.startsWith("http")) {
        return urlValidator.isValid(content);
    }

    return execute("http://www.mock.com/" + content);
}