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.hack23.cia.service.data.impl.LegacyNamingStrategy.java

/**
* Convert.//from  w  ww.  j  a  v a2 s.c o m
*
* @param identifier
*            the identifier
* @return the identifier
*/
private static Identifier convert(final Identifier identifier) {
    if (identifier == null || StringUtils.isBlank(identifier.getText())) {
        return identifier;
    } else {
        return Identifier.toIdentifier(
                identifier.getText().replaceAll(REG_EXPR, REPLACEMENT_PATTERN).toLowerCase(Locale.ENGLISH));
    }
}

From source file:com.alibaba.doris.admin.service.main.DorisConfigUtil.java

/**
 * <p>/*from   w w w  .j  a v  a 2  s .  com*/
 * ?ip????serviceIP
 * ???.
 * <p>
 * request.getRemoteAddr()?ServiceIP
 * <p>
 * ??Http?x-forwarded-forIP??
 * ??IP?
 * <p>
 * ??forwarded-for?Proxy-Client-IPWL-Proxy-Client-IP??
 * 
 * @param request
 * @return
 */
public static String getIpAddr(HttpServletRequest request) {
    String ip = null;

    ip = request.getHeader("x-forwarded-for");
    if (StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getHeader("Proxy-Client-IP");
    }
    if (StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getHeader("WL-Proxy-Client-IP");
    }
    if (StringUtils.isBlank(ip) || "unknown".equalsIgnoreCase(ip)) {
        ip = request.getRemoteAddr();
    }
    String[] temp = StringUtils.split(ip, ',');
    if (temp.length > 1) {
        for (int i = 0; i < temp.length; i++) {// ?unknown
            if (!"unknown".equalsIgnoreCase(temp[i])) {
                ip = temp[i];
                break;
            }
        }
    }

    return ip;
}

From source file:com.googlecode.jtiger.modules.ecside.util.ExportViewUtils.java

public static String parseXLS(String value) {
    if (StringUtils.isBlank(value))
        return "";

    value = replaceNonBreakingSpaces(value);

    return value;
}

From source file:com.zf.decipher.DataEn.java

/**
 * /*from w w w. j ava 2  s .c  o m*/
 *
 * @param data
 *            ?
 * @return
 * @throws Exception
 */
public static String decrypt(String data) throws Exception {
    if (StringUtils.isBlank(data))
        return "";
    byte be[] = Base64.decode(data, Base64.CRLF);
    return new String(decrypt(be));
}

From source file:eu.matejkormuth.pexel.slave.bukkit.core.ValidityChecker.java

public static void checkMapData(final eu.matejkormuth.pexel.commons.MapData mapData) {
    if (StringUtils.isBlank(mapData.getAuthor())) {
        throw new ValidationException("Map author can't be blank!");
    }//from   ww  w .  java  2s . c  om
    if (StringUtils.isBlank(mapData.getName())) {
        throw new ValidationException("Map name can't be blank!");
    }
    if (mapData.getMaxPlayers() < 1) {
        System.out.println("Max players should probably be more than one!");
    }
    if (mapData.getProtectedRegion() == null) {
        throw new ValidationException("Protected region can't be null!");
    }
    if (mapData.getWorld() == null) {
        throw new ValidationException("World not found on server!");
    }
}

From source file:com.taobao.datax.engine.schedule.JarLoader.java

private static URL[] getUrl(String path) {
    /* check path exist */
    if (null == path || StringUtils.isBlank(path)) {
        throw new IllegalArgumentException("Path cannot be empty .");
    }/*w ww  .j  a  v a2 s.co m*/

    File jarPath = new File(path);
    if (!jarPath.exists() || !jarPath.isDirectory()) {
        throw new IllegalArgumentException("Path must be directory .");
    }

    /* set filter */
    FileFilter jarFilter = new FileFilter() {
        @Override
        public boolean accept(File pathname) {
            return pathname.getName().endsWith(".jar");
        }
    };

    /* iterate all jar */
    File[] allJars = new File(path).listFiles(jarFilter);
    URL[] jarUrls = new URL[allJars.length];

    for (int i = 0; i < allJars.length; i++) {
        try {
            jarUrls[i] = allJars[i].toURI().toURL();
        } catch (MalformedURLException e) {
            logger.error(ExceptionTracker.trace(e));
            throw new DataExchangeException(e.getCause());
        }
        logger.debug(jarUrls[i]);
    }

    return jarUrls;
}

From source file:com.ai.smart.common.helper.util.RequestUtils.java

/**
 * ?QueryString?URLDecoderUTF-8??post??// ww w  . ja  v a2  s.  c  o m
 * HttpServletRequest#getParameter?
 *
 * @param request web
 * @param name    ???
 * @return
 */
public static String getQueryParam(HttpServletRequest request, String name) {
    if (StringUtils.isBlank(name)) {
        return null;
    }
    if (request.getMethod().equalsIgnoreCase(POST)) {
        return request.getParameter(name);
    }
    String s = request.getQueryString();
    if (StringUtils.isBlank(s)) {
        return null;
    }
    try {
        s = URLDecoder.decode(s, UTF8);
    } catch (UnsupportedEncodingException e) {
        log.error("encoding " + UTF8 + " not support?", e);
    }
    String[] values = parseQueryString(s).get(name);
    if (values != null && values.length > 0) {
        return values[values.length - 1];
    } else {
        return null;
    }
}

From source file:com.github.slugify.Slugify.java

private static String removeDuplicateWhiteSpaces(String input) {
    String ret = StringUtils.trim(input);
    if (StringUtils.isBlank(ret)) {
        return "";
    }//from   w  w  w. java2s . co  m

    return ret.replaceAll("\\s+", " ");
}

From source file:com.likethecolor.alchemy.api.validator.OutputStatusValidator.java

private static void validate(final Response.STATUS status, final String statusInfo,
        final String originalJsonString) throws IOException {
    if (null == status || status != Response.STATUS.OK) {
        if (!StringUtils.isBlank(statusInfo)) {
            throw new IOException(
                    "Error making API call: " + statusInfo + " - original json string: " + originalJsonString);
        }/*w  w w. j av  a2s  .  c  o m*/
        throw new IOException(
                "Error making API call: " + status + " - original json string: " + originalJsonString);
    }
}

From source file:com.haulmont.cuba.core.sys.persistence.DbmsType.java

public static String getType(String storeName) {
    String propName = "cuba.dbmsType";
    if (!Stores.isMain(storeName))
        propName = propName + "_" + storeName;

    String id = AppContext.getProperty(propName);
    if (StringUtils.isBlank(id))
        throw new IllegalStateException("Property " + propName + " is not set");
    return id;/* w  ww  .j  av a  2s .  c o  m*/
}