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.pcms.core.util.UrlUtil.java

public static String getURI(HttpServletRequest request) {
    UrlPathHelper helper = new UrlPathHelper();
    String uri = helper.getOriginatingRequestUri(request);
    String ctx = helper.getOriginatingContextPath(request);
    if (!StringUtils.isBlank(ctx)) {
        return uri.substring(ctx.length());
    } else {/*from w w  w  .j  av  a2s  .co m*/
        return uri;
    }
}

From source file:gov.nih.nci.protexpress.ui.converters.EnumTypeConverter.java

/**
 * {@inheritDoc}/*from  w  ww .  j  av  a  2 s .  co m*/
 */
@Override
public Enum convertFromString(String value, Class toClass) {
    if (StringUtils.isBlank(value)) {
        return null;
    }
    return super.convertFromString(value, toClass);
}

From source file:de.thischwa.pmcms.server.ServletUtils.java

public static void establishContentType(String fileName, HttpServletResponse resp) {
    if (StringUtils.isBlank(fileName))
        return;//from   w  ww  .j  ava 2 s . c  om
    String contentType = contentTypes.getContentTypeFor(fileName);
    if (StringUtils.isNotBlank(contentType))
        resp.setContentType(contentType);
}

From source file:com.twitter.hraven.util.HadoopConfUtil.java

/**
 * Get the user name from the job conf check for hadoop2 config param, then
 * hadoop1/* w  ww  .  j  av a2  s  .c  om*/
 * 
 * @param jobConf
 * @return userName
 * 
 * @throws IllegalArgumentException
 */
public static String getUserNameInConf(Configuration jobConf) throws IllegalArgumentException {
    String userName = jobConf.get(Constants.USER_CONF_KEY_HADOOP2);
    if (StringUtils.isBlank(userName)) {
        userName = jobConf.get(Constants.USER_CONF_KEY);
        if (StringUtils.isBlank(userName)) {
            // neither user.name nor hadoop.mapreduce.job.user.name found
            throw new IllegalArgumentException(
                    " Found neither " + Constants.USER_CONF_KEY + " nor " + Constants.USER_CONF_KEY_HADOOP2);
        }
    }
    return userName;
}

From source file:gov.nih.nci.cabig.ctms.tools.DatabaseConfigurationAccessor.java

public String getDatabaseConfigurationName() {
    return StringUtils.isBlank(databaseConfigurationName) ? DEFAULT_DB_CONFIGURATION_NAME
            : databaseConfigurationName;
}

From source file:com.chadekin.jadys.commons.expression.SqlExpressionBuilder.java

public static boolean isBlankValue(Object value) {
    boolean isBlank = value == null || StringUtils.isBlank(value.toString());
    if (!isBlank) {
        boolean isEmptyCollection = value instanceof Collection && CollectionUtils.isEmpty((Collection) value);
        boolean isEmptyArray = value.getClass().isArray() && Array.getLength(value) == 0;
        isBlank = isEmptyCollection || isEmptyArray;
    }//from www . j  av  a2 s .c om
    return isBlank;
}

From source file:eionet.cr.harvest.util.HarvestMessageType.java

/**
 *
 * @param str/*from   ww w . j a v  a  2 s .co  m*/
 * @return
 */
public static HarvestMessageType parseFrom(String str) {

    if (StringUtils.isBlank(str)) {
        return null;
    } else {
        for (HarvestMessageType messageType : HarvestMessageType.values()) {

            if (str.equals(messageType.toString())) {
                return messageType;
            }
        }
    }

    return null;
}

From source file:com.sfs.whichdoctor.formatter.AgedDebtorsAnalysisFormatter.java

/**
 * Gets the field.//w w  w.j a  v a 2  s  .c o  m
 *
 * @param grouping the grouping
 * @param field the field
 * @param format the format
 * @return the field
 */
public static String getField(final AgedDebtorsGrouping grouping, final String field, final String format) {

    String value = "";

    if (grouping == null || field == null) {
        return value;
    }

    if (StringUtils.equalsIgnoreCase(field, "Grouping")) {
        value = grouping.getName();
        if (StringUtils.isBlank(value)) {
            value = "Uncategorised";
        }
    }

    if (StringUtils.equalsIgnoreCase(field, "Total")) {
        value = Formatter.toCurrency(grouping.getTotal(), "$");
        if (StringUtils.equalsIgnoreCase(format, "html")) {
            value = "<div style=\"text-align: right\">" + value + "</div>";
        }
    }

    if (value == null) {
        value = "";
    }
    return value;
}

From source file:com.aqnote.shared.cryptology.digest.SM.java

public final static String sm3(String src) {
    if (StringUtils.isBlank(src))
        return "";
    try {/*from w  ww .  ja  v  a2s  . c o m*/
        return sm3(src.getBytes(DEFAULT_CHARSET));
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return "";
}

From source file:com.twitter.hraven.Cluster.java

static void loadHadoopClustersProps(String filename) {
    // read the property file
    // populate the map
    Properties prop = new Properties();
    if (StringUtils.isBlank(filename)) {
        filename = Constants.HRAVEN_CLUSTER_PROPERTIES_FILENAME;
    }/*from www . j  av a  2 s .  c  o m*/
    try {
        //TODO : property file to be moved out from resources into config dir
        InputStream inp = Cluster.class.getResourceAsStream("/" + filename);
        if (inp == null) {
            LOG.error(filename + " for mapping clusters to cluster identifiers in hRaven does not exist");
            return;
        }
        prop.load(inp);
        Set<String> hostnames = prop.stringPropertyNames();
        for (String h : hostnames) {
            CLUSTERS_BY_HOST.put(h, prop.getProperty(h));
        }
    } catch (IOException e) {
        // An ExceptionInInitializerError will be thrown to indicate that an
        // exception occurred during evaluation of a static initializer or the
        // initializer for a static variable.
        throw new ExceptionInInitializerError(" Could not load properties file " + filename
                + " for mapping clusters to cluster identifiers in hRaven");
    }
}