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.enonic.cms.domain.security.user.DisplayNameResolver.java

public String resolveDisplayName(final String name, final String displayName, final UserInfo userInfo) {
    this.displayName = displayName;
    this.userName = name;

    if (userInfo != null) {
        setUserInfoFields(userInfo);//from  w w w .  j a  va2 s. c om
    }

    String resolvedDisplayName = doResolve();

    if (StringUtils.isBlank(resolvedDisplayName)) {
        throw new IllegalArgumentException("Could not resolve display name");
    }

    return resolvedDisplayName;
}

From source file:com.googlecode.jtiger.modules.ecside.common.HTMLOptionsUtil.java

public static String getOptionsList(Map imap, Object defaultKey, String otherAttribute) {
    StringBuffer rs = new StringBuffer();
    Iterator itor = imap.keySet().iterator();

    while (itor.hasNext()) {
        //         String key=(String)itor.next();
        //         String value=(String)imap.get(key);
        String key = String.valueOf(itor.next());

        String value = convertString(imap.get(key), "");

        String selected = "";
        if (key.equals(defaultKey)) {
            selected = "selected=\"selected\"";
        }/*w ww .  j  ava 2 s.co  m*/
        otherAttribute = StringUtils.isBlank(otherAttribute) ? "" : " " + otherAttribute + " ";

        rs.append("<option value=\"").append(key).append("\" ").append(selected).append(otherAttribute)
                .append(" >").append(value).append("</option>\n");
    }

    return rs.toString();
}

From source file:io.yields.math.framework.kpi.ExplorerDAO.java

public static void save(Explorer<?> explorer) {
    String group = explorer.getGroup();
    if (StringUtils.isBlank(group)) {
        group = NO_GROUP;/*from  www .jav a  2 s.co m*/
    }
    File destinationFolder = getRootFolder(group);

    if (!destinationFolder.exists()) {
        try {
            forceMkdir(destinationFolder);
        } catch (IOException ioe) {
            throw new IllegalStateException(
                    format("Destination folder for data export could not be created at %s",
                            destinationFolder.getAbsolutePath()),
                    ioe);
        }
    }

    if (!destinationFolder.isDirectory()) {
        throw new IllegalStateException(format("Destination path for data export %s is not a folder",
                destinationFolder.getAbsolutePath()));
    }

    if (!destinationFolder.canWrite()) {
        throw new IllegalStateException(format("Destination folder for data export %s is not writable",
                destinationFolder.getAbsolutePath()));
    }

    String fileName = explorer.getName().replaceAll("[^a-zA-Z0-9]", "_") + "_"
            + DATE_TIME_FORMATTER.format(LocalDateTime.now());

    File csvDestinationFile = new File(destinationFolder, fileName + "." + FILE_SUFFIX_CSV);
    csvExporter.export(explorer, csvDestinationFile);

    File jsonDestinationFile = new File(destinationFolder, fileName + "." + FILE_SUFFIX_JSON);
    jsonExporter.export(explorer, jsonDestinationFile);

}

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

public static Locale getLocale(String lang) {

    if (StringUtils.isBlank(lang)) {
        return getDefaultLocale();
    }// w  ww  .ja  v a  2  s. c o  m

    if (lang.equals(Constants.ENGLISH_CODE)) {
        return Locale.ENGLISH;
    } else if (lang.equals(Constants.FRENCH_CODE)) {
        return Locale.FRENCH;
    } else {
        log.warn("Resources for this language " + lang + " may not be handled by this system");
        return new Locale(lang);
    }

}

From source file:com.enonic.cms.core.security.user.DisplayNameResolver.java

public String resolveDisplayName(final String name, final String displayName, final UserFields userFields) {
    this.displayName = displayName;
    this.userName = name;

    if (userFields != null) {
        setUserInfoFields(userFields);/*  ww  w. j  a v a  2s . c om*/
    }

    String resolvedDisplayName = doResolve();

    if (StringUtils.isBlank(resolvedDisplayName)) {
        throw new IllegalArgumentException("Could not resolve display name");
    }

    return resolvedDisplayName;
}

From source file:edu.duke.cabig.c3pr.utils.web.propertyeditors.EnumByNameEditor.java

@Override
public void setAsText(String text) throws IllegalArgumentException {
    if (text == null || StringUtils.isBlank(text)) {
        setValue(null);// ww  w.  j  a  v a  2s  .c o  m
    } else {
        setValue(Enum.valueOf(enumClass, text));
    }
}

From source file:com.fms1.tools.HSSF.java

public static void Start(String args) {
    java.io.File fExcelFile = null;
    try {//from  w  w  w  .  j a  v  a  2s . c om
        fExcelFile = new java.io.File(args);
        Workbook workbook = Workbook.getWorkbook(fExcelFile);
        Sheet sheet = workbook.getSheet(1);
        int k = 0;
        if (!StringUtils.isBlank(sheet.getCell(0, k).getContents())) {
            k++;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:de.codesourcery.planning.demo.SampleResourceLocation.java

public SampleResourceLocation(String name) {

    if (StringUtils.isBlank(name)) {
        throw new IllegalArgumentException("name cannot be blank.");
    }/*from   www  .  j  a v  a2 s .c  om*/
    this.name = name;
}

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

public static Map parseTokenLine(String line, String delimiter) {

    BidiMap returnMap = new TreeBidiMap();

    if (StringUtils.isBlank(line) || StringUtils.isBlank(delimiter)) {
        return returnMap;
    }/*from w w w.j av  a  2 s  .  com*/

    StringTokenizer st = new StringTokenizer(line, delimiter);

    int count = 0;
    while (st.hasMoreTokens()) {
        String value = st.nextToken();
        returnMap.put(value, count);
        count++;
    }

    return returnMap;

}

From source file:com.redhat.rhn.common.util.ServletUtils.java

/** util function to take a servlet request and compute the path
 * relative to the server (not relative to the webapp).  needed
 * when getPath() is relative to the webapp instead of the server
 * @param req The request to inspect//from w  ww.  j  av  a  2s  .  c  om
 * @return The path requested.
 */
public static String getRequestPath(HttpServletRequest req) {
    try {
        String requestUri = (String) req.getAttribute("javax.servlet.forward.request_uri");
        if (StringUtils.isBlank(requestUri)) {
            requestUri = new URL(req.getRequestURL().toString()).getPath();
        }
        return requestUri;
    } catch (Exception e) {
        throw new IllegalArgumentException("Unable to parse url: " + req.getRequestURL());
    }
}