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.appdynamicspilot.util.ArgumentUtils.java

public static boolean isNullOrEmpty(final String argumentValue) {
    return (isNull(argumentValue) || StringUtils.isBlank(argumentValue));
}

From source file:com.elasticbox.jenkins.k8s.repositories.api.charts.github.GitHubUrl.java

private static String normalize(String url) {

    if (StringUtils.isBlank(url)) {
        return null;
    }//from   w w  w  . j  a  va  2 s .  c om
    // Strip "/tree/..."
    if (url.contains("/tree/")) {
        url = url.replaceFirst("/tree/.*$", "");
    }
    if (!url.endsWith("/")) {
        url += '/';
    }
    return url;
}

From source file:net.sf.zekr.engine.audio.RecitationPackConverter.java

public static AudioData convert(File oldRecitationPack) throws IOException, ConfigurationException {
    PropertiesConfiguration props = ConfigUtils.loadConfig(oldRecitationPack, "UTF-8");
    AudioData ad = new AudioData();
    ad.id = props.getString("audio.id");
    if (StringUtils.isBlank(ad.id)) {
        logger.debug("audio.id cannot be null or empty");
        return null;
    }/*w  ww. j  a  v  a  2 s . com*/
    ad.id += "-converted";

    ad.version = "0.7.5";
    ad.lastUpdate = props.getString("audio.lastUpdate");
    ad.quality = "?";

    ad.name = props.getString("audio.name");
    if (StringUtils.isBlank(ad.id)) {
        logger.debug("audio.name cannot be null or empty");
        return null;
    }
    ad.name += " (converted)";

    ad.license = props.getString("audio.license");
    ad.locale = new Locale(props.getString("audio.language"), props.getString("audio.country"));

    String fileName = props.getString("audio.fileName");
    fileName = StringUtils.replace(fileName, "{SURA}", "%1$03d");
    fileName = StringUtils.replace(fileName, "{AYA}", "%2$03d");

    String baseUrl = props.getString("audio.baseUrl");
    if (StringUtils.isBlank(baseUrl)) {
        logger.debug("audio.baseUrl cannot be null or empty");
        return null;
    }
    baseUrl = StringUtils.replace(baseUrl, "%", "%%");

    String path;
    if (props.containsKey("audio.serverUrl")) {
        ad.type = "online";
        String serverUrl = props.getString("audio.serverUrl");
        path = serverUrl + "/" + baseUrl + "/";
        ad.onlineUrl = path + fileName;

        if (props.containsKey("audio.prestartFileName")) {
            ad.onlineAudhubillah = path + props.getString("audio.prestartFileName");
        }
        if (props.containsKey("audio.startFileName")) {
            ad.onlineBismillah = path + props.getString("audio.startFileName");
        }
        if (props.containsKey("audio.endFileName")) {
            ad.onlineSadaghallah = path + props.getString("audio.endFileName");
        }
    } else {
        ad.type = "offline";

        baseUrl = StringUtils.replace(baseUrl, "[base]", "<base>");
        baseUrl = StringUtils.replace(baseUrl, "[workspace]", "<workspace>");
        baseUrl = StringUtils.replace(baseUrl, "[w_b]", "<workspace_base>");

        path = baseUrl + "/";
        ad.offlineUrl = path + fileName;

        if (props.containsKey("audio.prestartFileName")) {
            ad.offlineAudhubillah = path + props.getString("audio.prestartFileName");
        }
        if (props.containsKey("audio.startFileName")) {
            ad.offlineBismillah = path + props.getString("audio.startFileName");
        }
        if (props.containsKey("audio.endFileName")) {
            ad.offlineSadaghallah = path + props.getString("audio.endFileName");
        }
    }

    return ad;
}

From source file:com.ms.commons.test.tool.exportdata.ConsoleCmdAnaylisysUtil.java

public static ConsoleCmd anaConsoleCmd(String cmd) {
    if (StringUtils.isBlank(cmd)) {
        throw new RuntimeException("Command cannot be empty!");
    }/*from  w  w  w . j a v a  2 s  .c o m*/
    String trimedCmd = cmd.trim();
    for (CmdAnalysisor cmdAnalysisor : cmdAnalysisorList) {
        for (String pre : cmdAnalysisor.analysisCommandList()) {
            if (trimedCmd.startsWith(pre + " ")) {
                return cmdAnalysisor.analysisConsoleCmd(cmd, trimedCmd.substring((pre + " ").length()));
            }
        }
    }
    if (trimedCmd.startsWith("convert ")) {
        throw new NotImplementedException("Not supported!");
    }
    throw new RuntimeException("Unknow command: " + cmd);
}

From source file:com.ms.commons.utilities.CharTools.java

/**
 *  T&#24676;  T??  unicode ? 10?//w w  w  . jav a 2s.c o m
 * 
 * @param str
 * @return
 */
public static String unicodeUrlDecode(String str) {
    if (StringUtils.isBlank(str)) {
        return str;
    }
    StringBuilder sb = new StringBuilder();
    Matcher matcher = unicode_url_pattern.matcher(str);
    int preEnd = 0;
    while (matcher.find()) {
        String group = matcher.group(1);
        int start = matcher.start();
        sb.append(str.substring(preEnd, start));
        sb.append(fromCharCode(Integer.parseInt(group)));
        preEnd = matcher.end();
    }
    sb.append(str.substring(preEnd, str.length()));
    return sb.toString();
}

From source file:io.github.jeddict.jpa.spec.validator.ConvertValidator.java

public static boolean isEmpty(Convert convert) {
    boolean empty = false;
    if (StringUtils.isBlank(convert.getConverter()) && !convert.isDisableConversion()) {
        empty = true;/*from  w ww. ja v  a2 s  . c o m*/
    }
    return empty;
}

From source file:com.migo.defence.SQLFilter.java

/**
 * SQL//from   w  w  w  .ja va 2s. co m
 * @param str  ?
 */
public static String sqlInject(String str) {
    if (StringUtils.isBlank(str)) {
        return null;
    }
    //'|"|;|\
    str = StringUtils.replace(str, "'", "");
    str = StringUtils.replace(str, "\"", "");
    str = StringUtils.replace(str, ";", "");
    str = StringUtils.replace(str, "\\", "");

    //???
    str = str.toLowerCase();

    //?
    String[] keywords = { "master", "truncate", "insert", "select", "delete", "update", "declare", "alert",
            "create", "drop" };

    //???
    for (String keyword : keywords) {
        if (str.contains(keyword)) {
            throw new RRException("??");
        }
    }

    return str;
}

From source file:com.aqnote.shared.cryptology.util.ProviderUtil.java

@SuppressWarnings("unchecked")
public static void addProvider(String className) throws Exception {
    if (StringUtils.isBlank(className))
        return;//w ww .  j av a2  s .  c om
    Class<?> clazz = Class.forName(className);
    if (clazz == null || !clazz.isAssignableFrom(Provider.class))
        return;
    addProvider((Class<Provider>) clazz);
}

From source file:io.github.jeddict.jpa.spec.validator.table.TableValidator.java

public static boolean isEmpty(Table table) {
    return StringUtils.isBlank(table.getName()) && StringUtils.isBlank(table.getSchema())
            && StringUtils.isBlank(table.getCatalog()) && table.getUniqueConstraint().isEmpty()
            && table.getIndex().isEmpty();
}

From source file:com.enonic.cms.domain.portal.PrettyPathNameCreator.java

public static String generatePrettyPathName(String originalName) {
    if (StringUtils.isBlank(originalName)) {
        //throw new IllegalArgumentException( "Generate name failed; Original name cannot be empty or blank" );
        return DEFAULT_PATHNAME;
    }/* w  w w.  jav  a 2s  .c  om*/

    String prettifiedPathName = originalName;

    prettifiedPathName = makeLowerCase(prettifiedPathName);
    prettifiedPathName = replaceWithHyphens(prettifiedPathName);
    prettifiedPathName = removeUnsafeCharacters(prettifiedPathName);
    prettifiedPathName = replaceBlankSpaces(prettifiedPathName);
    prettifiedPathName = replaceTrailingHyphens(prettifiedPathName);
    prettifiedPathName = replaceHyphensAroundDot(prettifiedPathName);
    prettifiedPathName = ensureNiceBeginningAndEnding(prettifiedPathName);

    if (StringUtils.isBlank(prettifiedPathName)) {
        return DEFAULT_PATHNAME;
    }

    return prettifiedPathName;
}