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:cn.powerdash.libsystem.common.validation.BaseValidator.java

/**
 * //  w w w.  j  ava2  s  . c om
 * Description: TODO
 * 
 * @param context
 * @param fieldName
 * @param messageTemplate
 */
@SuppressWarnings("deprecation")
protected void bindNode(final ConstraintValidatorContext context, final String fieldName,
        String messageTemplate) {
    String template = messageTemplate;
    if (StringUtils.isBlank(messageTemplate)) {
        template = context.getDefaultConstraintMessageTemplate();
    }
    context.disableDefaultConstraintViolation();
    context.buildConstraintViolationWithTemplate(template).addNode(fieldName).addConstraintViolation();
}

From source file:com.alibaba.ims.platform.exception.WebException.java

public WebException(String message, Object... params) {
    if (StringUtils.isBlank(message)) {
        return;/*  ww  w. ja  va  2 s .  c  om*/
    }
    this.message = MessageFormat.format(message, params);
}

From source file:Acciones.EmailAction.java

private boolean validar() {
    boolean flag = true;
    if (StringUtils.isBlank(nombre)) {
        flag = false;//from ww w .j a  v  a 2 s.c om
    }
    if (StringUtils.isBlank(email)) {
        flag = false;
    }
    if (StringUtils.isBlank(telefono)) {
        flag = false;
    }
    if (StringUtils.isBlank(consulta)) {
        flag = false;
    }
    return flag;
}

From source file:de.thischwa.pmcms.view.context.object.Utils.java

/**
 * @return True, is string is empty, otherwise false.
 *///w w  w.  j  a v a  2s. co m
public static boolean isEmpty(final String string) {
    return StringUtils.isBlank(string);
}

From source file:com.greenline.guahao.biz.manager.orderremind.convertors.OrderRemindConvertor.java

public static CustomerApplyQueryDTO convertToCustomerApplyQueryDTO(OrderRemindDO remind) {
    CustomerApplyQueryDTO dto = new CustomerApplyQueryDTO();
    if (null != remind) {
        dto.setPageIndex(1); // ?
        dto.setPageSize(100); // ??
        dto.setCustomerId(null == remind.getCustomerId() ? 0L : Long.valueOf(remind.getCustomerId())); // ?
        dto.setStatus(StringUtils.isBlank(remind.getState()) ? null : Integer.valueOf(remind.getState())); // ?
    }// w  w w .j  a  v a  2 s  . c o m
    return dto;
}

From source file:com.kenai.redminenb.util.RedmineUtil.java

/**
 * Helper method to convert the first letter of a string to uppercase. And
 * prefix the string with some next string.
 *//*from w w w .j  a va  2 s. c  om*/
public static String capitalize(String s) {
    return StringUtils.isBlank(s) ? s : Character.toUpperCase(s.charAt(0)) + s.substring(1);
}

From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.common.util.DateUtils.java

/**
 * Return <code>true</code> if day, month and year have the expected format.
 *
 * @param day//w ww. j  a v a2 s.  c o m
 * @param month
 * @param year
 * @return <code>true</code> if day, month and year have the expected format
 * @throws DateUtilsException if day, month or year do not have the expected format
 */
public static boolean validateDateFormat(final String day, final String month, final String year)
        throws DateUtilsException {

    boolean result = true;

    StringBuilder errorMessage = new StringBuilder();

    if (!YEAR_PATTERN.matcher(year).matches()) {
        errorMessage.append("year '").append(year).append("' expected to be 4 digits");
    }

    if (!MONTH_OR_DAY_PATTERN.matcher(month).matches()) {

        if (!StringUtils.isBlank(errorMessage.toString())) {
            errorMessage.append(", ");
        }

        errorMessage.append("month '").append(month).append("' expected to be 1 or 2 digits");
    }

    if (!MONTH_OR_DAY_PATTERN.matcher(day).matches()) {

        if (!StringUtils.isBlank(errorMessage.toString())) {
            errorMessage.append(", ");
        }

        errorMessage.append("day '").append(day).append("' expected to be 1 or 2 digits");
    }

    if (!StringUtils.isBlank(errorMessage.toString())) {
        throw new DateUtilsException(errorMessage.toString());
    }

    return result;
}

From source file:com.janrain.backplane2.server.MessageRequest.java

public MessageRequest(String callback, String since, String block) {

    if (StringUtils.isNotEmpty(callback)) {
        if (!callback.matches("[\\._a-zA-Z0-9]*")) {
            throw new InvalidRequestException("invalid_request", "Callback parameter value is malformed");
        }// w w w.  j  ava2 s  .co  m
    }

    this.since = StringUtils.isBlank(since) ? "" : since;

    try {
        Integer blockSeconds = Integer.valueOf(block);
        if (blockSeconds < 0 || blockSeconds > MAX_BLOCK_SECONDS) {
            throw new InvalidRequestException("Invalid value for block parameter (" + block
                    + "), must be between 0 and " + MAX_BLOCK_SECONDS);
        }
        this.returnBefore = new Date(System.currentTimeMillis() + blockSeconds.longValue() * 1000);
    } catch (NumberFormatException e) {
        throw new InvalidRequestException(
                "Invalid value for block parameter (" + block + "): " + e.getMessage());
    }

}

From source file:com.b5m.user.frame.util.DateUtils.java

public static Date String2Date(String dateStr) {
    if (StringUtils.isBlank(dateStr)) {
        return null;
    }//from  ww w.j  av  a2s . c  o m
    return String2Date(dateStr, "yyyyMMdd");
}

From source file:com.univocity.articles.kairosdb.custom.KairosDataStoreConfiguration.java

public KairosDataStoreConfiguration(String dataStoreName, String url) {
    super(dataStoreName);
    if (StringUtils.isBlank(url)) {
        throw new IllegalArgumentException("KairosDB connection URL cannot be null.");
    }//from   www.j ava 2s  .  c  o  m
    this.url = url;
}