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

public static boolean providersNameIsYidong(Context context) {
    String IMSI = getIMSI(context);
    if (IMSI.startsWith("46000") || IMSI.startsWith("46002")) {
        return true;
    }//w  w  w  .j  a va  2s  .  c o m
    return false;
}

From source file:Main.java

public static String getPropertyName(Method getter) {
    String getterName = getter.getName();
    assert getterName.startsWith("get"); // todo check for "is"
    return decapitalize(getterName.substring(3));
}

From source file:Main.java

public static String addFilePrefix(String dataString) {
    return dataString != null && !dataString.startsWith(FILE_PROTOCAL) ? FILE_PROTOCAL + dataString
            : dataString;/*from  w  w  w . j a  v  a  2 s.  com*/
}

From source file:Main.java

public static String okNameForMutator(AnnotatedMethod am, String prefix) {
    String name = am.getName();
    if (name.startsWith(prefix)) {
        return manglePropertyName(name.substring(prefix.length()));
    }//from   www. jav a 2s  .c  om
    return null;
}

From source file:Main.java

public static String stripCDATA(String s) {
    s = s.trim();/*  w  ww.  j  a v a 2 s.c  o  m*/
    if (s.startsWith("<![CDATA[")) {
        s = s.substring(9);
        int i = s.indexOf("]]>");
        if (i == -1) {
            throw new IllegalStateException("argument starts with <![CDATA[ but cannot find pairing ]]>");
        }
        s = s.substring(0, i);
    }
    return s;
}

From source file:Main.java

public static boolean isTextXML(String text) {
    text = text.trim();//from   w  w w. ja v  a 2 s  .com
    if (!(text.startsWith("<") && text.endsWith(">")))
        return false; //If text doesn't begin with "<" it's not XML

    int firstClose = text.indexOf(">");
    int lastOpen = text.lastIndexOf("<");

    if (lastOpen == 0 && text.lastIndexOf("/") == firstClose - 1)
        return true; //Example "<DIMES />
    if (text.substring(1, firstClose + 1).equals(text.substring(lastOpen + 2)))
        return true; //<XML> blah </XML>

    return false;
}

From source file:Main.java

public static String getDeviceName() {
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;
    if (model.startsWith(manufacturer)) {
        return capitalize(model);
    }// w w w  .j ava  2 s. co m
    if (manufacturer.equalsIgnoreCase("HTC")) {
        return "HTC " + model;
    }
    return capitalize(manufacturer) + " " + model;
}

From source file:Main.java

public static String getDexClassName(String dottedClassName) {
    if (dottedClassName == null || dottedClassName.isEmpty())
        throw new RuntimeException("Empty class name detected");

    String slashedName = dottedClassName.replace('.', '/');
    if (slashedName.startsWith("L") && slashedName.endsWith(";"))
        return slashedName;
    return "L" + slashedName + ";";
}

From source file:Main.java

public static String javaClassToSmali(String className) {
    if (className.startsWith("[")) {
        return className.replaceAll("\\.", "/");
    }/*from   w ww.  j a  v a2  s.  co m*/

    String javaName = smaliPrimitiveToJavaName.inverse().get(className);
    if (null != javaName) {
        return javaName;
    }

    if (className.endsWith(";") || (1 == className.length())) {
        // Already Smali format
        return className;
    }

    return "L" + className.replaceAll("\\.", "/") + ";";
}

From source file:ijfx.service.workflow.json.FileDeserializer.java

public static File deserialize(String possibleURL) {
    if (possibleURL.startsWith(FileSerializer.FILE_PREFIX)) {
        return new File(possibleURL.substring(FileSerializer.FILE_PREFIX.length()));
    } else {/*  w  ww .  ja v a2  s.  com*/
        return null;
    }
}