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

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

Introduction

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

Prototype

public static boolean isEmpty(final CharSequence cs) 

Source Link

Document

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

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

NOTE: This method changed in Lang version 2.0.

Usage

From source file:de.micromata.genome.gwiki.utils.WebUtils.java

public static String encodeUrlParam(String value) {
    if (StringUtils.isEmpty(value) == true) {
        return "";
    }/*from  www .ja  va2s . com*/

    try {
        return URLEncoder.encode(value, "UTF-8");
    } catch (UnsupportedEncodingException ex) {
        throw new RuntimeException(ex);
    }
}

From source file:io.cloudslang.content.database.services.SQLQueryService.java

public static void executeSqlQuery(@NotNull final SQLInputs sqlInputs) throws Exception {
    if (StringUtils.isEmpty(sqlInputs.getSqlCommand())) {
        throw new Exception("command input is empty.");
    }//from   w w  w  .j  av a2 s .c  o  m
    ConnectionService connectionService = new ConnectionService();
    try (final Connection connection = connectionService.setUpConnection(sqlInputs)) {

        connection.setReadOnly(true);
        Statement statement = connection.createStatement(sqlInputs.getResultSetType(),
                sqlInputs.getResultSetConcurrency());
        statement.setQueryTimeout(sqlInputs.getTimeout());
        final ResultSet results = statement.executeQuery(sqlInputs.getSqlCommand());

        final ResultSetMetaData mtd = results.getMetaData();

        int iNumCols = mtd.getColumnCount();

        final StringBuilder strColumns = new StringBuilder(sqlInputs.getStrColumns());

        for (int i = 1; i <= iNumCols; i++) {
            if (i > 1) {
                strColumns.append(sqlInputs.getStrDelim());
            }
            strColumns.append(mtd.getColumnLabel(i));
        }
        sqlInputs.setStrColumns(strColumns.toString());

        while (results.next()) {
            final StringBuilder strRowHolder = new StringBuilder();
            for (int i = 1; i <= iNumCols; i++) {
                if (i > 1)
                    strRowHolder.append(sqlInputs.getStrDelim());
                if (results.getString(i) != null) {
                    String value = results.getString(i).trim();
                    if (sqlInputs.isNetcool())
                        value = SQLUtils.processNullTerminatedString(value);

                    strRowHolder.append(value);
                }
            }
            sqlInputs.getLRows().add(strRowHolder.toString());
        }
    }
}

From source file:com.github.dozermapper.core.builder.model.jaxb.FieldType.java

public static FieldType fromValue(String value) {
    if (StringUtils.isEmpty(value)) {
        return null;
    }/* ww  w. j  av  a 2s .c o m*/

    for (FieldType c : FieldType.values()) {
        if (c.value.equals(value)) {
            return c;
        }
    }

    throw new IllegalArgumentException("field-type should be iterate or generic. Found: " + value);
}

From source file:com.github.dozermapper.core.builder.model.jaxb.Type.java

public static Type fromValue(String value) {
    if (StringUtils.isEmpty(value)) {
        return null;
    }//from www.  ja  va 2 s  .c  o m

    for (Type c : Type.values()) {
        if (c.value.equals(value)) {
            return c;
        }
    }

    throw new IllegalArgumentException("type should be bi-directional or one-way. Found: " + value);
}

From source file:com.astamuse.asta4d.util.i18n.LocalizeUtil.java

public static String[] getCandidatePaths(String path, Locale locale) {
    int dotIndex = path.lastIndexOf(".");
    String name = dotIndex > 0 ? path.substring(0, dotIndex) : path;
    String extension = dotIndex > 0 ? path.substring(dotIndex) : StringUtils.EMPTY;
    List<String> candidatePathList = new ArrayList<>();
    if (!StringUtils.isEmpty(locale.getVariant())) {
        candidatePathList.add(name + '_' + locale.getLanguage() + "_" + locale.getCountry() + "_"
                + locale.getVariant() + extension);
    }/*from  w  ww . jav  a2  s .c o  m*/
    if (!StringUtils.isEmpty(locale.getCountry())) {
        candidatePathList.add(name + '_' + locale.getLanguage() + "_" + locale.getCountry() + extension);
    }
    if (!StringUtils.isEmpty(locale.getLanguage())) {
        candidatePathList.add(name + '_' + locale.getLanguage() + extension);
    }
    candidatePathList.add(path);
    return candidatePathList.toArray(new String[candidatePathList.size()]);
}

From source file:com.nts.alphamale.type.DirectionType.java

public static DirectionType matchOf(String value) {
    if (StringUtils.isEmpty(value)) {
        return DirectionType.NATURAL;
    }/*from www.  j a va 2 s  .  co m*/
    for (DirectionType v : values()) {
        if (v.toString().equalsIgnoreCase(value)) {
            return v;
        }
    }
    throw new IllegalArgumentException();
}

From source file:AIR.Common.Utilities.Path.java

public static String combine(String dir, String fileName, String separator) {
    // TODO: needs review
    dir = dir.replace("/", separator);
    dir = dir.replace("\\", separator);
    // End/* w  w w  .j  a  v  a  2s  . c  o  m*/
    if (StringUtils.isEmpty(dir))
        return fileName;
    else if (StringUtils.isEmpty(fileName))
        return dir;
    if (dir.endsWith(separator) || fileName.startsWith(separator)) {
        return String.format("%s%s", dir, fileName);
    } else {
        return String.format("%s%s%s", dir, separator, fileName);
    }
}

From source file:com.github.dozermapper.core.builder.model.jaxb.Relationship.java

public static Relationship fromValue(String value) {
    if (StringUtils.isEmpty(value)) {
        return null;
    }//w w  w  .ja va2s  .c o  m

    for (Relationship c : Relationship.values()) {
        if (c.value.equals(value)) {
            return c;
        }
    }

    throw new IllegalArgumentException("relationship should be cumulative or non-cumulative. Found: " + value);
}

From source file:com.github.riccardove.easyjasub.commons.CommonsLangStringUtils.java

public static boolean isEmpty(String title) {
    return StringUtils.isEmpty(title);
}

From source file:com.esri.geoevent.test.performance.utils.MessageUtils.java

public static String escapeNewLineCharacters(String data) {
    if (StringUtils.isEmpty(data))
        return null;

    String replacedData = data.replace(DEFAULT_CRNL_SEPERATOR, CRNL_SEPERATOR);
    replacedData = replacedData.replace(DEFAULT_CR_SEPERATOR, CR_SEPERATOR);
    replacedData = replacedData.replace(DEFAULT_NL_SEPERATOR, NL_SEPERATOR);

    return replacedData;
}