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:Main.java

/** Returns the talker ID and sentence ID as a single String, ex: "GPGGA". */
public static String getType(String nmeaSentence) {
    if (nmeaSentence != null && !nmeaSentence.isEmpty() && nmeaSentence.startsWith("$")) {
        return nmeaSentence.substring(1, 6);
    } else {//  w  ww  . ja  v a2  s.c o m
        return "Unknown";
    }
}

From source file:Main.java

/**
 * Tries to convert the string to an Integer. If there is an error it
 * returns null/*from   w  ww .  j a  va  2s  .  c  o m*/
 *
 * @param number
 * @return
 */
public static Integer convertStringToInteger(String number) {
    if (number == null || number.isEmpty()) {
        return null;
    }

    try {
        return Integer.parseInt(number);
    } catch (NumberFormatException e) {
        return null;
    }
}

From source file:Main.java

/**
 * Returns a string formatted time//  w w w  . ja  v  a  2 s. c  o m
 *
 * @return String of formatted time.
 */
static public String getTimeAsString(Calendar c, String format) {
    if (format.isEmpty()) {
        format = "hh:mm Hours";
    }

    SimpleDateFormat sdf = new SimpleDateFormat(format);

    return sdf.format(c.getTimeInMillis());
}

From source file:Main.java

public static boolean stringIsEmpty(String text) {
    boolean isEmpty = true;
    if (text != null) {
        String tmp = text.replaceAll("\\s", "");
        if (!tmp.isEmpty()) {
            isEmpty = false;/*from  w  w w  .  java 2 s . co  m*/
        }
    }
    return isEmpty;
}

From source file:Main.java

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

From source file:Main.java

/**
 * Returns the registered extension for the given MIME type. Note that some
 * MIME types map to multiple extensions. This call will return the most
 * common extension for the given MIME type.
 * // w  w  w.ja va  2 s  .  c o m
 * @param mimeType
 *            A MIME type (i.e. text/plain)
 * @return The extension for the given MIME type or null iff there is none.
 */
public static String guessExtensionFromMimeType(String mimeType) {
    if (mimeType == null || mimeType.isEmpty()) {
        return null;
    }
    return mimeTypeToExtensionMap.get(mimeType);
}

From source file:Main.java

/**
 * Returns true if the given extension has a registered MIME type.
 * //ww w .  jav  a2s .com
 * @param extension
 *            A file extension without the leading '.'
 * @return True iff there is an extension entry in the map.
 */
public static boolean hasExtension(String extension) {
    if (extension == null || extension.isEmpty()) {
        return false;
    }
    return extensionToMimeTypeMap.containsKey(extension);
}

From source file:com.gargoylesoftware.js.CodeUpdater.java

private static boolean isCodeStart(final String line) {
    return !line.isEmpty() && Character.isAlphabetic(line.charAt(0)) && !line.startsWith("package")
            && !line.startsWith("import");
}

From source file:Main.java

private static String formatDatabaseName(Context context, String name) {
    if (name == null || name.isEmpty()) {
        name = getDefaultDatabaseName(context);
    }//from w ww  .j  a  va  2 s  .  co  m

    if (!name.startsWith(DATABASE_START)) {
        name = DATABASE_START + name;
    }
    if (!name.endsWith(DATABASE_TYPE)) {
        name += DATABASE_TYPE;
    }

    return name;
}

From source file:Main.java

/**
 * @param element/*from  w w  w  . j  a v a  2 s  .c o m*/
 * @param atrName
 * @return String attribute or nul if not defined or empty
 */
public static String getSingleNonEmptyStringAtributeFromElement(Element element, String atrName) {
    String atrValue = element.getAttribute(atrName);
    return atrValue.isEmpty() ? null : atrValue;
}