List of usage examples for java.lang String indexOf
public int indexOf(String str)
From source file:Main.java
/** * This method converts a given XML attribute or element name to a local representation by stripping it of its * namespace prefix.//from www. j a v a 2 s. c o m * * @param xml * the xml * @return String */ public static String getLocalPart(String xml) { final int pos; if ((pos = xml.indexOf(":")) >= 0) { xml = xml.substring(pos + 1); } return xml; }
From source file:Main.java
/** * When using text as tooltip, table cell, tree cell then newline characters are ignored <b>unless</b> * the text is encapsulated in <html>...</html> * <p>// ww w . ja v a 2 s. c o m * This helper checks the string for newline characters \n and \r */ public static boolean isMultilineLabelText(String s) { if (s != null) { if (s.indexOf('\n') >= 0 || s.indexOf('\r') >= 0) { return true; } } return false; }
From source file:Main.java
private static List getMainProcessNames(List list) { ArrayList arraylist = new ArrayList(); Iterator iterator = list.iterator(); do {//from www . j a v a 2 s .c om if (!iterator.hasNext()) break; String s = (String) iterator.next(); int i = s.indexOf(":"); if (i > 0) arraylist.add(s.substring(0, i)); } while (true); return arraylist; }
From source file:Main.java
public static String findPreamble(final String xml) { final int indexStart = xml.indexOf(PREAMBLE_START); // make sure we found the encoding attribute if (indexStart != -1) { final int indexEnd = xml.indexOf(PREAMBLE_END, indexStart + PREAMBLE_START.length()); // make sure we found the end of the attribute if (indexEnd != -1) { return xml.substring(indexStart, indexEnd + PREAMBLE_END.length()); }/*from w w w .j ava2 s . co m*/ } return null; }
From source file:Main.java
public static String findDocumentType(final String xml) { final int indexStart = xml.indexOf(DOCTYPE_START); // make sure we found the encoding attribute if (indexStart != -1) { final int indexEnd = xml.indexOf(DOCTYPE_END, indexStart + DOCTYPE_START.length()); // make sure we found the end of the attribute if (indexEnd != -1) { return xml.substring(indexStart, indexEnd + DOCTYPE_END.length()); }/*w w w . j a va 2 s .com*/ } return null; }
From source file:Utils.java
/** * @param hostStr/* ww w . j ava 2 s .c o m*/ * @param defaultPort * @return */ static public int parsePort(String hostStr, int defaultPort) { int sepIdx = hostStr.indexOf(':'); if (sepIdx < 0) { return defaultPort; } else { String portStr = hostStr.substring(sepIdx + 1).trim(); try { return Integer.parseInt(portStr); } catch (NumberFormatException e) { return defaultPort; } } }
From source file:Main.java
public static String normalizePI(String contents) { if (contents == null || contents.indexOf("?>") >= 0) return null; int i = 0, len = contents.length(); for (; i < len; i++) if (!Character.isWhitespace(contents.charAt(i))) break; return (i == 0) ? contents : contents.substring(i); }
From source file:Main.java
public static Map<String, String> splitQuery(String query) { Map<String, String> query_pairs = new LinkedHashMap<String, String>(); try {//from w ww . ja v a2 s . c o m String[] pairs = query.split("&"); for (String pair : pairs) { int idx = pair.indexOf("="); query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8")); } } catch (UnsupportedEncodingException e) { query_pairs.put("error", "UnsupportedEncodingException"); query_pairs.put("error_description", e.getMessage()); } return query_pairs; }
From source file:ReflectionUtil.java
private static String getPackageName(String clzName) { if (clzName.indexOf("/") == -1) { return null; }//w w w.jav a 2 s. co m String packageName = clzName.substring(0, clzName.lastIndexOf("/")); return packageName.replace("/", "."); }
From source file:Main.java
public static String getBasUrl(String url) { String head = ""; int index = url.indexOf("://"); if (index != -1) { head = url.substring(0, index + 3); url = url.substring(index + 3);/* ww w. jav a2s . co m*/ } index = url.indexOf("/"); if (index != -1) { url = url.substring(0, index + 1); } return head + url; }