List of usage examples for java.lang String startsWith
public boolean startsWith(String prefix)
From source file:Main.java
/** * Returns true if the string starts with http:// or https://. * * @param uri string to evaluate//from w w w .j a va2 s . com * @return true if the string starts with http:// or https:// */ public static boolean startsWithHttpOrHttps(String uri) { if (uri == null) { return false; } // the scheme is case insensitive, according to RFC 7230, section 2.7.3: /* The scheme and host are case-insensitive and normally provided in lowercase; all other components are compared in a case-sensitive manner. */ String lowercaseUri = uri.toLowerCase(Locale.US); return lowercaseUri.startsWith("http://") || lowercaseUri.startsWith("https://"); }
From source file:Main.java
static Map<String, Method> getGetPropertyMethods(Class<?> beanClass) { HashMap<String, Method> props; if (getPropsCache.containsKey(beanClass)) { props = getPropsCache.get(beanClass); } else {//from ww w . j av a2 s. c o m props = new HashMap<String, Method>(); getPropsCache.put(beanClass, props); Method[] ms = beanClass.getMethods(); for (int i = 0; i < ms.length; i++) { Method m = ms[i]; String name = m.getName(); if (name.startsWith("get") && name.length() > 3 && Character.isUpperCase(name.charAt(3))) { name = name.substring(3); props.put(name, m); } } } return props; }
From source file:Main.java
public static String removeSizeQuote(String str) { if (str == null) { return null; }// ww w . j av a 2s . c o m if (str.startsWith("\"") && str.endsWith("\"") && str.length() > 2) { return str.substring(1, str.length()); } return str; }
From source file:Main.java
public static List<String> getJoins(Uri uri) { List<String> result = new ArrayList<String>(); Set<String> queryParameterNames = getQueryParameterNames(uri); Iterator<String> iterator = queryParameterNames.iterator(); while (iterator.hasNext()) { String param = iterator.next(); if (param.startsWith(TABLE)) { result.add(uri.getQueryParameter(param)); }/*from w ww .j a v a 2s . c o m*/ } return result; }
From source file:Main.java
public static String extractDomain(String url, boolean aggressive) { if (url.startsWith("http://")) url = url.substring("http://".length()); else if (url.startsWith("https://")) url = url.substring("https://".length()); if (aggressive) { if (url.startsWith("www.")) url = url.substring("www.".length()); // strip mobile from start if (url.startsWith("m.")) url = url.substring("m.".length()); }//from w ww .j a va2 s . c o m int slashIndex = url.indexOf("/"); if (slashIndex > 0) url = url.substring(0, slashIndex); return url; }
From source file:Main.java
/** * Get a uri's user-friendly display name * /*from w w w .ja va 2s . c o m*/ * @param context the application context * @param uri the uri to query * * @return a user-friendly display name */ public static String getUriDisplayName(Context context, Uri uri) { String displayName = null; String scheme = uri.getScheme(); if (scheme.startsWith("content")) { String[] proj = { OpenableColumns.DISPLAY_NAME }; Cursor cursor = context.getContentResolver().query(uri, proj, null, null, null); if (cursor != null) { int columnIndex = cursor.getColumnIndexOrThrow(OpenableColumns.DISPLAY_NAME); cursor.moveToFirst(); displayName = cursor.getString(columnIndex); cursor.close(); } } else if (scheme.startsWith("file")) { displayName = uri.getLastPathSegment(); } return displayName; }
From source file:Main.java
public static String getCoverFileForTrackFile(String filePath) { if (filePath.startsWith("file://")) filePath = filePath.substring(7); int p = filePath.lastIndexOf('/'); if (p <= 0) return null; filePath = filePath.substring(0, p); String cand = makeFile(filePath, "folder.jpg"); if (doesFileExist(cand)) return cand; cand = makeFile(filePath, "folder.png"); if (doesFileExist(cand)) return cand; cand = makeFile(filePath, "cover.jpg"); if (doesFileExist(cand)) return cand; cand = makeFile(filePath, "cover.png"); if (doesFileExist(cand)) return cand; cand = makeFile(filePath, ".folder.png"); if (doesFileExist(cand)) return cand; cand = makeFile(filePath, ".folder.jpg"); if (doesFileExist(cand)) return cand; return null;//from w ww . ja va2s. c om }
From source file:edu.sdsc.scigraph.services.refine.RefineUtil.java
private static boolean isProbableJSON(String text) { return text.startsWith("[") && text.endsWith("]") || text.startsWith("{") && text.endsWith("}"); }
From source file:Main.java
public static void setResourceAttributeValue(Node node, String resourceType, String attribute, String value) { String currentNodeName = node.getNodeName(); if (currentNodeName.startsWith(resourceType)) { setAttributeValue(node, attribute, value); } else if (currentNodeName.startsWith(RESOURCE_ITEM)) { String typeValue = getAttributeValue(node, ATTRIBUTE_TYPE); if (resourceType.equals(typeValue)) { setAttributeValue(node, attribute, value); }/* ww w . j a va2 s. com*/ } }
From source file:Main.java
static Map<String, Method> getSetPropertyMethods(Class<?> beanClass) { HashMap<String, Method> props; if (setPropsCache.containsKey(beanClass)) { props = setPropsCache.get(beanClass); } else {/*from w w w . j ava 2 s . com*/ props = new HashMap<String, Method>(); setPropsCache.put(beanClass, props); Method[] ms = beanClass.getMethods(); for (int i = 0; i < ms.length; i++) { Method m = ms[i]; String name = m.getName(); if (name.startsWith("set") && name.length() > 3 && Character.isUpperCase(name.charAt(3)) && m.getParameterTypes().length == 1) { name = name.substring(3); props.put(name, m); } } } return props; }