List of usage examples for java.lang String indexOf
public int indexOf(String str)
From source file:Main.java
private static void append(final StringBuilder sb, final char separator, final char escape, final String component) { if ((component.indexOf(separator) < 0) && (component.indexOf(escape) < 0)) { sb.append(component);//from w w w . j a va 2 s.co m } else { for (int j = 0; j < component.length(); j++) { final char c = component.charAt(j); if (c == separator) { sb.append(escape).append(c); } else if (c == escape) { sb.append(c).append(c); } else { sb.append(c); } } } }
From source file:Main.java
private static String stripPrefix(String name) { return name.substring(name.indexOf(":") + 1); }
From source file:Main.java
public static String replaceTimeZero(String date) { if (date != null) { if (date.indexOf("00:00:00") > 0) { date = date.replaceAll("00:00:00", ""); } else if (date.indexOf(":00") == 16) { date = date.substring(0, 16); }/*from ww w. j ava2 s. c o m*/ } return date; }
From source file:Main.java
/** * Returns the stylename in a style of the form stylename[;key=value] or an * empty string if the given style does not contain a stylename. * /*from w w w .j ava 2 s. c o m*/ * @param style * String of the form stylename[;key=value]. * @return Returns the stylename from the given formatted string. */ public static String getStylename(String style) { if (style != null) { String[] pairs = style.split(";"); String stylename = pairs[0]; if (stylename.indexOf("=") < 0) { return stylename; } } return ""; }
From source file:Main.java
public static boolean isTagUid(final String uid) { return uid.startsWith("user/") && (uid.indexOf("/state/") != -1 || uid.indexOf("/label/") != -1); }
From source file:Main.java
public static String getOnlyFileName(String name) { String retStr = name;//w w w .jav a 2s . co m if (name.indexOf("/") >= 0) { retStr = name.substring(name.lastIndexOf("/") + 1); } else if (name.indexOf("\\") >= 0) { retStr = name.substring(name.lastIndexOf("\\") + 1); } return retStr; }
From source file:Main.java
/** * Extracts category and categoryValue from the mediaID. mediaID is, by this sample's * convention, a concatenation of category (eg "by_genre"), categoryValue (eg "Classical") and * mediaID. This is necessary so we know where the user selected the music from, when the music * exists in more than one music list, and thus we are able to correctly build the playing queue. * * @param mediaID that contains a category and categoryValue. *//*from ww w . j a v a2 s.c o m*/ public static @NonNull String[] getHierarchy(String mediaID) { int pos = mediaID.indexOf(LEAF_SEPARATOR); if (pos >= 0) { mediaID = mediaID.substring(0, pos); } return mediaID.split(String.valueOf(CATEGORY_SEPARATOR)); }
From source file:Main.java
public final static Map<String, String> queryToMap(String post) { Map<String, String> ret = new HashMap<String, String>(); if (post == null) { return ret; }/*from w ww. j a v a 2 s . c o m*/ String[] fields = post.split("\\&"); for (int i = 0; i < fields.length; i++) { String kv = fields[i]; int idx = kv.indexOf('='); if (idx > 0) { ret.put(kv.substring(0, idx), kv.substring(idx + 1)); } } return ret; }
From source file:Main.java
public static Element[] getAncestors(Element parent, String name) { int i = name.indexOf('.'); if (i < 0) { return getChildren(parent, name); }//from ww w . ja va 2s. co m Element p = getUniqueChild(parent, name.substring(0, i)); return (p == null) ? new Element[0] : getAncestors(p, name.substring(i + 1)); }
From source file:Main.java
/** * Strip out mime type parameters if they are present * // w w w.jav a 2 s. c om * @param mimeType Mime type e.g. application/atom+xml;profile=opds * @return Mime type without any params e.g. application/atom+xml */ public static String stripMimeParams(String mimeType) { int i = mimeType.indexOf(';'); return i != -1 ? mimeType.substring(0, i).trim() : mimeType; }