List of usage examples for java.lang String charAt
public char charAt(int index)
From source file:FastParser.java
/** * Parse the long at index from value. The long is assumed to run until * the end of the String./*from w w w .j a va2 s .co m*/ */ public static long parseLong(String value, int index) { char c = value.charAt(index++); long 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; }
From source file:Main.java
public static char getCharForMorse(String morse) { String out = morseToCharTable.get(morse); if (out != null) { return out.charAt(0); } else {/*from w w w .j av a 2s . c o m*/ return '?'; } }
From source file:Main.java
public static boolean checkIfClassHasMatchingGetMethod(Class<?> clazz, String columnname) { String neededMethodename = "get" + (Character.toUpperCase(columnname.charAt(0)) + columnname.substring(1)); for (Method aMethod : clazz.getMethods()) { if (neededMethodename.equals(aMethod.getName())) { return true; }//from w w w .j a v a 2 s . com } return false; }
From source file:Main.java
public static int prefixCodedToInt(final String prefixCoded) { final int shift = prefixCoded.charAt(0) - SHIFT_START_INT; if (shift > 31 || shift < 0) throw new NumberFormatException( "Invalid shift value in prefixCoded string (is encoded value really an INT?)"); int sortableBits = 0; for (int i = 1, len = prefixCoded.length(); i < len; i++) { sortableBits <<= 7;/*ww w . j a v a 2s. c om*/ final char ch = prefixCoded.charAt(i); if (ch > 0x7f) { throw new NumberFormatException("Invalid prefixCoded numerical value representation (char " + Integer.toHexString(ch) + " at position " + i + " is invalid)"); } sortableBits |= ch; } return (sortableBits << shift) ^ 0x80000000; }
From source file:Main.java
public static String removeNullCharAtEnd(String st) { int index = st.length() - 1; char c = st.charAt(index); if (c == '\u0000') { return st.substring(0, index); }/*from w w w. ja v a2s.co m*/ return st; }
From source file:Main.java
private static String toIdName(String fieldName) { String idName = String.valueOf(Character.toLowerCase(fieldName.charAt(1))); for (int i = 2, length = fieldName.length(); i < length; ++i) { char c = fieldName.charAt(i); if (Character.isUpperCase(c)) { idName = idName + ID_SEPARATOR + Character.toLowerCase(c); } else {/*from w w w . j a v a 2 s . c o m*/ idName += c; } } return idName; }
From source file:Main.java
public static String createNewPrivateFolder(String folderName) { String folderPathString = getSDPath() + mPrivatePath + folderName; if (folderPathString.charAt(folderPathString.length() - 1) != '/') { folderPathString += '/'; }//from w ww. ja v a 2 s . com File path = new File(folderPathString); if (!path.exists()) { path.mkdir(); } return folderPathString; }
From source file:Main.java
/** * test for numbers in a given string//from w ww . ja va 2 s . c o m * * @param String text - text for searching * @return boolean - true: text contains numbers, false: text not contains numbers */ public static boolean containsNumbers(String text) { for (int i = 0; i < text.length(); i++) { if (((int) text.charAt(i) >= 48) && ((int) text.charAt(i) <= 57)) { return true; } } return false; }
From source file:Main.java
private static int getStartIndex(String term) { int length = term.length(); int index = 0; while (term.charAt(index) == '*') { ++index;//from w w w.j a v a 2 s. c o m if (index >= length) { break; } } return index; }
From source file:Main.java
public static boolean onlyContainsWhitespace(String src) { for (int i = 0; i < src.length(); i++) { final char c = src.charAt(i); if (WHITESPACE.indexOf(c) == -1) { //found a character which isn't whitespace return false; }/*from w w w .j av a 2 s. c om*/ } return true; }