List of usage examples for java.lang String indexOf
public int indexOf(String str)
From source file:Main.java
public static Map split(List list, String separator) { if (list == null) return null; Map map = new HashMap(); if (list == null || list.size() == 0) return map; for (Iterator i$ = list.iterator(); i$.hasNext();) { String item = (String) i$.next(); int index = item.indexOf(separator); if (index == -1) map.put(item, ""); else/*from w w w.ja va2s .c om*/ map.put(item.substring(0, index), item.substring(index + 1)); } return map; }
From source file:Main.java
public static void putNemonicKey(AbstractButton button, char mnemonicKey) { String text = button.getText(); if (text.indexOf(mnemonicKey) >= 0) { button.setText(getLabelName(text, mnemonicKey, false)); }//from ww w.j a v a2 s . c o m button.setMnemonic(mnemonicKey); }
From source file:Main.java
/** * Strips XML declaration from the string. * * @param string XML string/*from w w w. jav a2s .com*/ * * @return XML string without XML declaration */ public static String stripDeclaration(final String string) { final int pos = string.indexOf("?>"); if (pos == -1) { return string; } else { return string.substring(pos + 2).trim(); } }
From source file:Main.java
public static String trimXml(String xml) { int start = 0, end = 0; start = xml.indexOf("<"); if (start < 0) { return ""; }/* www .ja v a2 s .com*/ end = xml.lastIndexOf(">"); if (end < 0) { return ""; } return xml.substring(start, ++end); }
From source file:Main.java
/** * return offset of cc from beginning of s1, -1 if not found. * @param s1 String//w w w . j av a 2 s. c o m * @param len1 maximum offset (values > than lenl are ignored and returned as -1) * @param cc character to search for * @return index of cc in s1 */ static int wstrnchr(String s1, int len1, char cc) { int indexOf = s1.indexOf(cc); if (indexOf < len1) { return indexOf; } return -1; }
From source file:Main.java
public static Element createElement(Element parent, String path) { int i = path.indexOf('.'); if (i < 0) { Element element = parent.getOwnerDocument().createElement(path); parent.appendChild(element);/*from w w w . ja v a 2s . c om*/ return element; } String p = path.substring(0, i), c = path.substring(i + 1); Element pe = getUniqueChild(parent, p); if (pe == null) { pe = parent.getOwnerDocument().createElement(p); parent.appendChild(pe); } return createElement(pe, c); }
From source file:Main.java
public static Element createElement(Element parent, String path) { int i = path.indexOf('.'); Element element = null;/*w ww . j a v a2s .co m*/ if (i < 0) { element = parent.getOwnerDocument().createElement(path); parent.appendChild(element); } else { String p = path.substring(0, i), c = path.substring(i + 1); Element pe = getUniqueChild(parent, p); if (pe == null) { pe = parent.getOwnerDocument().createElement(p); parent.appendChild(pe); } element = createElement(pe, c); } return element; }
From source file:Main.java
private static String[] filter(String[] p_array, boolean p_includeComments) { String[] result = p_array;/* w w w. j av a2 s . c o m*/ if (!p_includeComments) { Vector v = new Vector(); for (int i = 0; i < p_array.length; i++) { String s = p_array[i]; if (s.indexOf("<!--") < 0) { v.addElement(s); } } result = new String[v.size()]; for (int i = 0; i < v.size(); i++) { result[i] = (String) v.elementAt(i); } } return result; }
From source file:Main.java
public static String removeHttpSuffix(String imgUrl) { if (imgUrl.contains("?")) { int tempIndex = imgUrl.indexOf("?"); return imgUrl.substring(0, tempIndex + 1); }/* ww w .j av a 2 s . c om*/ return imgUrl; }
From source file:Main.java
public static Bundle urlToBundle(String url) { int index = url.indexOf("://"); if (index >= 0) { url = "http://" + url.substring(index + 1); } else {/* w w w. j a va 2 s . c o m*/ url = "http://" + url; } try { URL e = new URL(url); Bundle b = decodeUrl(e.getQuery()); b.putAll(decodeUrl(e.getRef())); return b; } catch (Throwable var4) { return new Bundle(); } }