List of usage examples for java.lang Character isLetter
public static boolean isLetter(int codePoint)
From source file:org.exoplatform.calendar.ws.CalendarRestApi.java
private boolean containSpecialChar(String value) { for (int i = 0; i < value.length(); i++) { char c = value.charAt(i); if (Character.isLetter(c) || Character.isDigit(c) || c == '_' || c == '-' || Character.isSpaceChar(c)) { continue; }//w w w. j a va 2 s .c o m return true; } return false; }
From source file:ths.commons.util.StringUtils.java
/** * <p>Checks if the CharSequence contains only Unicode letters and * space (' ').</p>// ww w . j a v a 2 s . co m * * <p>{@code null} will return {@code false} * An empty CharSequence (length()=0) will return {@code true}.</p> * * <pre> * StringUtils.isAlphaSpace(null) = false * StringUtils.isAlphaSpace("") = true * StringUtils.isAlphaSpace(" ") = true * StringUtils.isAlphaSpace("abc") = true * StringUtils.isAlphaSpace("ab c") = true * StringUtils.isAlphaSpace("ab2c") = false * StringUtils.isAlphaSpace("ab-c") = false * </pre> * * @param cs the CharSequence to check, may be null * @return {@code true} if only contains letters and space, * and is non-null * @since 3.0 Changed signature from isAlphaSpace(String) to isAlphaSpace(CharSequence) */ public static boolean isAlphaSpace(CharSequence cs) { if (cs == null) { return false; } int sz = cs.length(); for (int i = 0; i < sz; i++) { if ((Character.isLetter(cs.charAt(i)) == false) && (cs.charAt(i) != ' ')) { return false; } } return true; }
From source file:com.quinsoft.zeidon.vml.VmlOperation.java
/** * This should really be named "UfObfuscateString" because it doesn't encrypt the string, * just makes it harder to read it in an .ini file. */* w w w. j av a 2 s. c o m*/ * Logic copied directly from kzoeufaa.c * * @param sbEncryptedString * @param originalString * @param length */ public static final int UfEncryptString(StringBuilder sbEncryptedString, String originalString, int length) { sbEncryptedString.setLength(0); // Use sb.setLength( 0 ); to clear a string buffer. int uLth = originalString.length(); // if ( uLth > 26 ) // uLth = 26; char[] pchOut = new char[uLth + 1]; char[] pchIn = originalString.toCharArray(); char uChar = 0; int nOrderIdx = 0; boolean bNullFound = false; pchOut[uLth] = 0; while (Encrypt2[nOrderIdx] > (uLth - 1)) { nOrderIdx++; } int nInLth = pchIn.length; while (nInLth > uLth || nInLth > 25) { nInLth -= uLth; } char cChar = 0; pchOut[Encrypt2[nOrderIdx]] = Encrypt1[nInLth]; nOrderIdx++; while (uChar < (uLth - 1)) { while (Encrypt2[nOrderIdx] > (uLth - 1)) { nOrderIdx++; } if (!bNullFound && pchIn[uChar] > 0) { cChar = pchIn[uChar]; if (Character.isLetter(cChar)) { while (cChar >= 'a') { cChar -= ' '; } while (cChar < 'A') { cChar += 11; } cChar -= 'A'; if (uChar % 2 > 0) { pchOut[Encrypt2[nOrderIdx]] = Encrypt1[cChar]; } else { pchOut[Encrypt2[nOrderIdx]] = Encrypt2[cChar]; } } else { pchOut[Encrypt2[nOrderIdx]] = (char) (EncryptNonAlpha[cChar] - 'a'); } } else { cChar += 17; if (cChar > 25) { cChar -= 25; } bNullFound = true; if (uChar % 2 > 0) { pchOut[Encrypt2[nOrderIdx]] = Encrypt2[cChar]; } else { pchOut[Encrypt2[nOrderIdx]] = Encrypt1[cChar]; } } uChar++; nOrderIdx++; } for (uChar = 0; uChar < uLth; uChar++) { pchOut[uChar] += 'a'; } sbEncryptedString.append(pchOut); return sbEncryptedString.length(); }
From source file:com.sjdf.platform.xss.StringUtils.java
/** * <p>/*from w ww. ja v a 2s . com*/ * Checks if the CharSequence contains only Unicode letters. * </p> * <p/> * <p> * {@code null} will return {@code false}. An empty CharSequence * (length()=0) will return {@code false}. * </p> * <p/> * <pre> * StringUtils.isAlpha(null) = false * StringUtils.isAlpha("") = false * StringUtils.isAlpha(" ") = false * StringUtils.isAlpha("abc") = true * StringUtils.isAlpha("ab2c") = false * StringUtils.isAlpha("ab-c") = false * </pre> * * @param cs the CharSequence to check, may be null * @return {@code true} if only contains letters, and is non-null * @since 3.0 Changed "" to return false and not true */ public static boolean isAlpha(CharSequence cs) { if (cs == null || cs.length() == 0) { return false; } int sz = cs.length(); for (int i = 0; i < sz; i++) { if (!Character.isLetter(cs.charAt(i))) { return false; } } return true; }
From source file:com.quinsoft.zeidon.vml.VmlOperation.java
public static final int UfDecryptString(StringBuilder sbDecryptedString, String original, int length) { sbDecryptedString.setLength(0); // Use sb.setLength( 0 ); to clear a string buffer. if (original.length() == 0) { return (0); }/*from w w w. j a v a 2s . c o m*/ int uLth = original.length(); // if ( uLth > 26 ) // uLth = 26; char[] pchIn = original.toCharArray(); char[] pchOut = new char[length + 1]; char uChar = 0; int nOrderIdx = 0; while (Encrypt2[nOrderIdx] > (uLth - 1)) { nOrderIdx++; } int cReturnLth = pchIn[Encrypt2[nOrderIdx]] - 'a'; int nReturnLth = 0; while (Encrypt1[nReturnLth] != cReturnLth) { nReturnLth++; } cReturnLth = nReturnLth; nOrderIdx++; while (cReturnLth > 0) { while (Encrypt2[nOrderIdx] > (uLth - 1)) { nOrderIdx++; } char ucChar = pchIn[Encrypt2[nOrderIdx]]; if (Character.isLetter(ucChar)) { ucChar -= 'a'; if (uChar % 2 > 0) { int cWk = 0; while (Encrypt1[cWk] != ucChar) { cWk++; } pchOut[uChar] = (char) (cWk + 'a'); } else { int cWk = 0; while (Encrypt2[cWk] != ucChar) { cWk++; } pchOut[uChar] = (char) (cWk + 'a'); } } else { int nIdx; // Look for the encrypted char in the non-alpha table. for (nIdx = 32; nIdx < 127; nIdx++) { if (EncryptNonAlpha[nIdx] == ucChar) { break; } } if (nIdx == 127) { SysMessageBox(null, "Zeidon Internal Error", "Error decrypting string", 0); return (zCALL_ERROR); } pchOut[uChar] = (char) nIdx; } cReturnLth--; uChar++; nOrderIdx++; } pchOut[uChar] = 0; sbDecryptedString.setLength(0); // Use sb.setLength( 0 ); to clear a string buffer. sbDecryptedString.append(pchOut); return (nReturnLth); }
From source file:org.apache.commons.lang3.StringUtils.java
/** * <p>Checks if the CharSequence contains only Unicode letters.</p> * * <p>{@code null} will return {@code false}. * An empty CharSequence (length()=0) will return {@code false}.</p> * * <pre>/*w ww .j a v a2s . c om*/ * StringUtils.isAlpha(null) = false * StringUtils.isAlpha("") = false * StringUtils.isAlpha(" ") = false * StringUtils.isAlpha("abc") = true * StringUtils.isAlpha("ab2c") = false * StringUtils.isAlpha("ab-c") = false * </pre> * * @param cs the CharSequence to check, may be null * @return {@code true} if only contains letters, and is non-null * @since 3.0 Changed signature from isAlpha(String) to isAlpha(CharSequence) * @since 3.0 Changed "" to return false and not true */ public static boolean isAlpha(CharSequence cs) { if (cs == null || cs.length() == 0) { return false; } int sz = cs.length(); for (int i = 0; i < sz; i++) { if (Character.isLetter(cs.charAt(i)) == false) { return false; } } return true; }
From source file:com.sjdf.platform.xss.StringUtils.java
/** * <p>//from w ww.jav a 2s . co m * Checks if the CharSequence contains only Unicode letters and space (' '). * </p> * <p/> * <p> * {@code null} will return {@code false} An empty CharSequence (length()=0) * will return {@code true}. * </p> * <p/> * <pre> * StringUtils.isAlphaSpace(null) = false * StringUtils.isAlphaSpace("") = true * StringUtils.isAlphaSpace(" ") = true * StringUtils.isAlphaSpace("abc") = true * StringUtils.isAlphaSpace("ab c") = true * StringUtils.isAlphaSpace("ab2c") = false * StringUtils.isAlphaSpace("ab-c") = false * </pre> * * @param cs the CharSequence to check, may be null * @return {@code true} if only contains letters and space, and is non-null * @since 3.0 Changed signature from isAlphaSpace(String) to * isAlphaSpace(CharSequence) */ public static boolean isAlphaSpace(CharSequence cs) { if (cs == null) { return false; } int sz = cs.length(); for (int i = 0; i < sz; i++) { if (!Character.isLetter(cs.charAt(i)) && cs.charAt(i) != ' ') { return false; } } return true; }
From source file:org.apache.commons.lang3.StringUtils.java
/** * <p>Checks if the CharSequence contains only Unicode letters and * space (' ').</p>//from w ww.j ava 2s .c om * * <p>{@code null} will return {@code false} * An empty CharSequence (length()=0) will return {@code true}.</p> * * <pre> * StringUtils.isAlphaSpace(null) = false * StringUtils.isAlphaSpace("") = true * StringUtils.isAlphaSpace(" ") = true * StringUtils.isAlphaSpace("abc") = true * StringUtils.isAlphaSpace("ab c") = true * StringUtils.isAlphaSpace("ab2c") = false * StringUtils.isAlphaSpace("ab-c") = false * </pre> * * @param cs the CharSequence to check, may be null * @return {@code true} if only contains letters and space, * and is non-null * @since 3.0 Changed signature from isAlphaSpace(String) to isAlphaSpace(CharSequence) */ public static boolean isAlphaSpace(CharSequence cs) { if (cs == null) { return false; } int sz = cs.length(); for (int i = 0; i < sz; i++) { if (Character.isLetter(cs.charAt(i)) == false && cs.charAt(i) != ' ') { return false; } } return true; }
From source file:com.cohort.util.String2.java
/** * This converts "camelCase99String" to "Camel Case 99 String" * /*from w ww . j ava 2 s . c om*/ * @param s the camel case string. * @return the string with spaces before capital letters. * null returns null. * "" returns "". */ public static String camelCaseToTitleCase(String s) { //change // but don't space out an acronym, e.g., E T O P O // and don't split hyphenated words, e.g., Real-Time if (s == null) return null; int n = s.length(); if (n <= 1) return s; StringBuilder sb = new StringBuilder(n + 10); sb.append(Character.toUpperCase(s.charAt(0))); for (int i = 1; i < n; i++) { char chi1 = s.charAt(i - 1); char chi = s.charAt(i); if (Character.isLetter(chi)) { if (chi1 == Character.toLowerCase(chi1) && Character.isLetterOrDigit(chi1) && chi != Character.toLowerCase(chi)) sb.append(' '); } else if (Character.isDigit(chi)) { if (chi1 == Character.toLowerCase(chi1) && Character.isLetter(chi1)) sb.append(' '); } sb.append(chi); } return sb.toString(); }
From source file:com.clark.func.Functions.java
/** * <p>/*from w w w . ja v a2 s . c o m*/ * Checks if the CharSequence contains only unicode letters. * </p> * * <p> * <code>null</code> will return <code>false</code>. An empty CharSequence * (length()=0) will return <code>true</code>. * </p> * * <pre> * isAlpha(null) = false * isAlpha("") = true * isAlpha(" ") = false * isAlpha("abc") = true * isAlpha("ab2c") = false * isAlpha("ab-c") = false * </pre> * * @param cs * the CharSequence to check, may be null * @return <code>true</code> if only contains letters, and is non-null * @since 3.0 Changed signature from isAlpha(String) to * isAlpha(CharSequence) */ public static boolean isAlpha(CharSequence cs) { if (cs == null) { return false; } int sz = cs.length(); for (int i = 0; i < sz; i++) { if (Character.isLetter(cs.charAt(i)) == false) { return false; } } return true; }