List of usage examples for java.lang String startsWith
public boolean startsWith(String prefix)
From source file:com.meltmedia.dropwizard.etcd.junit.EtcdJsonRule.java
private static String ensureLeadingSlash(String directory) { return directory.startsWith("/") ? directory : "/" + directory; }
From source file:com.ery.estorm.zk.ZKAssign.java
/** * @param zkw/* ww w.j a v a 2s . c o m*/ * @param pathOrRegionName * @return Path to znode */ public static String getPath(final ZooKeeperWatcher zkw, final String pathOrRegionName) { return pathOrRegionName.startsWith("/") ? pathOrRegionName : getNodeName(zkw, pathOrRegionName); }
From source file:Main.java
public static boolean checkTelephone(String telephone) { if (TextUtils.isEmpty(telephone)) { return false; } else if ((telephone.startsWith("86") && telephone.length() == 13) || (!telephone.startsWith("86") && telephone.length() == 11)) { return true; }/*from w w w .j a v a 2 s. c o m*/ return false; }
From source file:Main.java
public static boolean startsWithFilePath(ArrayList<String> filePaths, String filePath) { String lowerCaseFilePath = filePath.toLowerCase(); for (String onePath : filePaths) { if (lowerCaseFilePath.startsWith(onePath.toLowerCase())) { return true; }//from w w w.j a va2s. co m } return false; }
From source file:Main.java
/** * Helper method used to weed out dynamic Proxy types; types that do * not expose concrete method API that we could use to figure out * automatic Bean (property) based serialization. *//*from w w w .ja v a 2 s . com*/ public static boolean isProxyType(Class<?> type) { // As per [Issue#57], should NOT disqualify JDK proxy: /* // Then: well-known proxy (etc) classes if (Proxy.isProxyClass(type)) { return true; } */ String name = type.getName(); // Hibernate uses proxies heavily as well: if (name.startsWith("net.sf.cglib.proxy.") || name.startsWith("org.hibernate.proxy.")) { return true; } // Not one of known proxies, nope: return false; }
From source file:Main.java
static InetAddress parseLinuxSubnetMask(String line) throws UnknownHostException { int e = line.indexOf("broadcast"); if (e == -1)/*from ww w .j a va 2 s.c om*/ return null; e--; String v = line.substring(line.indexOf("netmask") + 8, e); if (v.startsWith("0x")) { try { long address = Long.parseLong(v.substring(2), 16); return InetAddress.getByAddress(new byte[] { (byte) (address >> 24), (byte) ((address >> 16) & 0xff), (byte) ((address >> 8) & 0xff), (byte) (address & 0xff) }); } catch (NumberFormatException e2) { } } else { return InetAddress.getByName(v); } return null; }
From source file:de.tudarmstadt.ukp.dkpro.keyphrases.bookindexing.evaluation.phrasematch.TokenReader.java
private static String normalizeSuffix(String suffix) { return suffix.startsWith(".") ? suffix : "." + suffix; }
From source file:Main.java
/** * * @param jsonStr string param .expect a json string * @return formatted json string if param is a json string,otherwise return the param *///from w ww. jav a 2 s. com public static String convert(String jsonStr) { try { jsonStr = jsonStr.trim(); if (jsonStr.startsWith("{")) { JSONObject jsonObject = new JSONObject(jsonStr); return jsonObject.toString(JSON_INDENT); } if (jsonStr.startsWith("[")) { JSONArray jsonArray = new JSONArray(jsonStr); return jsonArray.toString(JSON_INDENT); } } catch (JSONException e) { e.printStackTrace(); } return jsonStr; }
From source file:Main.java
private static String addThreadInfo(final String msg) { final String threadName = Thread.currentThread().getName(); final String shortName = threadName.startsWith("OkHttp") ? "OkHttp" : threadName; return "[" + shortName + "] " + msg; }