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

/**
 * @param source/* w w w  .ja v  a  2 s .co m*/
 * @param name
 * @return
 */
private static int getTagPos(String source, String name) {
    int pos = -1;
    if (source == null || source.isEmpty() || name == null || name.isEmpty())
        return pos;

    int start;
    String temp = source;

    while ((start = temp.indexOf(name)) >= 0) {
        temp = temp.substring(start);
        if (temp.charAt(name.length()) == ' ' || temp.charAt(name.length()) == '=')
            return start;

        temp = temp.substring(name.length());
    }

    return pos;
}

From source file:Main.java

public static void rateUs(String packageName) {
    if (packageName.isEmpty())
        packageName = mContext.getPackageName();
    String jumpUrl = "";
    Intent i = getIntent(mContext);//from  w  w  w.ja  v a2  s  . com
    boolean b = judge(mContext, i);
    if (b == false) {
        String tGooglePlayNo = "https://play.google.com/store/apps/details?id=" + packageName;
        jumpUrl = tGooglePlayNo;
    } else {
        String tGooglePlayYes = "market://details?id=" + packageName;
        jumpUrl = tGooglePlayYes;
    }

    Uri uri = Uri.parse(jumpUrl);
    Intent it = new Intent(Intent.ACTION_VIEW, uri);
    mContext.startActivity(it);
}

From source file:Main.java

/**
 * return if str is empty// w w w .  jav  a 2s .  com
 *
 * @param str
 * @return
 */
public static boolean isEmpty(String str) {
    return str == null || str.length() == 0 || str.equalsIgnoreCase("null") || str.isEmpty() || str.equals("");
}

From source file:com.silverpeas.sandbox.converter.ODTConverter.java

public static void setDestinationPath(String destinationPath) {
    if (!destinationPath.isEmpty()) {
        DESTINATION_PATH = destinationPath;
        if (!destinationPath.endsWith("/")) {
            DESTINATION_PATH += "/";
        }/*from  w w w.  java  2  s  . c  o m*/
    }
}

From source file:Main.java

public static File getLastDirectory() {
    if (lastDirectory == null) {
        String home = System.getProperty("user.home");
        lastDirectory = home != null && !home.isEmpty() ? new File(home) : File.listRoots()[0];
    }//from w  ww  .j  a  v  a  2  s  .  co m
    return lastDirectory;
}

From source file:Main.java

public static void callPhone(Context ctx, String phoneNumber) {
    if (ctx == null) {
        return;/*from   www .  j av  a 2  s  .  c om*/
    }

    if (phoneNumber.isEmpty()) {
        return;
    }

    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));

    ctx.startActivity(intent);

}

From source file:Main.java

/**
 * Indicates if the passed node has a child node of the passed name 
 * @param element The node to inspect//from ww w.  j  av  a  2 s.  c  om
 * @param nodeName The name of the child node to look for
 * @param caseSensitive true for a case sensitive node, false for case insensitive
 * @return true if the named child node exists, false otherwise
 */
public static boolean hasChildNodeByName(Node element, CharSequence nodeName, boolean caseSensitive) {
    if (element == null)
        return false;
    if (nodeName == null)
        return false;
    final String name = nodeName.toString().trim();
    if (name.isEmpty())
        return false;
    NodeList list = element.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
        Node node = list.item(i);
        if (caseSensitive) {
            if (node.getNodeName().equals(name))
                return true;
        } else {
            if (node.getNodeName().equalsIgnoreCase(name))
                return true;
        }
    }
    return false;
}

From source file:Main.java

public static Date getDate(String dataString) {
    try {//from  w  w w .j  av  a2  s  .co  m
        if (dataString == null || dataString.isEmpty()) {
            return null;
        }
        return getZuluFormat().parse(dataString);
    } catch (Exception ex) {
        return null;
    }
}

From source file:Main.java

/**
 * return if str is empty//ww w .  jav a 2 s  . c  o m
 *
 * @param str
 * @return
 */
public static boolean isEmpty(String str) {
    if (str == null || str.length() == 0 || str.equalsIgnoreCase("null") || str.isEmpty() || str.equals("")) {
        return true;
    } else {
        return false;
    }
}

From source file:Main.java

public static String GetChildElementText(Element element, String name) {
    if (element != null && name != null && !name.isEmpty()) {
        NodeList nodes = element.getChildNodes();

        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);

            if (node instanceof Element && name.equals(node.getNodeName())) {
                return node.getTextContent();
            }//from  w ww  .j  a v a 2s. co  m
        }
    }
    return null;
}