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.adaptris.core.util.Args.java

/**
 * Convenience to throw an {@link IllegalArgumentException} if the associated argument is the
 * blank string as defined by {@link StringUtils#isBlank(String)}.
 * //from   www  .  ja  v a2  s . c om
 * @param argument the argument.
 * @param member the member name associated with this argument.
 * @return the argument
 */
public static String notBlank(final String argument, final String member) {
    if (StringUtils.isBlank(argument)) {
        throw new IllegalArgumentException(member + " may not be blank/empty/null");
    }
    return argument;
}

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

public MailRecipientField(String email, String name) {
    this.email = email;
    if (!StringUtils.isBlank(name)) {
        this.name = name;
    } else {/*from   www  .java 2  s  .c o  m*/
        this.name = email;
    }
}

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

@Override
public boolean execute(String content) {
    return StringUtils.isBlank(content) || _pattern.matcher(content).matches();
}

From source file:com.cy.driver.user.action.UploadIdentityNumberAction.java

@Override
public String exec() {
    try {/*from  ww  w. j ava  2s. c o m*/
        String id = request.getParameter("driverId"),
                identityNumber = request.getParameter("identityLicenseNum");

        if (StringUtils.isBlank(id)) {
            sendResponseToJson("-9", "?.");
            log.warn("?.");
            return ERROR;
        }
        int accFlag = operationLogService.checkUser(id);
        if (accFlag == 1) {
            log.info("?");
            sendResponseToJson("-9", "?");
            return ERROR;
        } else if (accFlag == 11) {
            log.info("");
            sendResponseToJson("-9", "");
            return ERROR;
        }
        log2Db(id);

        if (StringUtils.isBlank(identityNumber)) {
            sendResponseToJson("-8", "???");
            log.warn("???");
            return ERROR;
        }
        if (!ValidateUtil.validateIdentityLicenseNum(identityNumber)) {
            sendResponseToJson("-8", "?????");
            log.warn("?????");
            return ERROR;
        }
        DriverUserInfoBo bo = new DriverUserInfoBo();
        bo.setId(Integer.parseInt(id));
        bo.setIdentityLicenseNum(identityNumber);
        int i = driverUserCargoInfoService.updateDriverUserInfo(bo);
        if (i == 1) {
            sendResponseToJson("1", "??.");
            log.info("??");
        } else {
            sendResponseToJson("0", "?.");
            log.info("?.");
        }
    } catch (Exception e) {
        try {
            sendResponseToJson("-8", e.getMessage());
            log.error(e.getMessage());
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        e.printStackTrace();
    }
    return SUCCESS;
}

From source file:com.yahoo.sql4d.indexeragent.meta.Utils.java

/**
 * //from  ww  w .  j  av a  2 s  .  c  o m
 * @param dateStr
 * @param n
 * @param freqInMinutes
 * @return 
 */
public static DateTime nthDateOf(String dateStr, int n, int freqInMinutes) {
    if (StringUtils.isBlank(dateStr)) {
        throw new IllegalArgumentException("Invalid dateStr " + dateStr);
    }
    int year = 0;
    int month = 1;
    int day = 1;
    int hour = 0;
    int min = 0;

    try {
        if (dateStr.length() >= 4) {
            year = fourFormat.parse(dateStr.substring(0, 4)).intValue();
            if (dateStr.length() >= 6) {
                month = twoFormat.parse(dateStr.substring(4, 6)).intValue();
                if (dateStr.length() >= 8) {
                    day = twoFormat.parse(dateStr.substring(6, 8)).intValue();
                    if (dateStr.length() >= 10) {
                        hour = twoFormat.parse(dateStr.substring(8, 10)).intValue();
                        if (dateStr.length() >= 12) {
                            min = twoFormat.parse(dateStr.substring(10, 12)).intValue();
                        }
                    }
                }
            }
        }
    } catch (ParseException ex) {
        throw new IllegalArgumentException("Invalid dateStr " + dateStr + " " + ex);
    }
    return new DateTime(DateTimeZone.UTC).withYear(year).withMonthOfYear(month).withDayOfMonth(day)
            .withHourOfDay(hour).withMinuteOfHour(min).withSecondOfMinute(0).withMillisOfSecond(0)
            .plusMinutes(n * freqInMinutes);
}

From source file:com.alibaba.ims.platform.util.DateUtil.java

/**
 * ?//ww  w  .j  a  va2s .c  o m
 *
 * @param dateStr
 * @return
 */
public static Date parse(String dateStr) {
    if (StringUtils.isBlank(dateStr)) {
        return null;
    }
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    try {
        return simpleDateFormat.parse(dateStr);
    } catch (ParseException e) {
        logger.error("Parse string to date error.", e);
        return null;
    }
}

From source file:cec.easyshop.storefront.filters.btg.RefererHeaderBtgFilter.java

@Override
protected AbstractBTGRuleDataEvent getEvent(final HttpServletRequest request) {
    RefererHeaderUsedBTGRuleDataEvent result = null;
    final String referrer = request.getHeader(REFERER_HEADER_NAME);
    if (!StringUtils.isBlank(referrer)) {
        result = new RefererHeaderUsedBTGRuleDataEvent(referrer);
    }/*from www  . j av  a 2 s . co  m*/
    return result;
}

From source file:com.fengduo.bee.commons.util.NumberParser.java

public static int parseInt(String qscore, int defaultValue) {
    if (StringUtils.isBlank(qscore)) {
        return defaultValue;
    }/*from   w  ww  . jav a2 s  .  c  om*/
    try {
        return Integer.parseInt(qscore);
    } catch (Exception e) {
        return defaultValue;
    }
}

From source file:com.leixl.easyframework.doc.dao.impl.EDongxiDaoImpl.java

public Pagination getPage(String title, Boolean disabled, int pageNo, int pageSize) {
    Finder f = Finder.create("select bean from EDongxi bean");
    f.append(" where 1=1");
    if (!StringUtils.isBlank(title)) {
        f.append(" and bean.title like :title");
        f.setParam("title", "%" + title + "%");
    }/*from  ww  w  .  j  a v  a2s .co  m*/
    if (disabled != null) {
        f.append(" and bean.disabled=:disabled");
        f.setParam("disabled", disabled);
    }
    f.append(" order by bean.id desc");
    return find(f, pageNo, pageSize);
}

From source file:com.partnet.automation.Browser.java

/**
 * Returns the Browser enum constant found from the browserName. If
 * browserName is null or blank, null is returned.
 * //from  ww w  .ja v a  2  s. com
 * @param browserName string representation of the enum constant
 * @return null if browserName is blank or null, otherwise returns the enum
 *         constant
 * @throws IllegalArgumentException
 *           if a Browser enum constant could not be found
 */
public static Browser valueOfByName(String browserName) {
    if (StringUtils.isBlank(browserName))
        return null;

    return Browser.valueOf(browserName);
}