Example usage for java.lang String isEmpty

List of usage examples for java.lang String isEmpty

Introduction

In this page you can find the example usage for java.lang String isEmpty.

Prototype

public boolean isEmpty() 

Source Link

Document

Returns true if, and only if, #length() is 0 .

Usage

From source file:com.gs.obevo.util.DAStringUtil.java

/**
 * See {@link #normalizeWhiteSpaceFromString(String)}. This is the "old" version of that method, with a slightly
 * harder-to-read implementation. I want to switch to {@link #normalizeWhiteSpaceFromString(String)} as it is
 * a more standard implementation and thus easier to vet.
 *///from w ww  .  ja v  a 2s. co  m
public static String normalizeWhiteSpaceFromStringOld(String content) {
    if (content == null) {
        return null;
    }
    String[] lines = content.split("\\r?\\n");

    MutableList<String> newContent = Lists.mutable.empty();
    for (String line : lines) {
        line = line.trim();
        if (!line.isEmpty()) {
            line = line.replaceAll("\\s+", " ");
            newContent.add(line.trim());
        }
    }

    return newContent.makeString(" ").trim();
}

From source file:grails.plugins.sitemapper.ValidationUtils.java

public static void assertVideoDescription(String description) {
    if (description == null || description.isEmpty())
        throw new SitemapperException("Description not specified");
}

From source file:Main.java

public static String trimToId(String aName) {
    String result = aName;

    // if no name was given, generate an id
    if (result == null || result.isEmpty()) {
        return "id_" + java.util.UUID.randomUUID().toString();
    }// ww w . ja v  a2  s.  co  m
    // must be at least 2 characters long,must start with a letter
    else if (result.length() < 2 || !Character.isLetter(result.charAt(0))) {
        result = "id_" + result;
    }

    // capitalize, except first char (lower case)
    String[] words = result.split("\\W+"); // split into words
    result = ""; // reset result and build new
    for (int i = 0; i < words.length; i++) {
        result += (i == 0) ?
        // keep first word as is
                words[i] :
                // following words capitalize first char
                words[i].substring(0, 1).toUpperCase() + words[i].substring(1);
    }

    // umlauts, whitespaces and periods are not allowed
    result = result.replaceAll("\\s", "").replaceAll("\\.", "").replaceAll("\\u00c4", "Ae")
            .replaceAll("\\u00e4", "ae").replaceAll("\\u00d6", "Oe").replaceAll("\\u00f6", "oe")
            .replaceAll("\\u00dc", "Ue").replaceAll("\\u00fc", "ue").replaceAll("\\u00df", "ss");

    return result;
}

From source file:org.openehealth.ipf.labs.maven.confluence.export.AbstractConfluenceExportMojo.java

protected static boolean defined(String value) {
    return value != null && !value.isEmpty();
}

From source file:com.moki.touch.util.UrlUtil.java

public static String getUrlExtention(String url) {
    if (url == null || url.isEmpty() || url.length() < 4) {
        return "";
    }/*from   ww  w.  j  av a 2s  .c  om*/
    return url.substring(url.length() - 4).toLowerCase();
}

From source file:com.lithium.flow.util.CsvFormats.java

private static char getChar(@Nonnull Config config, @Nonnull String key, char def) {
    String value = config.getString(key);
    return value.isEmpty() ? def : value.charAt(0);
}

From source file:com.lithium.flow.util.CsvFormats.java

private static Character getChar(@Nonnull Config config, @Nonnull String key) {
    String value = config.getString(key);
    return value.isEmpty() ? null : value.charAt(0);
}

From source file:Main.java

public static void visitRecursively(Node node, BufferedWriter bw) throws Exception {
    NodeList list = node.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
        // get child node
        Node childNode = list.item(i);
        if (childNode.getNodeType() == Node.TEXT_NODE) {
            System.out.println("Found Node: " + childNode.getNodeName() + " - with value: "
                    + childNode.getNodeValue() + " Node type:" + childNode.getNodeType());

            String nodeValue = childNode.getNodeValue();
            nodeValue = nodeValue.replace("\n", "").replaceAll("\\s", "");
            if (!nodeValue.isEmpty()) {
                System.out.println(nodeValue);
                bw.write(nodeValue);//from  w  w  w  . ja v  a 2s. co m
                bw.newLine();
            }
        }
        visitRecursively(childNode, bw);
    }
}

From source file:Util.java

/**
 * Checks if classNames belongs to package
 * /*from  w  w  w  . j  a v  a 2s .c om*/
 * @param className
 *            class name
 * @param packageName
 *            package
 * @return true if belongs
 */
public static boolean isPackageMember(String className, String packageName) {
    if (!className.contains(".")) {
        return packageName == null || packageName.isEmpty();
    } else {
        String classPackage = className.substring(0, className.lastIndexOf('.'));
        return packageName.equals(classPackage);
    }
}

From source file:Main.java

public static String getFullName(String firstName, String lastName) {
    StringBuffer result = new StringBuffer();
    boolean flag = false;
    if (lastName != null && !lastName.isEmpty()) {
        result.append(lastName);//from w  w  w. jav a 2s  .  c  om
        flag = true;
    }
    if (firstName != null && !firstName.isEmpty()) {
        if (flag) {
            result.append(", ");
        }
        result.append(firstName);
    }

    return result.toString();
}