Example usage for java.lang String startsWith

List of usage examples for java.lang String startsWith

Introduction

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

Prototype

public boolean startsWith(String prefix) 

Source Link

Document

Tests if this string starts with the specified prefix.

Usage

From source file:Main.java

/**
 * Simply removes double-quotes from the beginning and end of given string
 * @param str//from   www.  j a v  a 2 s. c  o  m
 * @return
 */
public static final String dequote(String str) {
    if (str.startsWith("\""))
        str = str.substring(1);
    if (str.endsWith("\""))
        str = str.substring(0, str.length() - 1);
    return str;
}

From source file:Main.java

public static String checkMucVerifyDomain(String domain) {
    if (!TextUtils.isEmpty(domain) && !domain.startsWith("@")) {
        return "@" + domain;
    }//from  w w w.  j  a  va  2s . co m
    return domain;
}

From source file:Main.java

/**
 * Whether the URI is a local one.//from   w  w w.  j  av  a  2 s. c  o  m
 * 
 * @param uri
 * @return
 */
public static boolean isLocal(String uri) {
    if (uri != null && !uri.startsWith("http://")) {
        return true;
    }
    return false;
}

From source file:Main.java

/**
 * Remove a prefix if it is present (e.g. starting file:// in the case
 * of android)//ww w. j  av a2 s  .  com
 */
public static String stripPrefixIfPresent(String prefix, String path) {
    if (!path.startsWith(prefix)) {
        return path;
    } else {
        return path.substring(prefix.length());
    }
}

From source file:capital.scalable.restdocs.util.FieldUtil.java

public static String fromGetter(String javaMethodName) {
    int cut = javaMethodName.startsWith("get") ? "get".length() : "is".length();
    return uncapitalize(javaMethodName.substring(cut, javaMethodName.length()));
}

From source file:Main.java

/**
 * Retrieves the information(deviceId, sim serial number etc) of the device on which app is running 
 * /*from  w  w  w  . j  ava  2s. co  m*/
 * @return the deviceID, if no deviceID is available the Android build MODEL is returned.
 */
public static String getDeviceName() {
    final String deviceName;

    String manufacturer = "" + Build.MANUFACTURER;
    String model = Build.MODEL;

    if (model.startsWith(manufacturer)) {
        deviceName = model;
    } else {
        deviceName = manufacturer + " " + model;
    }

    return deviceName;
}

From source file:Main.java

/**
 * Remove the leading and trailing quotes from <code>str</code>.
 * E.g. if str is '"one two"', then 'one two' is returned.
 *
 * @param str The string from which the leading and trailing quotes
 * should be removed.//from w  w w . ja v a 2s  .  com
 *
 * @return The string without the leading and trailing quotes.
 */
static String stripLeadingAndTrailingQuotes(String str) {
    if (str.startsWith("\"")) {
        str = str.substring(1, str.length());
    }
    if (str.endsWith("\"")) {
        str = str.substring(0, str.length() - 1);
    }
    return str;
}

From source file:Main.java

/**
 * Checks wether the specified path expression starts with the
 * <code>instance</code> function.
 * <p/>/* w w w . j  ava2 s. co  m*/
 * Examples:
 * <ul>
 * <li><code>"a"</code> returns <code>false</code>.
 * <li><code>"a[.=instance('i')/b]"</code> returns <code>false</code>.
 * <li><code>"instance('i')/a"</code> returns <code>true</code>.
 * <li><code>"instance(/b/c)/a"</code> returns <code>true</code>.
 * </ul>
 *
 * @param path the path expression.
 * @return <code>true</code> if the specified path expression starts with
 * the <code>instance</code> function, <code>false</code> otherwise.
 */
public static boolean hasInstanceFunction(String path) {
    return path != null && path.startsWith(INSTANCE_FUNCTION);
}

From source file:Main.java

public static Document getXmlDocFromURI(String xmlFile) throws Exception {
    if (xmlFile.startsWith("http"))
        return getXmlDocFromURI(new URL(xmlFile).openStream());
    else//from ww  w  .ja va 2s .co m
        return getXmlDocFromURI(new FileInputStream(new File(xmlFile)));
}

From source file:Main.java

public static String getPlatformName(String hwRev) {
    String platformName;//from ww w  .ja v  a 2  s.c  o  m
    if (hwRev.startsWith("snowy")) {
        platformName = "basalt";
    } else if (hwRev.startsWith("spalding")) {
        platformName = "chalk";
    } else {
        platformName = "aplite";
    }
    return platformName;
}