List of usage examples for java.lang String charAt
public char charAt(int index)
From source file:com.cognifide.qa.bb.aem.touch.util.DataPathUtil.java
/** * Method normalizes data path. Checks if last character of path is digit, if yes, then returns substring * before last {@code _} occurrence.//from w w w. ja v a 2 s . co m * Example: for given in parameter string '/title_1234' method will return '/title' * * @param dataPath data path. * @return normalized data path. */ public static String normalize(String dataPath) { return Character.isDigit(dataPath.charAt(dataPath.length() - 1)) ? StringUtils.substringBeforeLast(dataPath, "_") : dataPath; }
From source file:Main.java
public static boolean isZero(String id) { for (int i = 0; i < id.length(); i++) { char index = id.charAt(i); if (index != '0') return false; }//from w w w .j a v a 2s . c o m return true; }
From source file:Main.java
/** * Check if the expected character exist at the given offset in the value. * //from w ww .j a va2 s . c om * @param value the string to check at the specified offset * @param offset the offset to look for the expected character * @param expected the expected character * @return true if the expected character exist at the given offset */ private static boolean checkOffset(String value, int offset, char expected) { return (offset < value.length()) && (value.charAt(offset) == expected); }
From source file:Main.java
private static int findTypeEnd(@Nonnull String str, int index) { char c = str.charAt(index); switch (c) {// www . ja v a2 s.co m case 'Z': case 'B': case 'S': case 'C': case 'I': case 'J': case 'F': case 'D': return index + 1; case 'L': while (str.charAt(index++) != ';') { } return index; case '[': while (str.charAt(index++) != '[') { } return findTypeEnd(str, index); default: throw new IllegalArgumentException(String.format("Param string \"%s\" contains invalid type prefix: %s", str, Character.toString(c))); } }
From source file:Main.java
public static boolean is_hex_char(String str) { for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'))) { return false; }/*from w ww . java 2 s.co m*/ } return true; }
From source file:Main.java
public static String getBaseName(String name, boolean bracketed) { String result = name; if (bracketed) { if (result.charAt(result.length() - 1) != ')') return name; result = result.substring(0, result.length() - 1); }/*from w w w .j a v a 2 s. co m*/ while (Character.isDigit(result.charAt(result.length() - 1))) result = result.substring(0, result.length() - 1); if (bracketed) { if (!result.substring(result.length() - 2).equals(" (")) //$NON-NLS-1$ return name; result = result.substring(0, result.length() - 2); } return result; }
From source file:Main.java
/** * Decode a base64 string into a long value. *///from w w w . ja va 2 s . c om public static long longFromBase64(String value) { int pos = 0; long longVal = base64Values[value.charAt(pos++)]; int len = value.length(); while (pos < len) { longVal <<= 6; longVal |= base64Values[value.charAt(pos++)]; } return longVal; }
From source file:Main.java
/** * Convert a Cygwin based path to Windows format e.g. /cygdrive/c/file.txt * to C:\\file.txt//from w w w.j av a 2s .co m * @param cygPath Cygwin based path * @return Windows path */ public static String toWindowsPath(String cygPath) { StringBuilder sb = new StringBuilder(); sb.append(cygPath.charAt(10)).append(":\\"); if (cygPath.length() > 12) { sb.append(cygPath.substring(12)); } return sb.toString(); }
From source file:Main.java
/** * Generate capitalized string/* ww w . j a v a 2 s. co m*/ * * @param line string to be capitalized * @return capitalized string */ private static String capitalize(final String line) { return Character.toUpperCase(line.charAt(0)) + line.substring(1); }
From source file:FastParser.java
/** * Parse the int at index from value. The int is assumed to run until * the end of the String.//from w ww.j av a2s . c o m */ public static int parseInt(String value, int index) { char c = value.charAt(index++); int ans; if (c == '-') ans = -(value.charAt(index++) - '0'); else ans = c - '0'; int n = value.length(); for (; index < n;) { ans = ans * 10 + (value.charAt(index++) - '0'); } return ans; }