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

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

Introduction

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

Prototype

public static boolean isEmpty(final CharSequence cs) 

Source Link

Document

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

 StringUtils.isEmpty(null)      = true StringUtils.isEmpty("")        = true StringUtils.isEmpty(" ")       = false StringUtils.isEmpty("bob")     = false StringUtils.isEmpty("  bob  ") = false 

NOTE: This method changed in Lang version 2.0.

Usage

From source file:com.fdorigo.rmfly.wicket.ViewScorePage.java

public ViewScorePage(PageParameters params) {

    final String nNumberString = params.get("nNumber").toString();

    if (StringUtils.isEmpty(nNumberString)) {
        validNnumber = false;/*from   ww w  .  ja v a2s .com*/
    } else {
        record = recordFacade.find(nNumberString);
        if (record != null) {
            validNnumber = true;
        } else {
            validNnumber = false;
        }
    }

    init();
}

From source file:com.google.mr4c.content.S3Credentials.java

public boolean isValid() {
    return !(StringUtils.isEmpty(m_id) || StringUtils.isEmpty(m_secret));
}

From source file:com.sunney.eweb.controller.LoginController.java

@RequestMapping(value = "/checkLogin", method = RequestMethod.POST)
@ResponseBody// ww w. j  a  v  a2s.  com
public Object checkLogin(HttpServletRequest request) {
    HttpSession session = request.getSession();
    String userId = request.getParameter("userId");
    String password = request.getParameter("password");
    Result result = new Result();
    if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(password)) {

    }
    logger.info("======================" + userId + password);
    UsersDTO user = usersService.queryUsersByUserId(userId);
    if (user != null) {
        if (user.getPassword().equals(password)) {
            logger.info("login success");
            result.setSuccess(true);
            result.setInfoCode("success");
            session.setAttribute(GlobalConstant.ADMIN_COOKIE_NAME, user);
        } else {
            result.setSuccess(false);
            result.setInfoCode("??");
            logger.info("??");
        }
    } else {
        result.setSuccess(false);
        result.setInfoCode("?");
        logger.info("?");
    }
    return result;
}

From source file:models.PersistentObjectModel.java

@Override
public boolean equals(Object obj) {
    if (obj instanceof PersistentObjectModel) {
        if (super.equals(obj) || StringUtils.isEmpty(this.type)
                || StringUtils.isEmpty(((PersistentObjectModel) obj).type)) {
            return StringUtils.equals(this.id, ((PersistentObjectModel) obj).id);
        }/*from w  w  w.  j  a  va 2s  .c om*/
    }

    return super.equals(obj);
}

From source file:eionet.webq.web.controller.util.WebformUrlProviderImpl.java

@Override
public String getWebformPath(ProjectFile webform) {
    String webformPath = null;// w w  w  .  j a  v  a 2 s.c o  m
    if (webform.getFileName().endsWith(".html") || webform.getFileName().endsWith(".htm")) {
        if (StringUtils.isEmpty(webform.getProjectIdentifier())) {
            ProjectEntry project = projectService.getById(webform.getProjectId());
            if (project != null) {
                webform.setProjectIdentifier(project.getProjectId());
            }
        }
        webformPath = webqUrl + "/webform/project/" + webform.getProjectIdentifier() + "/file/"
                + webform.getFileName() + "?";
    } else {
        webformPath = webqUrl + "/xform/?formId=" + webform.getId() + "&";
    }
    return webformPath;
}

From source file:jongo.jdbc.OrderParam.java

public static OrderParam valueOf(final MultivaluedMap<String, String> pathParams, final String pk) {
    String sort = pathParams.getFirst("sort");
    String dir = pathParams.getFirst("dir");

    if (StringUtils.isEmpty(dir))
        dir = "ASC";

    OrderParam instance;/*from   w  ww  .  jav a 2  s .com*/
    if (StringUtils.isEmpty(sort)) {
        instance = new OrderParam(pk, dir);
    } else {
        instance = new OrderParam(sort, dir);
    }

    return instance;
}

From source file:com.fdorigo.rmfly.wicket.ViewResultsPage.java

public ViewResultsPage(PageParameters params) {

    final String nNumberString = params.get("nNumber").toString();

    if (StringUtils.isEmpty(nNumberString)) {
        validNnumber = false;/*from  w ww.  ja  va  2 s . co  m*/
    } else {
        record = recordFacade.find(nNumberString);
        if (record != null) {
            validNnumber = true;
        } else {
            validNnumber = false;
        }
    }

    init();
}

From source file:com.mirth.connect.util.StringUtil.java

public static String unescape(String s) {

    // If null or empty, return the string
    if (StringUtils.isEmpty(s)) {
        return s;
    }//from  w w w.  j  av  a  2 s. c o m

    // If the value is bracket delimited in double quotes, remove the quotes and treat the rest as a literal
    if (s.length() >= 2 && s.substring(0, 1).equals("\"")
            && s.substring(s.length() - 1, s.length()).equals("\"")) {
        return s.substring(1, s.length() - 1);
    }

    // Standard escape sequence substitutions for non-printable characters (excludes printable characters: \ " ')
    s = s.replace("\\b", "\b");
    s = s.replace("\\t", "\t");
    s = s.replace("\\n", "\n");
    s = s.replace("\\f", "\f");
    s = s.replace("\\r", "\r");

    // Substitute hex sequences with single character (e.g. 0x0a -> \n)
    int n = 0;
    while ((n = s.indexOf("0x", n)) != -1 && s.length() >= n + 4) {
        char ch;
        try {
            ch = (char) Integer.parseInt(s.substring(n + 2, n + 4), 16);
        } catch (NumberFormatException e) {
            n += 2;
            continue;
        }
        if (n + 4 < s.length()) {
            s = s.substring(0, n) + ch + s.substring(n + 4);
        } else {
            s = s.substring(0, n) + ch;
            break;
        }

        n++;
    }

    return s;
}

From source file:com.nesscomputing.migratory.mojo.database.util.TemplatingStatementLocator.java

@Override
public String locate(final String statementName, final StatementContext context) throws Exception {
    if (StringUtils.isEmpty(statementName)) {
        throw new IllegalStateException("Statement Name can not be empty/null!");
    }//from w w w .j  a  va 2  s .com

    if (statementName.charAt(0) == '#') {
        // Multiple templates can be in a string template group. In that case, the name is #<template-group:<statement name>
        final String[] statementNames = StringUtils.split(statementName.substring(1), ":");

        final String location = prefix + statementNames[0] + ".st";

        LOG.trace("Loading SQL: %s", location);
        final URL locationUrl = Resources.getResource(this.getClass(), location);

        if (locationUrl == null) {
            throw new IllegalArgumentException("Location '" + location + "' does not exist!");
        }
        final String contents = loaderManager.loadFile(locationUrl.toURI());

        if (statementNames.length == 1) {
            final StringTemplate template = new StringTemplate(contents, AngleBracketTemplateLexer.class);
            template.setAttributes(context.getAttributes());
            final String sql = template.toString();

            LOG.trace("SQL: %s", sql);
            return sql;
        } else {
            final StringTemplateGroup group = new StringTemplateGroup(new StringReader(contents),
                    AngleBracketTemplateLexer.class);
            LOG.trace("Found %s in %s", group.getTemplateNames(), locationUrl);

            final StringTemplate template = group.getInstanceOf(statementNames[1]);
            template.setAttributes(context.getAttributes());
            final String sql = template.toString();

            LOG.trace("SQL: %s", sql);
            return sql;
        }
    } else {
        return statementName;
    }
}

From source file:com.hybris.integration.service.tmall.impl.LogisticsServiceImpl.java

@Override
public String offlinesend(String integrationId, String marketplaceLogId, LogisticsOfflineSendRequest request)
        throws ApiException {
    LogisticsOfflineSendResponse rsp = getClient(integrationId).execute(request, getToken(integrationId));
    String status = null;/*from   w w  w .j  a  v  a  2 s .  co  m*/
    if (rsp != null && StringUtils.isEmpty(rsp.getErrorCode())) {
        status = rsp.getShipping().getIsSuccess() + "";
    } else {
        LOGGER.error(rsp.getBody());
        throw new TmallAppException(ResponseCode.REQUEST_TMALL_ERROR.getCode(), rsp.getSubMsg());
    }
    return status;
}