List of usage examples for java.lang String startsWith
public boolean startsWith(String prefix)
From source file:Main.java
public static String getCountryCode(EditText dialCode) { if (dialCode != null) { String code = dialCode.getText().toString(); if (code != null && code.startsWith("+")) { code = code.substring(1);/*from w w w . jav a 2 s.c o m*/ } return code; } return null; }
From source file:Main.java
/** * find all getter and is method and return the value by map. *///from w w w .ja va 2 s . c om public static Map<String, Object> getProperties(Object bean) { Map<String, Object> map = new HashMap<>(); for (Method method : bean.getClass().getMethods()) { String name = method.getName(); if (((name.length() > 3 && name.startsWith("get")) || (name.length() > 2 && name.startsWith("is"))) && Modifier.isPublic(method.getModifiers()) && method.getParameterTypes().length == 0 && method.getDeclaringClass() != Object.class) { int i = name.startsWith("get") ? 3 : 2; String key = name.substring(i, i + 1).toLowerCase() + name.substring(i + 1); try { map.put(key, method.invoke(bean, new Object[0])); } catch (Exception e) { } } } return map; }
From source file:Main.java
public static boolean isVailUrl(String url) { if (TextUtils.isEmpty(url)) { return false; }/*from ww w . ja va 2 s .c o m*/ return url.startsWith("http://") || url.startsWith("https://") || url.startsWith("wwww."); }
From source file:Main.java
public static boolean isDue(byte[] data) { String[] strs = getDateInfoFromDate(data); if (strs != null && strs.length == 2) { String saveTimeStr = strs[0]; while (saveTimeStr.startsWith("0")) { saveTimeStr = saveTimeStr.substring(1, saveTimeStr.length()); }/* w ww .j a va 2s. c o m*/ long saveTime = Long.valueOf(saveTimeStr); long deleteAfter = Long.valueOf(strs[1]); if (System.currentTimeMillis() > saveTime + deleteAfter * 1000) { return true; } } return false; }
From source file:io.pivotal.cla.security.GitHubAuthenticationEntryPoint.java
public static boolean isAdmin(String secretState) { return secretState != null && secretState.startsWith("ADMIN"); }
From source file:org.codehaus.groovy.grails.plugins.springsecurity.RedirectUtils.java
/** * Build a redirect url./*from ww w . j av a2 s .co m*/ * @param request the request * @param response the response * @param url the target url to redirect to * @return the url */ public static String buildRedirectUrl(final HttpServletRequest request, final HttpServletResponse response, final String url) { if (!url.startsWith("http://") && !url.startsWith("https://")) { String scheme = request.getScheme(); int serverPort = RESOLVER.getServerPort(request); boolean inHttp = "http".equalsIgnoreCase(scheme); boolean inHttps = "https".equalsIgnoreCase(scheme); boolean includePort = !((inHttp && serverPort == 80) || (inHttps && serverPort == 443)); String port = includePort ? ":" + serverPort : ""; return scheme + "://" + request.getServerName() + port + request.getContextPath() + url; } return url; }
From source file:org.springsource.sinspctr.rest.ResourceLocator.java
public static File getClasspathRelativeFile(String path) throws URISyntaxException { if (path.startsWith("/")) { path = path.substring(1);/*from w w w.j ava 2 s .c o m*/ } return new File(findClassLoader().getResource(path).toURI()); }
From source file:Main.java
public static void findClassesInApk(String apkPath, String packageName, List<String> classNames) throws IOException { DexFile dexFile = null;/*from w w w . j av a 2 s.c o m*/ try { dexFile = new DexFile(apkPath); Enumeration<String> apkClassNames = dexFile.entries(); while (apkClassNames.hasMoreElements()) { String className = apkClassNames.nextElement(); if (className.startsWith(packageName) && isToplevelClass(className)) { classNames.add(className); } } } catch (IOException e) { android.util.Log.w(LOGTAG, "Error finding classes at apk path: " + apkPath, e); } }
From source file:Main.java
private static String formatLocation(String address) { if (address != null && address.trim().length() > 0) { if (address.startsWith(",")) return formatLocation(address.substring(1)); }//from www .j a v a2 s . com return address; }
From source file:Main.java
public static String getPrefixNS(String uri, Node e) { while (e != null && e.getNodeType() == Node.ELEMENT_NODE) { NamedNodeMap attrs = e.getAttributes(); for (int n = 0; n < attrs.getLength(); n++) { Attr a = (Attr) attrs.item(n); String name = a.getName(); if (name.startsWith("xmlns:") && a.getNodeValue().equals(uri)) { return name.substring("xmlns:".length()); }/*from w w w .j a va 2 s.c o m*/ } e = e.getParentNode(); } return null; }