List of usage examples for java.lang String indexOf
public int indexOf(String str)
From source file:Main.java
/** * Convenience method to extract value from {@code @fooAttribute="blagh"} * style filter.//from www .jav a 2 s . c om * * @param filter * @return */ private static String extractFilterValue(String filter) { return filter.substring(filter.indexOf("=\"") + 2, filter.lastIndexOf("\"")); }
From source file:Utils.java
/** * Returns the anchor value of the given URL. * /*from w w w . j a va2 s . co m*/ * @param url * URL * @return anchor value, or null if none was defined */ public static String getAnchor(String url) { if (url != null) { int anchorPosition = url.indexOf(ANCHOR_CHAR); if (anchorPosition >= 0) { return url.substring(anchorPosition + 1); } } return null; }
From source file:Main.java
/** * check if the first String contains the second one. * @param s1 full String//from w w w .ja va 2 s. c om * @param len1 maximum position in String * @param s2 String to search for * @return true if s1 contains s2 in the range 0-len1 */ static boolean wsubstrn(String s1, int len1, String s2) { int searchIndex = s1.indexOf(s2); return searchIndex > -1 && searchIndex <= len1; }
From source file:Main.java
private static String extractEncoding(String hdr) { int i = hdr.indexOf("encoding="); if (i == -1)/*from w ww .j ava 2 s . c o m*/ return null; hdr = hdr.substring(i + 9); char sep = hdr.charAt(0); hdr = hdr.substring(1); i = hdr.indexOf(sep); if (i == -1) return null; return hdr.substring(0, i); }
From source file:Main.java
public static boolean idIsCreateByLocal(String id) { if (id == null) { return false; }/* ww w. j av a 2s .c o m*/ return id.indexOf("tmp_") >= 0; }
From source file:Main.java
/** * @see java.util.regex.Pattern#quote(java.lang.String) *//*from ww w .j a va 2s . c o m*/ public static String quote(String s) { int slashEIndex = s.indexOf("\\E"); if (slashEIndex == -1) return "\\Q" + s + "\\E"; StringBuilder sb = new StringBuilder(s.length() * 2); sb.append("\\Q"); slashEIndex = 0; int current = 0; while ((slashEIndex = s.indexOf("\\E", current)) != -1) { sb.append(s.substring(current, slashEIndex)); current = slashEIndex + 2; sb.append("\\E\\\\E\\Q"); } sb.append(s.substring(current, s.length())); sb.append("\\E"); return sb.toString(); }
From source file:Main.java
/** * Extracts the name of the tag, from string containing the name and * attributes/*from ww w. j av a2 s . com*/ * * @param tagAndAttributes * string containing the name and attributes * @return tag name string separated by space from the tag attributes * @deprecated use TagClass.getName() instead */ public static String getTagName(String tagAndAttributes) { int nameIndex = tagAndAttributes.indexOf(' '); if (nameIndex != -1) { int tabIndex = tagAndAttributes.indexOf('\t'); if (tabIndex > -1 && tabIndex < nameIndex) { return tagAndAttributes.substring(0, tabIndex); } return tagAndAttributes.substring(0, nameIndex); } nameIndex = tagAndAttributes.indexOf('/'); if (nameIndex != -1) { return tagAndAttributes.substring(0, nameIndex); } return tagAndAttributes; }
From source file:Main.java
public static String getSortXMPPName(String jid) { if (jid != null) { return TextUtils.substring(jid, 0, jid.indexOf("@")); }/*from w w w . j a va 2s.c o m*/ return ""; }
From source file:adalid.commons.util.ThrowableUtils.java
private static String getString(String string) { int i = string.indexOf("PSQLException:"); if (i >= 0) { i = string.indexOf("ERROR:", i); if (i >= 0) { int j = string.indexOf("Error Code:", i); if (j >= 0) { return string.substring(i, j); }/*from w ww . jav a 2 s . co m*/ } } return string; }
From source file:Main.java
public static String parseCookie(String raw) { String c = raw;/*from w ww . j av a2 s.co m*/ if (raw != null) { int endIndex = raw.indexOf(";"); if (endIndex >= 0) { c = raw.substring(0, endIndex); } } return c; }