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.mmj.app.biz.cons.ReportTypeEnum.java

/**
 * ?name?/*from  w ww  . j av a 2  s  .com*/
 */
public static ReportTypeEnum getEnum(String name) {
    if (StringUtils.isEmpty(name)) {
        return null;
    }
    for (ReportTypeEnum current : values()) {
        if (StringUtils.equalsIgnoreCase(current.name, name)) {
            return current;
        }
    }
    return null;
}

From source file:net.shopxx.dao.impl.PaymentDaoImpl.java

public Payment findBySn(String sn) {
    if (StringUtils.isEmpty(sn)) {
        return null;
    }/*from   w w w . j  a  va2 s .co m*/
    String jpql = "select payment from Payment payment where lower(payment.sn) = lower(:sn)";
    try {
        return entityManager.createQuery(jpql, Payment.class).setParameter("sn", sn).getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
}

From source file:net.sourceforge.fenixedu.domain.EmptyGrade.java

static protected boolean qualifiesAsEmpty(String value) {
    if (value != null) {
        value = value.trim();/*  w w w .j av  a 2  s .  c  o  m*/
    }
    return StringUtils.isEmpty(value) || value.equals("null");
}

From source file:net.shopxx.dao.impl.ShippingDaoImpl.java

public Shipping findBySn(String sn) {
    if (StringUtils.isEmpty(sn)) {
        return null;
    }/*from w w  w  .j  a  v a2s. c om*/
    String jpql = "select shipping from Shipping shipping where lower(shipping.sn) = lower(:sn)";
    try {
        return entityManager.createQuery(jpql, Shipping.class).setParameter("sn", sn).getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
}

From source file:net.shopxx.dao.impl.AdminDaoImpl.java

public boolean usernameExists(String username) {
    if (StringUtils.isEmpty(username)) {
        return false;
    }/*from  ww w.ja  va  2  s.com*/
    String jpql = "select count(*) from Admin admin where lower(admin.username) = lower(:username)";
    Long count = entityManager.createQuery(jpql, Long.class).setParameter("username", username)
            .getSingleResult();
    return count > 0;
}

From source file:com.indexoutofbounds.util.ClassPathInputStreamUtils.java

/**
 * Creates an InputStream from the path which can be either something on
 * the file system, a remote system, or a classpath entry.
 * @param path//from  www.ja v a 2  s  .  c  o m
 * @return
 * @throws Exception
 */
public final static InputStream getInputStream(final String path) throws IOException {

    if (StringUtils.isEmpty(path)) {
        throw new IOException("Unable to locate empty config file parameter");
    }

    final URL url = locateURL(path);
    if (url == null) {
        throw new IOException("Unable to locate config file: " + path);
    }

    try {

        return new BufferedInputStream(url.openStream());
    } catch (IOException e) {
        throw new IOException("Unable to open config file: " + path + ", " + e.getLocalizedMessage());
    }
}

From source file:net.shopxx.dao.impl.PaymentLogDaoImpl.java

public PaymentLog findBySn(String sn) {
    if (StringUtils.isEmpty(sn)) {
        return null;
    }/* w  ww  .java 2 s  .c  om*/
    String jpql = "select paymentLog from PaymentLog paymentLog where lower(paymentLog.sn) = lower(:sn)";
    try {
        return entityManager.createQuery(jpql, PaymentLog.class).setParameter("sn", sn).getSingleResult();
    } catch (NoResultException e) {
        return null;
    }
}

From source file:com.aimluck.eip.modules.actions.project.util.ProjectTestUtil.java

public static String join(List<String> list, String separator) {
    StringBuilder features = new StringBuilder();
    Iterator<String> it = list.iterator();
    while (it.hasNext()) {
        String word = it.next();/*from w  w  w . j a  v a2s.c  o  m*/
        if (StringUtils.isEmpty(word)) {
            continue;
        }
        features.append(word);
        if (it.hasNext()) {
            features.append(separator);
        }
    }
    return features.toString();
}

From source file:com.kalessil.phpStorm.phpInspectionsEA.inspectors.regularExpressions.modifiersStrategy.MissingUnicodeModifierStrategy.java

static public void apply(@Nullable String modifiers, @Nullable String pattern,
        @NotNull StringLiteralExpression target, @NotNull ProblemsHolder holder) {
    if ((modifiers == null || modifiers.indexOf('u') == -1) && !StringUtils.isEmpty(pattern)) {
        if (unicodeCharactersPattern.matcher(pattern).matches()) {
            holder.registerProblem(target, messageCharacters, ProblemHighlightType.GENERIC_ERROR);
        } else {//from  www  .j ava 2s.  c  o  m
            final String normalized = StringUtils.replace(pattern, "\\\\", "");
            if (unicodeCodepointsPattern.matcher(normalized).matches()) {
                holder.registerProblem(target, messageCodepoints, ProblemHighlightType.GENERIC_ERROR);
            }
        }
    }
}

From source file:io.renren.common.utils.IPUtils.java

/**
 * ?IP?//from w  ww .  j  a  va  2 s.  com
 * 
 * Nginx???? ?request.getRemoteAddr()?IP?
 * ?????X-Forwarded-For?IP?X-Forwarded-For?unknownIPIP?
 */
public static String getIpAddr(HttpServletRequest request) {
    String ip = null;
    try {
        ip = request.getHeader("x-forwarded-for");
        if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("Proxy-Client-IP");
        }
        if (StringUtils.isEmpty(ip) || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("WL-Proxy-Client-IP");
        }
        if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("HTTP_CLIENT_IP");
        }
        if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getHeader("HTTP_X_FORWARDED_FOR");
        }
        if (StringUtils.isEmpty(ip) || "unknown".equalsIgnoreCase(ip)) {
            ip = request.getRemoteAddr();
        }
    } catch (Exception e) {
        logger.error("IPUtils ERROR ", e);
    }

    //        //??IP?
    //        if(StringUtils.isEmpty(ip) && ip.length() > 15) {
    //         if(ip.indexOf(",") > 0) {
    //            ip = ip.substring(0, ip.indexOf(","));
    //         }
    //      }

    return ip;
}