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.xx_dev.apn.proxy.utils.HostNamePortUtil.java

public static String getHostName(HttpRequest httpRequest) {
    String originalHostHeader = httpRequest.headers().get(HttpHeaders.Names.HOST);

    if (StringUtils.isBlank(originalHostHeader) && httpRequest.getMethod().equals(HttpMethod.CONNECT)) {
        originalHostHeader = httpRequest.getUri();
    }//from  ww w . ja v a2  s . c om

    if (StringUtils.isNotBlank(originalHostHeader)) {
        String originalHost = StringUtils.split(originalHostHeader, ": ")[0];
        return originalHost;
    } else {
        String uriStr = httpRequest.getUri();
        try {
            URI uri = new URI(uriStr);

            String schema = uri.getScheme();

            String originalHost = uri.getHost();

            return originalHost;
        } catch (URISyntaxException e) {
            logger.error(e.getMessage(), e);
            return null;
        }
    }
}

From source file:com.intuit.tank.vm.common.util.ValidationUtil.java

/**
 * Is this formatted as a variable//from w w w  . j  a v  a 2s.co  m
 * 
 * @param key
 *            The variable name
 * @return TRUE if it is formatted as a variable; FALSE otherwise
 */
public static boolean isAnyVariable(String key) {
    if (StringUtils.isBlank(key)) {
        return false;
    }

    if (key.charAt(0) == identifierChar) {
        return true;
    }
    if (key.indexOf("#{") == 0 && key.indexOf("}") == key.length() - 1) {
        return true;
    }

    return false;
}

From source file:com.baidu.rigel.biplatform.ac.util.PlaceHolderUtils.java

/**
 * ?????  abc/${1}/${2}/abc.action,?? ${1},${2}
 * /*from  w  w  w . j a  v  a 2 s.  co m*/
 * @param source ?
 * @return ????
 */
public static List<String> getPlaceHolders(String source) {
    if (StringUtils.isBlank(source)) {
        throw new IllegalArgumentException("can not get place hode list by blank source");
    }
    Pattern pattern = Pattern.compile("\\$\\{[^\\}]+\\}");
    Matcher match = pattern.matcher(source);
    List<String> result = new ArrayList<String>();
    while (match.find()) {
        result.add(match.group());
    }
    return result;
}

From source file:jp.ikedam.jenkins.plugins.scoringloadbalancer.util.ValidationUtil.java

public static FormValidation doCheckInteger(String value) {
    if (StringUtils.isBlank(value)) {
        return FormValidation.error(Messages.ValidationUtil_integer_requied());
    }//from   w ww .j a  va  2  s.co  m

    try {
        Integer.parseInt(StringUtils.trim(value));
    } catch (NumberFormatException e) {
        return FormValidation.error(e, Messages.ValidationUtil_integer_invalid());
    }

    return FormValidation.ok();
}

From source file:com.baidu.rigel.biplatform.ac.util.Md5Util.java

/**
 * * MD5?/*w ww  .j a  v a  2  s .co m*/
 * 
 * @param rawPass 
 * @param salt ?
 * @return md5
 * @throws IllegalArgumentException ?
 */
public static String encode(String rawPass, Object salt) {
    if (StringUtils.isBlank(rawPass)) {
        throw new IllegalArgumentException("encode string can not be empty!");
    }
    String saltedPass = mergePasswordAndSalt(rawPass, salt);
    try {
        MessageDigest messageDigest = MessageDigest.getInstance("MD5");
        byte[] digest = messageDigest.digest(saltedPass.getBytes());
        return new String(decodeByteArray(digest));
    } catch (NoSuchAlgorithmException e) {
        return rawPass;
    }
}

From source file:gov.nih.nci.protexpress.util.ManageProtAppInputOutputHelper.java

/**
 * Removes the invalid items (inputs/outputs with blank name, filename and notes) from the list.
 *
 * @param lst the list of inputs/outputs.
 *//* w  w w . ja  v a  2 s . c om*/
public static void removeInvalidItems(List<InputOutputObject> lst) {
    ListIterator<InputOutputObject> listIter = lst.listIterator();
    while (listIter.hasNext()) {
        InputOutputObject ioObject = listIter.next();
        if (StringUtils.isBlank(ioObject.getName()) && StringUtils.isBlank(ioObject.getDataFileURL())
                && StringUtils.isBlank(ioObject.getNotes())) {
            listIter.remove();
        }
    }
}

From source file:com.salesmanager.core.util.ReferenceUtil.java

public static String getUnSecureDomain(MerchantStore store) {

    String domain = conf.getString("core.domain.server");

    if (store != null && !StringUtils.isBlank(store.getDomainName())) {
        domain = store.getDomainName();/*ww w .j  a v  a2s  .  com*/
    }
    StringBuffer url = new StringBuffer();

    return url.append((String) conf.getString("core.domain.http.unsecure")).append("://").append(domain)
            .toString();
}

From source file:com.baidu.rigel.biplatform.cache.util.MacAddressUtil.java

/** 
 * getMachineNetworkFlag ?MACIP?MAC// w  w w  . jav a2 s  . c o  m
 * @param ia
 * @return
 * @throws SocketException
 * @throws UnknownHostException
 */
public static String getMachineNetworkFlag(InetAddress ia) throws SocketException, UnknownHostException {
    if (ia == null) {
        ia = InetAddress.getLocalHost();
    }
    String machineFlag = getMacAddress(ia);
    if (StringUtils.isBlank(machineFlag)) {
        machineFlag = getIpAddress(ia);
    }
    return machineFlag;
}

From source file:hydrograph.ui.common.util.ConvertHexValues.java

/**
 * This method converts input hex-value into its equivalent character.
 * //  w  ww.jav  a  2 s  .  c om
 * @param input
 *            , hex-value e.g. \x21 for !
 * @return string, if given input is valid hex-value then its equivalent character is returned else input is
 *         returned as it is.
 */
public static String parseHex(String input) {
    final int NO_OF_DIGITS = 2;

    if (StringUtils.isBlank(input) || StringUtils.length(input) < NO_OF_DIGITS + 2)
        return input;

    // Added support for \\t
    if (input.contains("\\t")) {
        input = input.replace("\\t", "\\x09");
    }

    String[] tokens = input.split("\\\\x");
    String hex;
    String temp;
    boolean startsWithHex = input.startsWith("\\x");

    for (int counter = 0; counter < tokens.length; counter++) {

        if (counter == 0 && !startsWithHex)
            continue;

        if (tokens[counter].equals(""))
            continue;

        temp = tokens[counter];
        hex = temp.substring(0, NO_OF_DIGITS);
        temp = temp.substring(NO_OF_DIGITS, temp.length());
        try {
            tokens[counter] = hexToChar(hex) + temp;
        } catch (NumberFormatException numberFormatException) {
            tokens[counter] = hex + temp;
        }
    }

    String result = "";
    for (String token : tokens) {
        result = result + token;
    }

    return result;

}

From source file:edu.umd.cs.findbugs.detect.LpUtil.java

public static boolean isBlank(String str) {
    if ("null".equals(str)) {
        return true;
    }/*ww w. ja v a 2s  . co  m*/
    return StringUtils.isBlank(str);
}