List of usage examples for java.lang String indexOf
public int indexOf(String str)
From source file:Main.java
static public String stripTopLevelTag(String xmlString) { return xmlString.substring(xmlString.indexOf('>') + 1, xmlString.lastIndexOf('<')); }
From source file:Main.java
/** * Check if a character is allowed in a filename (if it is a valid input) * * @param currentChar the entered char// w w w . j a v a 2s . co m * @return if it is allowed or not to be used in a filename */ private static boolean isFileCharAllowed(char currentChar) { boolean isCharAllowed = false; String reservedChars = "?:\"*|/\\<>"; if (reservedChars.indexOf(currentChar) == -1) { isCharAllowed = true; } return isCharAllowed; }
From source file:Main.java
public static Map<String, String> parserAliPartner(String result) { String[] array = result.split("&"); Map<String, String> map = new HashMap<String, String>(); for (String s : array) { int index = s.indexOf("="); String key = s.substring(0, index); String value = ""; if (!s.substring(index + 1).equals("''")) { value = s.substring(index + 2, s.length() - 1); }/*w ww. j ava 2s . c o m*/ map.put(key, value); } return map; }
From source file:Main.java
public static Map<String, String> parserAliResult(String result) { String[] array = result.split(";"); Map<String, String> map = new HashMap<String, String>(); for (String s : array) { int index = s.indexOf("="); String key = s.substring(0, index); String value = ""; if (!s.substring(index + 1).equals("{}")) { value = s.substring(index + 2, s.length() - 1); }//from w w w . j ava2s . c o m map.put(key, value); } return map; }
From source file:Main.java
/** * Extracts unique musicID from the mediaID. mediaID is, by this sample's convention, a * concatenation of category (eg "by_genre"), categoryValue (eg "Classical") and unique * musicID. 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 the musicID * @return musicID/* w w w.j av a2s. c o m*/ */ public static String extractMusicIDFromMediaID(String mediaID) { int pos = mediaID.indexOf(LEAF_SEPARATOR); if (pos >= 0) { return mediaID.substring(pos + 1); } return null; }
From source file:Main.java
/** * text of a leaf node, without child element * //from w w w . j a v a2 s . com * @param tag * @return String */ public static String getNodeText(Element tag) { String text = tag.toString(); int i = text.indexOf(">"); //$NON-NLS-1$ int j = text.lastIndexOf("</"); //$NON-NLS-1$ if (i < 0 || j < 0 || j < i) { return ""; //$NON-NLS-1$ } return text.substring(i + 1, j); }
From source file:Main.java
/** * Returns a UID in the format of {1}:{2}, where {1} is {@link #SYSTEM_NAMESPACE} and {2} is the * given typeId stripped of the prefix {@link #SYSTEM_NAMESPACE_PREFIX} if it exists. * * @param typeId/*from w w w . j a va 2 s . co m*/ * @return system uid (e.g. "system:test") */ public static String getSystemUID(String typeId) { int prefixIdx = typeId.indexOf(SYSTEM_NAMESPACE_PREFIX); if (prefixIdx != -1) { typeId = typeId.substring(prefixIdx + SYSTEM_NAMESPACE_PREFIX.length()); } return String.format("%s:%s", SYSTEM_NAMESPACE, typeId); }
From source file:Main.java
public static boolean isUserTagUid(final String uid) { return uid.startsWith("user/") && uid.indexOf("/label/") != -1; }
From source file:Main.java
public static String getSubString(String str, String string) { return str.substring(str.indexOf(string)); }
From source file:Main.java
/** * Returns a literal replacement <code>String</code> for the specified * <code>String</code>.//from w w w . ja va 2s . c om * @param s * @return */ private static String quote(String s) { if ((s.indexOf('\\') == -1) && (s.indexOf('$') == -1)) return s; StringBuffer sb = new StringBuffer(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c == '\\') { sb.append('\\'); sb.append('\\'); } else if (c == '$') { sb.append('\\'); sb.append('$'); } else { sb.append(c); } } return sb.toString(); }