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

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

Introduction

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

Prototype

public static boolean isEmpty(String str) 

Source Link

Document

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

Usage

From source file:com.kylinolap.common.util.HadoopUtil.java

/**
 * e.g. "hbase:kylin-local.corp.ebay.com:2181:/hbase-unsecure"
 *//*from  www.  ja va 2s .  c  om*/
public static Configuration newHBaseConfiguration(String url) {
    Configuration conf = HBaseConfiguration.create();
    if (StringUtils.isEmpty(url))
        return conf;

    // chop off "hbase:"
    if (url.startsWith("hbase:") == false)
        throw new IllegalArgumentException("hbase url must start with 'hbase:' -- " + url);

    url = StringUtils.substringAfter(url, "hbase:");
    if (StringUtils.isEmpty(url))
        return conf;

    // case of "hbase:domain.com:2181:/hbase-unsecure"
    Pattern urlPattern = Pattern.compile("([\\w\\d\\-.]+)[:](\\d+)(?:[:](.*))?");
    Matcher m = urlPattern.matcher(url);
    if (m.matches() == false)
        throw new IllegalArgumentException("HBase URL '" + url + "' is invalid, expected url is like '"
                + "hbase:domain.com:2181:/hbase-unsecure" + "'");

    logger.debug("Creating hbase conf by parsing -- " + url);

    String quorum = m.group(1);
    try {
        InetAddress.getByName(quorum);
    } catch (UnknownHostException e) {
        throw new IllegalArgumentException("Zookeeper quorum is invalid: " + quorum + "; urlString=" + url, e);
    }
    conf.set(HConstants.ZOOKEEPER_QUORUM, quorum);

    String port = m.group(2);
    conf.set(HConstants.ZOOKEEPER_CLIENT_PORT, port);

    String znodePath = m.group(3) == null ? "" : m.group(3);
    if (StringUtils.isEmpty(znodePath) == false)
        conf.set(HConstants.ZOOKEEPER_ZNODE_PARENT, znodePath);

    // reduce rpc retry
    conf.set(HConstants.HBASE_CLIENT_PAUSE, "3000");
    conf.set(HConstants.HBASE_CLIENT_RETRIES_NUMBER, "5");
    conf.set(HConstants.HBASE_CLIENT_OPERATION_TIMEOUT, "60000");
    // conf.set(ScannerCallable.LOG_SCANNER_ACTIVITY, "true");

    return conf;
}

From source file:com.sangupta.pep.macros.FxMacro.java

@Override
public ContentAndClasses process(String content, File parentDir) {
    final ContentAndClasses cc = new ContentAndClasses(content);

    if (StringUtils.isEmpty(content)) {
        return cc;
    }/* ww  w .j  a v  a2 s.c  o m*/

    Matcher matcher = PATTERN.matcher(content);
    if (matcher.matches()) {
        StringBuilder builder = new StringBuilder();
        builder.append(matcher.group(1));

        builder.append(matcher.group(3));

        String newContent = builder.toString();

        cc.setContent(newContent);
        String[] classNames = matcher.group(2).split(" ");
        for (String className : classNames) {
            cc.addClass(className);
        }
    }

    return cc;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.phd.validator.EmailListValidator.java

public boolean validateEmailList(String emailListString) {
    if (!StringUtils.isEmpty(emailListString)) {
        String[] emails = emailListString.split(",");
        for (String emailString : emails) {
            final String email = emailString.trim();
            if (!email.matches(EMail.W3C_EMAIL_SINTAX_VALIDATOR)) {
                return false;
            }/*  w  w  w. j  a v  a 2 s  .c  om*/
        }
    }

    return true;
}

From source file:com.pedra.storefront.forms.validation.ReviewValidator.java

@Override
public void validate(final Object object, final Errors errors) {
    final ReviewForm reviewForm = (ReviewForm) object;
    final String headLine = reviewForm.getHeadline();
    final String comment = reviewForm.getComment();
    final Double rating = reviewForm.getRating();

    if (StringUtils.isEmpty(headLine) || StringUtils.length(headLine) > 255) {
        errors.rejectValue("headline", "review.headline.invalid");
    }//ww  w.  j a  va 2s .c  o  m

    if (StringUtils.isEmpty(comment) || StringUtils.length(comment) > 4000) {
        errors.rejectValue("comment", "review.comment.invalid");
    }

    if (rating == null || rating.doubleValue() < 1 || rating.doubleValue() > 5) {
        errors.rejectValue("rating", "review.rating.invalid");
    }
}

From source file:com.sailing.hrm.persistent.form.dao.DbTableDao.java

/**
 * DDL/*from  ww w. j  a  v  a 2  s .c  o m*/
 * @param ddl
 */
public void create(String ddl) {
    if (StringUtils.isEmpty(ddl))
        return;
    if (ddl.indexOf(DEFAULT_DELIMITER) != -1) {
        String[] sqls = ddl.split(DEFAULT_DELIMITER);
        for (String sql : sqls) {
            SQLQuery query = super.createSQLQuery(sql + DEFAULT_DELIMITER);
            query.executeUpdate();
        }
    }
}

From source file:com.pureinfo.tgirls.servlet.GetScriptServlet.java

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    String scriptType = request.getParameter("scriptType");
    if (StringUtils.isEmpty(scriptType)) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST);
        return;//w w  w. ja v  a  2 s  . co  m
    }

    String location = null;
    String userId = null;
    String photoId = null;
    ScriptType st = null;//

    try {
        st = ScriptType.getScriptType(Integer.parseInt(scriptType));
    } catch (Exception e) {
    }

    switch (st) {
    case UserInfo:
        userId = request.getParameter("utid");
        location = ScriptManager.mapUserInfoScriptLocation(userId);
        break;
    case UserUpload:
        userId = request.getParameter("utid");
        location = ScriptManager.mapUserUploadScriptLocation(userId);
        break;
    case UserBuy:
        userId = request.getParameter("utid");
        location = ScriptManager.mapUserBuyScriptLocation(userId);
        break;
    case Pic:
        photoId = request.getParameter("picId");
        location = ScriptManager.mapPhotoScriptLocation(photoId);
        break;

    default:
        response.sendError(HttpServletResponse.SC_BAD_REQUEST);
        return;
    }

    if (StringUtils.isEmpty(location)) {
        response.sendError(HttpServletResponse.SC_BAD_REQUEST);
        return;
    }

    location += "?version=" + Math.random();
    logger.debug("return script:" + location);

    response.setHeader("Location", location);
    response.setHeader("Content-Encoding", "gzip");
    response.setStatus(HttpServletResponse.SC_SEE_OTHER);
    response.setHeader("Cache-Control", "no-cache"); //HTTP 1.1
    response.setHeader("Pragma", "no-cache"); //HTTP 1.0
    response.setDateHeader("Expires", -1);
    response.setDateHeader("max-age", 0);

    return;

}

From source file:cn.vlabs.duckling.vwb.tags.AuthorTag.java

@Override
public int doVWBStart() throws Exception {
    DPage page = vwbcontext.getPage();//from w w w  . j  av a 2  s.c  o  m
    String author = page.getAuthor();

    if (StringUtils.isEmpty(author))
        author = "unknown";

    if (!StringUtils.isEmpty(author)) {
        pageContext.getOut().print(UserNameUtil.getAuthorTip(vwbcontext, author));
    } else {
        pageContext.getOut().print("unknown");
    }

    return SKIP_BODY;
}

From source file:com.amalto.core.servlet.TransactionFilter.java

private static TransactionState getState(ServletRequest request) {
    HttpServletRequest httpServlet = (HttpServletRequest) request;
    String transactionId = httpServlet.getHeader(TRANSACTION_ID);
    if (StringUtils.isEmpty(transactionId)) {
        return ImplicitTransactionState.INSTANCE;
    } else {//from   w w  w.j av a  2 s.c  o m
        if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("Transaction ID from HTTP request: " + transactionId);
        }
        return new ExplicitTransaction(transactionId);
    }
}

From source file:com.jaxio.celerio.configuration.validation.NotReservedJavaValidator.java

@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
    if (allowEmpty && (value == null || StringUtils.isEmpty(value))) {
        return true;
    }/*from  w  w w .ja  v  a  2s .co  m*/
    return !JavaKeywords.isReserved(value);
}

From source file:com.enonic.cms.web.portal.page.HTML5HttpResponseFilter.java

@Override
public String filterResponse(final HttpServletRequest request, final String response, final String contentType)
        throws Exception {
    if ("none".equals(doctypeHandler) || StringUtils.isEmpty(doctypeHandler)) {
        return response;
    }/*ww  w  .jav  a2  s . c  om*/

    // handle only text/html
    if (contentType == null || !contentType.startsWith("text/html")) {
        return response;
    }

    final Matcher matcher = DOCTYPE.matcher(response);

    if (matcher.find()) {
        final String doctype = matcher.group(2);

        if ("html5fixer".equals(doctypeHandler) && doctype.contains("\"about:legacy-compat\"")
                || "html5forcer".equals(doctypeHandler) && !doctype.toLowerCase().contains("frameset")) {
            return DOCTYPE_HTML + matcher.group(3);
        }
    }

    return response;
}