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:de.thischwa.pmcms.tool.Utils.java

public static String getExtension(String path) {
    if (StringUtils.isBlank(path))
        return null;
    int lastExtPos = path.lastIndexOf(".");
    return (lastExtPos != -1) ? path.substring(lastExtPos + 1) : null;
}

From source file:cn.vlabs.duckling.vwb.ui.action.HtmlValidateUtil.java

public static boolean checkHtmlTextValidate(String content) {
    if (StringUtils.isBlank(content)) {
        return true;
    }//w  w  w.  j  av a 2 s. c o  m

    if (!containsInvalidateUrl(content)) {
        return true;
    }

    SAXBuilder builder = new SAXBuilder("org.cyberneko.html.parsers.SAXParser", true);
    try {
        Document doc = builder.build(new StringReader(content));
        Element e = doc.getRootElement();
        List<Element> forms = new ArrayList<Element>();
        fillFormElement(e, forms);
        for (Element form : forms) {
            String actionStr = form.getAttributeValue("action");
            getInvalidateFormAction().contains(actionStr);
            return false;
        }
    } catch (Throwable e) {
        log.error("?html?", e);
    }

    return true;
}

From source file:com.sic.bb.jenkins.plugins.sicci_for_xcode.util.PluginUtils.java

public static Pattern createPattern(List<String> stringList) {
    StringBuilder regex = new StringBuilder();

    if (stringList != null) {
        regex.append('(');

        for (String item : stringList) {
            if (StringUtils.isBlank(item))
                continue;

            regex.append(stringToPattern(item));
            regex.append('|');
        }/*from ww w .  j  a  va  2  s .  c o  m*/

        regex.deleteCharAt(regex.length() - 1);
        regex.append(')');
    }

    return Pattern.compile(regex.toString());
}

From source file:com.jodo.notify.util.JacksonUtil.java

public static <T> T toJava(String str, Class<T> clazz) {
    if (StringUtils.isBlank(str)) {
        return null;
    }//  w  w  w  .  ja v a  2 s. c o m
    try {
        return mapper.readValue(str, clazz);
    } catch (Exception e) {
        e.printStackTrace();
        System.out.println("String    [   " + str + "  ]  can not be parse to " + clazz.getName());
        throw new RuntimeException(e);
    }
}

From source file:com.salesmanager.central.util.SecurityUtil.java

/**
 * Determines if a user has roles for seeing / modifying the appropriate resource
 * @param request/*from   w ww.  j  a v  a2 s.c  om*/
 * @param role
 * @return
 */
public static boolean isUserInRole(HttpServletRequest request, String role) {

    try {

        if (StringUtils.isBlank(role)) {
            return true;
        }

        UserPrincipal principal = (UserPrincipal) request.getSession().getAttribute("PRINCIPAL");

        if (principal == null) {
            return false;
        }

        Context ctx = (Context) request.getSession().getAttribute(ProfileConstants.context);

        if (ctx.getMasterRole().equals("superuser")) {
            return true;
        }

        if (role.equals("superuser")) {
            if (ctx.getMasterRole().equals("superuser")) {
                return true;
            }
        } else {
            if (ctx.getMasterRole().equals("admin")) {
                return true;
            }
        }

        if (ctx.getMasterRole().equals("admin")) {
            return true;
        }

        return com.salesmanager.core.util.SecurityUtil.isUserInRole(request, role);

    } catch (Exception e) {
        log.error("Customer " + e);
    }

    return false;

}

From source file:com.baidu.rigel.biplatform.ma.model.utils.GsonUtils.java

/**
 * json?java/*from ww  w  .ja  va 2  s  .  c o  m*/
 * 
 * @param json
 * @param clazz
 * @return
 */
public static <T> T fromJson(String json, Class<T> clazz) {
    if (StringUtils.isBlank(json)) {
        return null;
    }
    return GSON.fromJson(json, clazz);
}

From source file:com.thoughtworks.cruise.materials.TfsServer.java

private static String getPropertyOrBomb(String propertyName) {
    String username = System.getenv(propertyName);
    if (StringUtils.isBlank(username))
        throw new RuntimeException(String.format("%s is not set", propertyName));
    return username;
}

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

public static boolean isEmpty(PrimaryKeyJoinColumn column) {
    boolean empty = false;
    if (StringUtils.isBlank(column.getName()) && StringUtils.isBlank(column.getReferencedColumnName())
            && StringUtils.isBlank(column.getColumnDefinition())
            && ForeignKeyValidator.isEmpty(column.getForeignKey())) {
        empty = true;//from   www.  j a v a 2 s.  c o  m
    }
    if (!empty && StringUtils.isBlank(column.getName()) && StringUtils.isNotBlank(column.getImplicitName())) {
        column.setName(column.getImplicitName());
        column.setImplicitName(null);
    }
    if (!empty && StringUtils.isBlank(column.getName())) {
        empty = true;
    }
    return empty;
}

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

public static String getCustomerBillingState(Customer customer, Locale locale) {

    if (!StringUtils.isBlank(customer.getCustomerBillingState())) {
        return customer.getCustomerBillingState();
    }/*from w  w  w  .j  a va  2s  .  com*/

    Map zones = RefCache.getAllZonesmap((LanguageUtil.getLanguageNumberCode(locale.getLanguage())));
    Zone zone = (Zone) zones.get(customer.getCustomerBillingZoneId());
    if (zone != null) {
        return zone.getZoneName();
    }
    return "";
}

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

public static boolean isEmpty(CollectionTable table) {
    JoinColumnValidator.filter(table.getJoinColumn());

    return StringUtils.isBlank(table.getName()) && StringUtils.isBlank(table.getSchema())
            && StringUtils.isBlank(table.getCatalog()) && table.getJoinColumn().isEmpty()
            && table.getIndex().isEmpty();
}