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

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

Introduction

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

Prototype

public static boolean isBlank(final CharSequence cs) 

Source Link

Document

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

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

Usage

From source file:ch.cyberduck.core.io.Checksum.java

public static Checksum parse(final String hash) {
    if (StringUtils.isBlank(hash)) {
        return Checksum.NONE;
    }//from w ww.ja va2s .  c  om
    if (hash.matches("[a-fA-F0-9]{32}")) {
        return new Checksum(HashAlgorithm.md5, hash);
    }
    if (hash.matches("[a-fA-F0-9]{40}")) {
        return new Checksum(HashAlgorithm.sha1, hash);
    }
    if (hash.matches("[A-Fa-f0-9]{64}")) {
        return new Checksum(HashAlgorithm.sha256, hash);
    }
    if (hash.matches("[A-Fa-f0-9]{128}")) {
        return new Checksum(HashAlgorithm.sha512, hash);
    }
    if (hash.matches("[a-fA-F0-9]{8}")) {
        return new Checksum(HashAlgorithm.crc32, hash);
    }
    log.warn(String.format("Failure to detect algorithm for checksum %s", hash));
    return Checksum.NONE;
}

From source file:mobile.util.MobileUtil.java

/**
 * ?URL?12//from  www  . j a  v  a  2  s .  com
 * 
 * @return truefalse?
 */
public static boolean isMobileUrlPrefixAndDevice(String url) {
    if (StringUtils.isBlank(url)) {
        return false;
    } else {
        return url.startsWith("/mobile/android/") || url.startsWith("/mobile/ipad/")
                || url.startsWith("/mobile/iphone/");
    }
}

From source file:io.redlink.sdk.util.ApiHelper.java

/**
 * Build a proper api version from the artifact version
 *
 * @return api version// w w w .j  a va 2  s.  c  o m
 * @see <a href="http://dev.redlink.io/sdk#introduction">api/sdk versioning</a>
 */
public static String getApiVersion() {
    String version = getApiVersion(ApiHelper.class.getPackage().getImplementationVersion());
    return (StringUtils.isBlank(version) ? "1.0-BETA" : version); //FIXME
}

From source file:de.micromata.genome.util.runtime.DynamicClassPath.java

public static void initClassPath(LocalSettings localSettings) {
    String cp = localSettings.getProperty("sys.classpathext");
    if (StringUtils.isBlank(cp) == true) {
        return;/*ww  w.  j av a 2  s. c o m*/
    }
    String[] cpl = StringUtils.split(cp, ",");
    URL[] urls = new URL[cpl.length];
    for (int i = 0; i < cpl.length; ++i) {
        URL url = createClUrl(new File(cpl[i]));
        urls[i] = url;
    }
    boolean extendSystemCl = false;
    if (extendSystemCl == false) {
        addContextClassPathes(urls);
    } else {
        for (String c : cpl) {
            URL url = createClUrl(new File(c));
            addSystemClassPath(url);
        }
    }
    // Class cls = Class.forName("org.springbyexample.jdbc.datasource.InitializingBasicDataSource", true, Thread.currentThread()
    // .getContextClassLoader());
}

From source file:com.test.edusys.common.utils.SearchFilter.java

/**
 * searchParamskey?OPERATOR_FIELDNAME/*from   w ww  . j a  v  a2  s.  c om*/
 */
public static Map<String, SearchFilter> parse(Map<String, Object> searchParams) {
    Map<String, SearchFilter> filters = new HashMap();

    for (Entry<String, Object> entry : searchParams.entrySet()) {
        // 
        String key = entry.getKey();
        Object value = entry.getValue();
        System.out.println(value);
        if (StringUtils.isBlank((String) value)) {
            continue;
        }

        // operatorfiledAttribute
        String[] names = StringUtils.split(key, "@");
        if (names.length != 2) {
            throw new IllegalArgumentException(key + " is not a valid search filter name");
        }
        String filedName = names[1];
        Operator operator = Operator.valueOf(names[0]);

        // searchFilter
        SearchFilter filter = new SearchFilter(filedName, operator, value);
        filters.put(key, filter);
    }

    return filters;
}

From source file:com.wxt.news.persistence.SearchFilter.java

/**
 * searchParamskey?OPERATOR_FIELDNAME/*w ww . j a  v  a2s  .co  m*/
 */
public static Map<String, SearchFilter> parse(Map<String, Object> searchParams) {
    Map<String, SearchFilter> filters = Maps.newHashMap();

    for (Entry<String, Object> entry : searchParams.entrySet()) {
        // 
        String key = entry.getKey();
        Object value = entry.getValue();
        if (value == null || (value instanceof String && StringUtils.isBlank((String) value))) {
            continue;
        }

        // operatorfiledAttribute
        String[] names = StringUtils.split(key, "_");
        if (names.length != 2) {
            throw new IllegalArgumentException(key + " is not a valid search filter name");
        }
        String filedName = names[1];
        Operator operator = Operator.valueOf(names[0]);

        // searchFilter
        SearchFilter filter = new SearchFilter(filedName, operator, value);
        filters.put(key, filter);
    }

    return filters;
}

From source file:com.hbc.api.trade.order.controller.validator.OrderValidator.java

public static void validateGuideId(String guideId) {
    if (StringUtils.isBlank(guideId)) {
        logger.error("guideId null??guideId=" + guideId);
        throw new TradeException(TradeReturnCodeEnum.ORDER_PARAM_FAILED, "guideId");
    }/*www . j a  v a2  s  . c  o  m*/
}

From source file:com.weibo.api.motan.config.ConfigUtil.java

/**
 * export fomart: protocol1:port1,protocol2:port2
 * /*from   w  w w.j a  v  a2 s.  co m*/
 * @param export
 * @return
 */
@SuppressWarnings("unchecked")
public static Map<String, Integer> parseExport(String export) {
    if (StringUtils.isBlank(export)) {
        return Collections.emptyMap();
    }
    Map<String, Integer> pps = new HashMap<String, Integer>();
    String[] protocolAndPorts = MotanConstants.COMMA_SPLIT_PATTERN.split(export);
    for (String pp : protocolAndPorts) {
        if (StringUtils.isBlank(pp)) {
            continue;
        }
        String[] ppDetail = pp.split(":");
        if (ppDetail.length == 2) {
            pps.put(ppDetail[0], Integer.parseInt(ppDetail[1]));
        } else if (ppDetail.length == 1) {
            if (MotanConstants.PROTOCOL_INJVM.equals(ppDetail[0])) {
                pps.put(ppDetail[0], MotanConstants.DEFAULT_INT_VALUE);
            } else {
                int port = MathUtil.parseInt(ppDetail[0], 0);
                if (port <= 0) {
                    throw new MotanServiceException("Export is malformed :" + export);
                } else {
                    pps.put(MotanConstants.PROTOCOL_MOTAN, port);
                }
            }

        } else {
            throw new MotanServiceException("Export is malformed :" + export);
        }
    }
    return pps;
}

From source file:in.bookmylab.Utils.java

public static String hashPassword(String password) {
    String hashed = null;/*w w w. j  a va  2  s  .  c  om*/
    try {
        if (!StringUtils.isBlank(password)) {
            MessageDigest digest = MessageDigest.getInstance("SHA-256");
            byte[] hash = digest.digest((salt + password).getBytes(StandardCharsets.ISO_8859_1));
            //hashed = Base64.getEncoder().encodeToString(hash);
            hashed = Base64.encodeBase64String(hash);
        }
    } catch (NoSuchAlgorithmException ex) {
        log.log(Level.SEVERE, "Could not hash string.", ex);
    }
    return hashed;
}

From source file:com.vmware.identity.openidconnect.common.CorrelationID.java

public static CorrelationID get(HttpRequest httpRequest) {
    Validate.notNull(httpRequest, "httpRequest");
    String correlationIdString = httpRequest.getParameters().get("correlation_id");
    return StringUtils.isBlank(correlationIdString) ? new CorrelationID()
            : new CorrelationID(correlationIdString);
}