List of usage examples for java.lang Character isLowerCase
public static boolean isLowerCase(int codePoint)
From source file:org.modelibra.util.TextHandler.java
boolean isQualifiedClassName(String string) { String quote = Pattern.quote("."); String[] strings = string.split(quote); if (strings.length == 0) { return false; }/*from ww w. ja va 2s .c o m*/ int i = 0; for (; i < strings.length - 1; i++) { if (!strings[i].toLowerCase().equals(strings[i])) { return false; } } if (Character.isLowerCase(strings[i].charAt(0))) { return false; } return true; }
From source file:org.wso2.andes.server.security.auth.manager.PrincipalDatabaseAuthenticationManager.java
private String generateSetterName(String argName) throws ConfigurationException { if ((argName == null) || (argName.length() == 0)) { throw new ConfigurationException("Argument names must have length >= 1 character"); }//from ww w .j a v a 2 s. c om if (Character.isLowerCase(argName.charAt(0))) { argName = Character.toUpperCase(argName.charAt(0)) + argName.substring(1); } final String methodName = "set" + argName; return methodName; }
From source file:org.opensextant.util.TextUtils.java
/** * Measure character count, upper, lower, non-Character, whitespace * //from w w w . j a v a2s. c o m * @param text * text * @return int array with counts. */ public static int[] measureCase(String text) { if (text == null) { return null; } int u = 0, l = 0, ch = 0, nonCh = 0, ws = 0; int[] counts = new int[5]; for (char c : text.toCharArray()) { if (Character.isLetter(c)) { ++ch; if (Character.isUpperCase(c)) { ++u; } else if (Character.isLowerCase(c)) { ++l; } } else if (Character.isWhitespace(c)) { ++ws; } else { ++nonCh; // Other content? } } counts[0] = ch; counts[1] = u; counts[2] = l; counts[3] = nonCh; counts[4] = ws; return counts; }
From source file:com.nridge.core.base.std.StrUtl.java
/** * Uses a simple Caesar-cypher encryption to replace each English letter * with the one 13 places forward or back along the alphabet, so that * "The butler did it!" becomes "Gur ohgyre qvq vg!". major advantage * of rot13 over rot(N) for other N is that it is self-inverse, so the * same code can be used for encoding and decoding. * <p>//from w w w .j av a2 s .c o m * <i>Note: The returned string will be wrapped with the less-than and * greater-than characters to signify that they were encrypted by this method. * These wrappers will be expected when the string is recovered.</i> * </p> * * @param aStringPlain A plain text string to encode. * @return An encrypted <i>String</i> object. */ public static String hidePassword(String aStringPlain) { char ch; boolean isAllUpper; StringBuilder strBuilder; int strLength, someNumber; if (StringUtils.isEmpty(aStringPlain)) return aStringPlain; else { strBuilder = new StringBuilder(); strLength = aStringPlain.length(); if (strLength > STRUTL_ROT13PW_SIZE) strLength = STRUTL_ROT13PW_SIZE - 1; isAllUpper = true; for (int i = 0; i < strLength; i++) { ch = aStringPlain.charAt(i); if (Character.isLowerCase(ch)) { isAllUpper = false; break; } } strBuilder.append(STRUTL_CHAR_PWBEGIN); if (isAllUpper) ch = 'A'; else ch = 'a'; ch += strLength; strBuilder.append(ch); if (strLength > STRUTL_ROT13PW_SIZE) strBuilder.append(aStringPlain, 0, STRUTL_ROT13PW_SIZE); else strBuilder.append(aStringPlain); someNumber = 2; for (int i = strLength; i < STRUTL_ROT13PW_SIZE; i++) { if (isAllUpper) ch = 'A'; else ch = 'a'; ch += i; if ((NumUtl.isEven(i)) && (!isAllUpper)) ch = Character.toLowerCase(ch); else if ((i % 3) == 0) { ch = '1'; ch += someNumber; someNumber++; } strBuilder.append(ch); } strBuilder.append(STRUTL_CHAR_PWFINISH); return simple13Rotation(strBuilder.toString()); } }
From source file:egovframework.rte.fdl.string.EgovStringUtil.java
/** * convert first letter to a big letter or a small * letter.<br>//w w w . j ava 2s . c o m * * <pre> * StringUtil.trim('Password') = 'password' * StringUtil.trim('password') = 'Password' * </pre> * @param str * String to be swapped * @return String converting result */ public static String swapFirstLetterCase(String str) { StringBuffer sbuf = new StringBuffer(str); sbuf.deleteCharAt(0); if (Character.isLowerCase(str.substring(0, 1).toCharArray()[0])) { sbuf.insert(0, str.substring(0, 1).toUpperCase()); } else { sbuf.insert(0, str.substring(0, 1).toLowerCase()); } return sbuf.toString(); }
From source file:com.jiahuan.svgmapview.core.helper.map.SVGParser.java
/** * This is where the hard-to-parse paths are handled. Uppercase rules are * absolute positions, lowercase are relative. Types of path rules: * <p/>/* w w w. ja va 2 s. c o m*/ * <ol> * <li>M/m - (x y)+ - Move to (without drawing) * <li>Z/z - (no params) - Close path (back to starting point) * <li>L/l - (x y)+ - Line to * <li>H/h - x+ - Horizontal ine to * <li>V/v - y+ - Vertical line to * <li>C/c - (x1 y1 x2 y2 x y)+ - Cubic bezier to * <li>S/s - (x2 y2 x y)+ - Smooth cubic bezier to (shorthand that assumes * the x2, y2 from previous C/S is the x1, y1 of this bezier) * <li>Q/q - (x1 y1 x y)+ - Quadratic bezier to * <li>T/t - (x y)+ - Smooth quadratic bezier to (assumes previous control * point is "reflection" of last one w.r.t. to current point) * </ol> * <p/> * Numbers are separate by whitespace, comma or nothing at all (!) if they * are self-delimiting, (ie. begin with a - sign) * * @param s * the path string from the XML */ private static Path doPath(String s) { int n = s.length(); ParserHelper ph = new ParserHelper(s, 0); ph.skipWhitespace(); Path p = new Path(); float lastX = 0; float lastY = 0; float lastX1 = 0; float lastY1 = 0; float subPathStartX = 0; float subPathStartY = 0; char prevCmd = 0; while (ph.pos < n) { char cmd = s.charAt(ph.pos); switch (cmd) { case '-': case '+': case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (prevCmd == 'm' || prevCmd == 'M') { cmd = (char) ((prevCmd) - 1); break; } else if (("lhvcsqta").indexOf(Character.toLowerCase(prevCmd)) >= 0) { cmd = prevCmd; break; } default: { ph.advance(); prevCmd = cmd; } } boolean wasCurve = false; switch (cmd) { case 'M': case 'm': { float x = ph.nextFloat(); float y = ph.nextFloat(); if (cmd == 'm') { subPathStartX += x; subPathStartY += y; p.rMoveTo(x, y); lastX += x; lastY += y; } else { subPathStartX = x; subPathStartY = y; p.moveTo(x, y); lastX = x; lastY = y; } break; } case 'Z': case 'z': { p.close(); p.moveTo(subPathStartX, subPathStartY); lastX = subPathStartX; lastY = subPathStartY; lastX1 = subPathStartX; lastY1 = subPathStartY; wasCurve = true; break; } case 'T': case 't': // todo - smooth quadratic Bezier (two parameters) case 'L': case 'l': { float x = ph.nextFloat(); float y = ph.nextFloat(); if (cmd == 'l') { p.rLineTo(x, y); lastX += x; lastY += y; } else { p.lineTo(x, y); lastX = x; lastY = y; } break; } case 'H': case 'h': { float x = ph.nextFloat(); if (cmd == 'h') { p.rLineTo(x, 0); lastX += x; } else { p.lineTo(x, lastY); lastX = x; } break; } case 'V': case 'v': { float y = ph.nextFloat(); if (cmd == 'v') { p.rLineTo(0, y); lastY += y; } else { p.lineTo(lastX, y); lastY = y; } break; } case 'C': case 'c': { wasCurve = true; float x1 = ph.nextFloat(); float y1 = ph.nextFloat(); float x2 = ph.nextFloat(); float y2 = ph.nextFloat(); float x = ph.nextFloat(); float y = ph.nextFloat(); if (cmd == 'c') { x1 += lastX; x2 += lastX; x += lastX; y1 += lastY; y2 += lastY; y += lastY; } p.cubicTo(x1, y1, x2, y2, x, y); lastX1 = x2; lastY1 = y2; lastX = x; lastY = y; break; } case 'Q': case 'q': // todo - quadratic Bezier (four parameters) case 'S': case 's': { wasCurve = true; float x2 = ph.nextFloat(); float y2 = ph.nextFloat(); float x = ph.nextFloat(); float y = ph.nextFloat(); if (Character.isLowerCase(cmd)) { x2 += lastX; x += lastX; y2 += lastY; y += lastY; } float x1 = 2 * lastX - lastX1; float y1 = 2 * lastY - lastY1; p.cubicTo(x1, y1, x2, y2, x, y); lastX1 = x2; lastY1 = y2; lastX = x; lastY = y; break; } case 'A': case 'a': { float rx = ph.nextFloat(); float ry = ph.nextFloat(); float theta = ph.nextFloat(); int largeArc = ph.nextFlag(); int sweepArc = ph.nextFlag(); float x = ph.nextFloat(); float y = ph.nextFloat(); if (cmd == 'a') { x += lastX; y += lastY; } drawArc(p, lastX, lastY, x, y, rx, ry, theta, largeArc, sweepArc); lastX = x; lastY = y; break; } default: Log.w(TAG, "Invalid path command: " + cmd); ph.advance(); } if (!wasCurve) { lastX1 = lastX; lastY1 = lastY; } ph.skipWhitespace(); } return p; }
From source file:android.databinding.tool.reflection.ModelClass.java
private static String stripFieldName(String fieldName) { // TODO: Make this configurable through IntelliJ if (fieldName.length() > 2) { final char start = fieldName.charAt(2); if (fieldName.startsWith("m_") && Character.isJavaIdentifierStart(start)) { return Character.toLowerCase(start) + fieldName.substring(3); }//from w ww .ja va2 s . co m } if (fieldName.length() > 1) { final char start = fieldName.charAt(1); final char fieldIdentifier = fieldName.charAt(0); final boolean strip; if (fieldIdentifier == '_') { strip = true; } else if (fieldIdentifier == 'm' && Character.isJavaIdentifierStart(start) && !Character.isLowerCase(start)) { strip = true; } else { strip = false; // not mUppercase format } if (strip) { return Character.toLowerCase(start) + fieldName.substring(2); } } return fieldName; }
From source file:com.aiblockchain.api.StringUtils.java
/** * Gets a lower case predicate or variable name derived from the given simple class name. * * @param simpleClassName the given simple class name * * @return a lower case predicate or variable name derived from the given simple class name *//* ww w. j av a2 s . c o m*/ public static String getLowerCasePredicateName(final String simpleClassName) { //Preconditions assert simpleClassName != null : "simpleClassName must not be null"; assert !simpleClassName.isEmpty() : "simpleClassName must not be empty"; // predicates begin with a lower case letter, but class names are capitalized and may also begin with a accronym if (simpleClassName.length() == 1) { // trivial case return simpleClassName.toLowerCase(Locale.ENGLISH); } else { final StringBuilder stringBuilder = new StringBuilder(); int index = 0; final int simpleClassName_len = simpleClassName.length(); while (true) { if (index >= simpleClassName_len) { // reached the end with all upper case characters break; } char ch = simpleClassName.charAt(index); stringBuilder.append(Character.toLowerCase(ch)); if (index < simpleClassName_len - 2 && Character.isUpperCase(simpleClassName.charAt(index + 1)) && Character.isLowerCase(simpleClassName.charAt(index + 2))) { break; } else if (index < simpleClassName_len - 1 && Character.isLowerCase(simpleClassName.charAt(index + 1))) { break; } index++; } // copy any remaining characters unchanged for (int i = index + 1; i < simpleClassName_len; i++) { stringBuilder.append(simpleClassName.charAt(i)); } return stringBuilder.toString(); } }
From source file:org.ebayopensource.turmeric.eclipse.services.ui.wizards.pages.ServiceFromNewWSDLAddOperationWizardPage.java
private boolean validateWSDLOperationName(String optName) { // no validation if it is an existing operation. if (newOperations == null) { return true; }//from ww w. j a va 2 s . c o m boolean isNewOperation = false; for (Operation oprt : newOperations) { if (oprt.getName().equals(optName)) { isNewOperation = true; break; } } if (isNewOperation == false) { return true; } // check name is empty if (optName.length() == 0) { return false; } // check name is lower case started char start = optName.charAt(0); if (Character.isLowerCase(start) == false) { return false; } // more validations may coming here... return true; }
From source file:org.sharegov.cirm.utils.GenUtils.java
/** * Ensures that a string starts with a capitalized letter. * @param s accepts a string, null, empty * @return/*from ww w . ja v a 2s . c o m*/ */ public static String capitalize(String s) { if (s == null || s.isEmpty()) return s; char first = s.charAt(0); if (Character.isLetter(first) && Character.isLowerCase(first)) return Character.toUpperCase(first) + s.substring(1); else return s; }