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.egt.core.jsf.component.HipervinculoVerDetalle.java

private boolean isNotEnabled() {
    String script = this.getOnClick();
    return StringUtils.isBlank(script);
}

From source file:com.alibaba.otter.manager.biz.utils.RegexUtils.java

public static String findFirst(String originalStr, String regex) {
    if (StringUtils.isBlank(originalStr) || StringUtils.isBlank(regex)) {
        return StringUtils.EMPTY;
    }//from w w  w.  jav a 2  s  .  c om

    PatternMatcher matcher = new Perl5Matcher();
    if (matcher.contains(originalStr, patterns.get(regex))) {
        return StringUtils.trimToEmpty(matcher.getMatch().group(0));
    }
    return StringUtils.EMPTY;
}

From source file:com.switchfly.inputvalidation.sanitizer.CurrencyCodeSanitizer.java

@Override
public String execute(String content) {
    if (StringUtils.isBlank(content)) {
        return content;
    }/*w  w  w  .ja v a 2 s. c  om*/
    try {
        return Currency.getInstance(StringUtils.upperCase(content)).toString();
    } catch (Exception e) {
        HtmlSanitizer htmlSanitizer = new HtmlSanitizer();
        String sanitized = htmlSanitizer.execute(content);
        _logger.warn("Invalid currency code (" + sanitized + "). Setting currency code to \"USD\".");
        return "USD";
    }
}

From source file:ae.constraint.NotBlank.java

@Override
public boolean isValid(final String value) {
    return !StringUtils.isBlank(value);
}

From source file:com.alibaba.ims.platform.dict.DictManager.java

/**
 * /* w w  w  . j a v  a2 s .com*/
 *
 * @param key
 * @param value
 */
public static void put(String key, String value) {
    if (StringUtils.isBlank(key)) {
        return;
    }
    getElement(key, true).setValue(value);
}

From source file:com.switchfly.inputvalidation.sanitizer.CobrandNameSanitizer.java

@Override
public String execute(String content) {
    if (StringUtils.isBlank(content)) {
        return content;
    }//from  ww w .ja  v  a 2  s . c  o m
    Pattern pattern = Pattern.compile("[\\w-]+");
    if (!pattern.matcher(content).matches()) {
        String sanitized = new HtmlSanitizer().execute(content);
        _logger.warn("Invalid cobrand name (" + sanitized + "). Setting cobrand name to \"default\".");
        return "default";
    }
    return content;
}

From source file:eionet.cr.util.SortOrder.java

/**
 *
 * @param order/*from  ww  w.  j av  a  2s.  co m*/
 * @return
 */
public static String oppositeSortOrder(String order) {
    if (StringUtils.isBlank(order))
        return ASCENDING.toString();
    else
        return parse(order).toOpposite().toString();
}

From source file:gov.nih.nci.cabig.caaers.dao.query.DeviceQuery.java

public void filterByType(String type) {
    if (StringUtils.isBlank(type)) {
        andWhere("d.type IS NULL OR d.type = ''");
    } else {/*from  w  w  w . j  av  a2  s .c  o  m*/
        andWhere("lower(d.type) = :" + DEVICE_TYPE);
        setParameter(DEVICE_TYPE, type.toLowerCase());
    }
}

From source file:com.fengduo.bee.commons.util.NumberParser.java

public static float parseFloat(String data, float defaultValue) {
    if (StringUtils.isBlank(data)) {
        return defaultValue;
    }//from  w  w w . j ava2s.  c  o  m
    return NumberUtils.toFloat(data, defaultValue);
}

From source file:com.feedzai.commons.sql.abstraction.engine.DatabaseFactory.java

/**
 * Gets a database connection from the specified properties.
 *
 * @param p The database properties./*  w w  w  . j a v a2s . c o m*/
 * @return A reference of the specified database engine.
 * @throws DatabaseFactoryException If the class specified does not exist or its not well implemented.
 */
public static DatabaseEngine getConnection(Properties p) throws DatabaseFactoryException {
    PdbProperties pdbProperties = new PdbProperties(p, true);
    AbstractDatabaseEngine de = null;

    final String engine = pdbProperties.getEngine();

    if (StringUtils.isBlank(engine)) {
        throw new DatabaseFactoryException("pdb.engine property is mandatory");
    }

    try {
        Class<?> c = Class.forName(engine);

        Constructor cons = c.getConstructor(PdbProperties.class);
        de = (AbstractDatabaseEngine) cons.newInstance(pdbProperties);

        Class<? extends AbstractTranslator> tc = de.getTranslatorClass();

        if (pdbProperties.isTranslatorSet()) {
            final Class<?> propertiesTranslator = Class.forName(pdbProperties.getTranslator());
            if (!AbstractTranslator.class.isAssignableFrom(propertiesTranslator)) {
                throw new DatabaseFactoryException("Provided translator does extend from AbstractTranslator.");
            }

            tc = (Class<? extends AbstractTranslator>) propertiesTranslator;
        }

        final Injector injector = Guice.createInjector(
                new PdbModule.Builder().withTranslator(tc).withPdbProperties(pdbProperties).build());
        injector.injectMembers(de);

        return de;
    } catch (DatabaseFactoryException e) {
        throw e;
    } catch (Exception e) {
        throw new DatabaseFactoryException(e);
    }
}