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

@SuppressWarnings("deprecation")
public static String decodeSubscriptionURL(final String url) {
    if (url.startsWith("feed/")) {
        return "feed/" + URLDecoder.decode(url.substring(5));
    } else {//from   w w  w. j  ava2 s.c o  m
        return url;
    }
}

From source file:Main.java

public static void openUrl(Context context, String url) {
    if (!url.startsWith("https://") && !url.startsWith("http://")) {
        url = "http://" + url;
    }//w  w w .j  a  v a2s  .  c om

    Intent i = new Intent(Intent.ACTION_VIEW);
    i.setData(Uri.parse(url));
    //i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    Log.d("WipiwayController", "openUrl . Openning link - " + url);

    context.startActivity(i);
}

From source file:Main.java

public static String setter2property(String methodName) {
    if (!methodName.startsWith("set") || methodName.length() < 4) {
        return null;
    }//from   www  . ja v  a 2  s . co m
    return Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4);
}

From source file:Main.java

public static String getDeviceName() {
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;
    if (model.startsWith(manufacturer)) {
        return model.toUpperCase();
    } else {/*from w  w w  .  j  a va2 s .c o  m*/
        return manufacturer + " " + model;
    }
}

From source file:Main.java

/**
 * Removes leading XML declaration from xml if present.
 * @param xml/*from ww  w. ja  va 2 s  .c  o  m*/
 * @return
 */
public static String omitXmlDeclaration(String xml) {
    if (xml.startsWith("<?xml") && xml.contains("?>")) {
        return xml.substring(xml.indexOf("?>") + 2).trim();
    }

    return xml;
}

From source file:Main.java

public static String filterBOMJsonStr(String jsonStr) {
    if (jsonStr != null && jsonStr.startsWith("\ufeff")) {
        jsonStr = jsonStr.replaceAll("\ufeff", "");
    }//from  w  w  w  . ja  v  a2 s.c  o  m
    return jsonStr;
}

From source file:Main.java

public static String getDisplayableAddress(String impsAddress) {
    if (impsAddress.startsWith("wv:")) {
        return impsAddress.substring(3);
    }/*from   w  w w. j  a v  a 2s  .c  o m*/
    return impsAddress;
}

From source file:Main.java

public static boolean hasInnerRef(String fieldName) {
    return fieldName != null && fieldName.startsWith("this$");
}

From source file:Main.java

public static String getDeviceModel(Context ctxt) {
    String manufacturer = Build.MANUFACTURER;
    String model = Build.MODEL;
    if (model.startsWith(manufacturer)) {
        return model;
    } else {/*  w ww.j ava2s . c  o  m*/
        return manufacturer + " " + model;
    }
}

From source file:Main.java

/**
 * Check if object is expression base on altSyntax
 *
 * @param value to treat as an expression
 * @return true if it is an expression/* www  .  ja v  a 2s .  c  o  m*/
 */
public static boolean isExpression(Object value) {
    String expr = value.toString();
    return expr.startsWith("%{") && expr.endsWith("}");
}