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:de.blizzy.documentr.validation.LoginNameValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (StringUtils.isBlank(value)) {
        return true;
    }/*from  www.jav  a 2  s.  c  om*/

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

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

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

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

From source file:aiai.ai.yaml.env.TimePeriods.java

public static TimePeriods from(String s) {
    if (StringUtils.isBlank(s)) {
        return ALWAYS_ACTIVE;
    }/*from www  .j  a v  a 2 s  . c  o m*/

    TimePeriods periods = new TimePeriods();
    for (StringTokenizer st = new StringTokenizer(s, ","); st.hasMoreTokens();) {
        String token = st.nextToken().trim();
        periods.periods.add(asTimePeriod(token));
    }
    return periods;
}

From source file:cc.unlimitedbladeworks.web.restricted.module.screen.TestError.java

public void execute(Context context, HttpServletRequest request, Navigator nav, @Param("code") String code)
        throws Exception {

    if (StringUtils.isBlank(code)) {
        //            CommonUtils.sucess(response, request.getRemoteHost() + " : " + new Date().toString());
        return;/*from   w  ww.  j a  va 2  s  . c  o  m*/
    }

    if (code.equals("500")) {
        throw new Exception(" 500 ");
    }

    if (code.equals("4041")) {
        throw new com.alibaba.citrus.service.template.TemplateNotFoundException(
                " 404 TemplateNotFoundException");
    }

    if (code.equals("4042")) {
        throw new com.alibaba.citrus.service.moduleloader.ModuleNotFoundException(
                " 404 ModuleNotFoundException");
    }

    //        CommonUtils.sucess(response, request.getRemoteHost() + " : " + new Date().toString());
    return;

}

From source file:cop.raml.utils.javadoc.JavaDocUtils.java

public static String clearMacros(String str) {
    if (StringUtils.isBlank(str))
        return null;

    str = Macro.removeAll(str);//  w  ww. j  av a 2  s  .c o m
    str = TagLink.remove(str);
    // TODO link should not be deleted; should be modified
    str = HtmlTag.replaceAll(str);
    str = MULTIPLE_WHITESPACES.matcher(str).replaceAll(StringUtils.SPACE);
    str = Utils.trimLine(str);
    str = str.trim();

    return str.isEmpty() ? null : str;
}

From source file:com.evanzeimet.queryinfo.jpa.field.QueryInfoFieldPathParts.java

public static QueryInfoFieldPathParts fromFullPath(String fullPath) throws QueryInfoException {
    int partCount;
    String[] partArray = null;/*  w w w  .  j  a va2  s . co  m*/

    if (StringUtils.isBlank(fullPath)) {
        partCount = 0;
    } else {
        partArray = fullPath.split("\\.");
        partCount = partArray.length;
    }

    if (partCount == 0) {
        String message = String.format("Found 0 path parts in [%s]", fullPath);
        throw new QueryInfoException(message);
    }

    int joinCount = (partCount - 1);

    List<String> joinAttributeNames = new ArrayList<>(joinCount);

    for (int partIndex = 0; partIndex < joinCount; partIndex++) {
        String joinAttributeName = partArray[partIndex];
        joinAttributeNames.add(joinAttributeName);
    }

    int fieldAttributeNameIndex = (partCount - 1);
    String fieldAttributeName = partArray[fieldAttributeNameIndex];

    QueryInfoFieldPathParts result = new QueryInfoFieldPathParts();

    result.setFieldAttributeName(fieldAttributeName);
    result.setJoinAttributeNames(joinAttributeNames);

    return result;
}

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

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

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

From source file:com.github.britter.beanvalidators.strings.ISBNConstraintValidator.java

@Override
public boolean isValid(final String value, final ConstraintValidatorContext context) {
    // Don't validate null, empty and blank strings, since these are validated by @NotNull, @NotEmpty and @NotBlank
    if (StringUtils.isBlank(value)) {
        return true;
    }/*ww  w.j a v a 2 s .com*/

    switch (type) {
    case ISBN_10:
        return ISBNValidator.getInstance().isValidISBN10(value);
    case ISBN_13:
        return ISBNValidator.getInstance().isValidISBN13(value);
    default:
        return ISBNValidator.getInstance().isValid(value);
    }
}

From source file:com.github.rvesse.airline.restrictions.common.NotBlankRestriction.java

@Override
protected boolean isValid(String value) {
    return !StringUtils.isBlank(value);
}

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

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (StringUtils.isBlank(value)) {
        return true;
    }/* www .j a va  2  s . c  o m*/

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