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

/**
 * Clean up url/*ww w .jav  a2s.co m*/
 *
 * @param url
 * @return cleaned url
 */
public static String cleanUrl(String url) {
    if (url.startsWith("/")) {
        return url.substring(1, url.length());
    }
    return url;
}

From source file:Main.java

public static boolean canBeCompilerOptionValue(final String text) {
    if (text.startsWith("-")) { // option or negative number
        return text.length() > 1 && Character.isDigit(text.charAt(1));
    }//from ww  w.j a  va2 s . c o  m
    return !text.startsWith("+");
}

From source file:Main.java

public static String deleteSpace(String str) {
    if (str.startsWith(" ")) {
        str = str.substring(1, str.length()).trim();
    } else if (str.endsWith(" ")) {
        str = str.substring(0, str.length() - 1).trim();
    }//w  ww  .j av a 2  s . c  om

    return str;
}

From source file:Main.java

public static String normalizeCloudName(String cloudName) {
    if (!(cloudName.startsWith("=") || cloudName.startsWith("*") || cloudName.startsWith("+"))) {
        return "=" + cloudName;
    }//from   w  w  w. j ava  2 s  .  c  o m
    return cloudName;
}

From source file:Main.java

public static String getCloudThumbPath(String cloudPath) {
    if (cloudPath.startsWith("/")) {
        return CLOUD_SYSTEM_DIR + cloudPath.substring(1);
    } else {/*from www . ja  v a2  s.c  o  m*/
        return CLOUD_SYSTEM_DIR + cloudPath;
    }
}

From source file:Main.java

public static String getRoot(String loc) {
    if (loc.startsWith("/mnt/sdcard")) {
        return "/mnt/sdcard";
    } else if (loc.startsWith("/mnt/innerDisk")) {
        return "/mnt/innerDisk";
    } else {//from  w  w w .ja va  2 s.co m
        return "/mnt/usbDisk1";
    }
    //return loc;
}

From source file:Main.java

public static String getTemplateShortName(String templateName) {
    if (templateName.startsWith(SMALLTALK_TEMPLATE_PREFIX)) {
        return templateName.substring(SMALLTALK_TEMPLATE_PREFIX.length());
    }//from   w w  w .j a  v  a 2 s  .  co  m
    return templateName;
}

From source file:Main.java

public static String classify(String packageName, String className) {
    if (className.startsWith(".")) {
        return packageName + className;
    } else if (className.contains(".")) {
        return className;
    } else {//from  ww  w  .j av  a 2s .c  om
        return packageName + "." + className;
    }
}

From source file:Main.java

public static String normalizeSetterName(String name) {
    if (name.startsWith("set_")) {
        return name.substring(4);
    } else if (name.startsWith("set")) {
        name = name.substring(3);/*from w  ww.jav  a 2  s .  c om*/
        return name.substring(0, 1).toLowerCase() + name.substring(1);
    } else if (name.startsWith("Set")) {
        return name.substring(3);
    } else {
        return name;
    }
}

From source file:Main.java

public static String getPropertyName(String name) {
    if (name.startsWith(IS)) {
        return name.substring(IS.length());
    } else if (name.startsWith(GET)) {
        return name.substring(GET.length());
    } else if (name.startsWith(SET)) {
        return name.substring(SET.length());
    }/*ww w  .j  a v a  2  s  . c  o m*/
    return null;
}