List of usage examples for java.lang Character toLowerCase
public static int toLowerCase(int codePoint)
From source file:lucee.commons.lang.StringUtil.java
/** * translate a string in camel notation to a string in hypen notation * example:/* w w w. ja v a2 s . c o m*/ * helloWorld -> hello-world * @param str * @return */ public static String camelToHypenNotation(String str) { if (isEmpty(str)) return str; StringBuilder sb = new StringBuilder(); //int len=str.length(); char c; sb.append(Character.toLowerCase(str.charAt(0))); for (int i = 1; i < str.length(); i++) { c = str.charAt(i); if (Character.isUpperCase(c)) { sb.append('-'); sb.append(Character.toLowerCase(c)); } else sb.append(c); } return sb.toString(); }
From source file:org.eclipse.jubula.rc.swt.driver.RobotSwtImpl.java
/** * @param character// w ww .j a va 2 s. c o m * the character * @return the "corrected" character, e.g. for Mac OS X it has to be in * lower case */ private static char getOSSspecificSpecBaseCharacter(char character) { if (EnvironmentUtils.isMacOS() && Character.isUpperCase(character)) { return Character.toLowerCase(character); } return character; }
From source file:mil.army.usace.data.dataquery.rdbms.RdbmsDataQuery.java
public String getDbName(String attributeName) { String fieldName = ""; for (int i = 0; i < attributeName.length(); i++) { if (i == 0) fieldName += Character.toLowerCase(attributeName.charAt(i)); else {/*from w w w . j a v a 2 s .co m*/ char c = attributeName.charAt(i); if (Character.isUpperCase(c)) fieldName += "_" + Character.toLowerCase(c); else fieldName += c; } } return fieldName; }
From source file:org.apache.uima.ruta.resource.MultiTreeWordList.java
/** * Returns a map with all strings with a specified edit distance to the string query as keys and * the files they belong to as values./*from w w w. j a v a 2 s . co m*/ * * @param node * The MultiTextNode which is under consideration at the moment. * @param query * The query string. * @param result * The result which matched until now. * @param distance * The remaining edit distance. * @param index * The index of the query string at the moment. * @param ignoreCase * Indicates whether we search case sensitive or not. * @param fragment * Indicates whether we search for fragments of the query string or not. * @param edm * The edit distance cost map we are using. * @param lastActionInsert * Indicates whether the last action was an insert action. * @param lastActionDelete * Indicates whether the last action was a delete action. * @return A map with all strings with a specified edit distance to the string query as keys and * the files they belong to as values. */ private Map<String, Set<String>> editDistanceClever(MultiTextNode node, String query, String result, double distance, int index, boolean ignoreCase, boolean fragment, EditDistanceCostMap edm, boolean lastActionInsert, boolean lastActionDelete) { EditDistanceResultMap resultMap = new EditDistanceResultMap(); if (!lastActionInsert) { // Delete. if (distance - edm.getDeleteCosts(node.getValue()) >= 0 && result.length() > 0) { resultMap.putAll( editDistanceClever(node, query, result, distance - edm.getDeleteCosts(node.getValue()), index + 1, ignoreCase, fragment, edm, false, true)); } } // Recursion stop. if (node.isWordEnd() || fragment) { HashMap<String, Set<String>> temp = new HashMap<String, Set<String>>(); double remainingInsertCosts = 0.0; // Accumulating remaining insert costs if the query is longer than // the word in the trie. for (int i = index; i < query.length(); i++) { remainingInsertCosts += edm.getInsertCosts(query.charAt(i)); } if (remainingInsertCosts <= distance) { // if (remainingInsertCosts <= distance && // !node.getTypes().isEmpty()) { // if (query.length() - index <= distance) { if (fragment) { temp.put(result, new HashSet<String>(getTypeCone(node))); } else { temp.put(result, new HashSet<String>(node.getTypes())); } resultMap.putAll(temp); } // Important: word end does not mean no children any more! if (node.getChildren() == null) { return resultMap; } } // Recursion. for (MultiTextNode tempNode : node.getChildren().values()) { if (index < query.length()) { if (ignoreCase) { if (Character.toLowerCase(tempNode.getValue()) == Character.toLowerCase(query.charAt(index))) { resultMap.putAll(editDistanceClever(tempNode, query, result + tempNode.getValue(), distance, index + 1, ignoreCase, fragment, edm, false, false)); } } else { if (tempNode.getValue() == query.charAt(index)) { resultMap.putAll(editDistanceClever(tempNode, query, result + tempNode.getValue(), distance, index + 1, ignoreCase, fragment, edm, false, false)); } } } if (distance - edm.getReplaceCosts(node.getValue(), tempNode.getValue()) >= 0) { // Substitute. resultMap.putAll(editDistanceClever(tempNode, query, result + tempNode.getValue(), distance - edm.getReplaceCosts(node.getValue(), tempNode.getValue()), index + 1, ignoreCase, fragment, edm, false, false)); } if (!lastActionDelete) { if (distance - edm.getInsertCosts(tempNode.getValue()) >= 0) { // Insert - use the same index twice. resultMap.putAll(editDistanceClever(tempNode, query, result + tempNode.getValue(), distance - edm.getInsertCosts(tempNode.getValue()), index, ignoreCase, fragment, edm, true, false)); } } } return resultMap; }
From source file:com.glaf.core.util.StringTools.java
public static String toUnderLineName(String s) { if (s == null) { return null; }// w w w . ja v a2 s . co m StringBuilder sb = new StringBuilder(); boolean upperCase = false; for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); boolean nextUpperCase = true; if (i < (s.length() - 1)) { nextUpperCase = Character.isUpperCase(s.charAt(i + 1)); } if ((i >= 0) && Character.isUpperCase(c)) { if (!upperCase || !nextUpperCase) { if (i > 0) sb.append(SEPARATOR); } upperCase = true; } else { upperCase = false; } sb.append(Character.toLowerCase(c)); } return sb.toString(); }
From source file:keyboard.ecloga.com.eclogakeyboard.EclogaKeyboard.java
@Override public void onKey(int primaryCode, int[] keyCodes) { final InputConnection ic = getCurrentInputConnection(); playClick();//from w ww.ja va 2 s . co m printChar = true; if (primaryCode != 126 && primaryCode != -5 && primaryCode != -1 && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_1 && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_2 && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_3 && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_4 && primaryCode != EmojiKeyboardView.KEYCODE_EMOJI_5) { keyPressCounter++; if (keyPressCounter > 100 && keyPressCounter <= 1000 && keypresscounter1.equals("false")) { NotificationManager notif = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard", System.currentTimeMillis()); PendingIntent pending = PendingIntent.getActivity(this, 0, new Intent(this, Home.class), 0); notify.setLatestEventInfo(getApplicationContext(), "Warming up!", "Type more than 100 characters", pending); notif.notify(0, notify); Preferences.setDefaults("keypresscounter1", "true", getApplicationContext()); } else if (keyPressCounter > 10000 && keyPressCounter <= 10000 && keypresscounter2.equals("false")) { NotificationManager notif = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard", System.currentTimeMillis()); PendingIntent pending = PendingIntent.getActivity(this, 0, new Intent(this, Home.class), 0); notify.setLatestEventInfo(getApplicationContext(), "Keep it up!", "Type more than 1000 characters", pending); notif.notify(0, notify); Preferences.setDefaults("keypresscounter2", "true", getApplicationContext()); } else if (keyPressCounter > 10000 && keypresscounter3.equals("false")) { NotificationManager notif = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Notification notify = new Notification(R.drawable.notify, "Ecloga Keyboard", System.currentTimeMillis()); PendingIntent pending = PendingIntent.getActivity(this, 0, new Intent(this, Home.class), 0); notify.setLatestEventInfo(getApplicationContext(), "Typing master!", "Type more than 10000 characters", pending); notif.notify(0, notify); Preferences.setDefaults("keypresscounter3", "true", getApplicationContext()); } Preferences.setDefaults("keypresses", String.valueOf(keyPressCounter), getApplicationContext()); } switch (primaryCode) { case 58: ic.commitText(":", 1); if (autoSpacing) { ic.commitText(" ", 1); } break; case 59: ic.commitText(";", 1); if (autoSpacing) { ic.commitText(" ", 1); } break; case 33: ic.commitText("!", 1); if (autoSpacing) { ic.commitText(" ", 1); } if (autoCapitalize) { caps = true; keyboard.setShifted(caps); kv.invalidateAllKeys(); printChar = false; } break; case 63: ic.commitText("?", 1); if (autoSpacing) { ic.commitText(" ", 1); } if (autoCapitalize) { caps = true; keyboard.setShifted(caps); kv.invalidateAllKeys(); printChar = false; } break; case -5: if (lang.equals("seclang")) { if (orient.equals("portrait")) { keyboard = prilang; } else if (orient.equals("landscape")) { keyboard = prilang_landscape; } kv.setKeyboard(keyboard); kv.invalidateAllKeys(); lang = "prilang"; } else if (lang.equals("prilang")) { if (orient.equals("portrait")) { keyboard = seclang; } else if (orient.equals("landscape")) { keyboard = seclang_landscape; } kv.setKeyboard(keyboard); kv.invalidateAllKeys(); lang = "seclang"; } break; case 32: ic.commitText(" ", 1); if (autoCapitalize) { if (String.valueOf(ic.getTextBeforeCursor(2, 0)).equals(". ")) { caps = true; keyboard.setShifted(caps); kv.invalidateAllKeys(); printChar = false; } } break; case 126: ic.deleteSurroundingText(1, 0); if (autoCapitalize) { if (String.valueOf(ic.getTextBeforeCursor(1, 0)).equals(".") || String.valueOf(ic.getTextBeforeCursor(2, 0)).equals(". ") || String.valueOf(ic.getTextBeforeCursor(2, 0)).equals("")) { caps = true; keyboard.setShifted(caps); kv.invalidateAllKeys(); printChar = false; } } break; case 44: ic.commitText(",", 1); if (autoSpacing) { ic.commitText(" ", 1); } break; case 46: ic.commitText(".", 1); if (autoSpacing) { ic.commitText(" ", 1); } if (autoCapitalize) { caps = true; keyboard.setShifted(caps); kv.invalidateAllKeys(); printChar = false; } break; case -1: ic.performEditorAction(EditorInfo.IME_ACTION_GO); break; case EmojiKeyboardView.KEYCODE_EMOJI_1: keyboard = new Keyboard(this, R.xml.emoji_a1); kv.setKeyboard(keyboard); kv.invalidateAllKeys(); emoji = 1; eScreen = 1; break; case EmojiKeyboardView.KEYCODE_EMOJI_2: keyboard = new Keyboard(this, R.xml.emoji_b1); kv.setKeyboard(keyboard); kv.invalidateAllKeys(); emoji = 2; eScreen = 1; break; case EmojiKeyboardView.KEYCODE_EMOJI_3: keyboard = new Keyboard(this, R.xml.emoji_c1); kv.setKeyboard(keyboard); kv.invalidateAllKeys(); emoji = 3; eScreen = 1; break; case EmojiKeyboardView.KEYCODE_EMOJI_4: keyboard = new Keyboard(this, R.xml.emoji_d1); kv.setKeyboard(keyboard); kv.invalidateAllKeys(); emoji = 4; eScreen = 1; break; case EmojiKeyboardView.KEYCODE_EMOJI_5: keyboard = new Keyboard(this, R.xml.emoji_e1); kv.setKeyboard(keyboard); kv.invalidateAllKeys(); emoji = 5; eScreen = 1; break; default: char code = (char) primaryCode; if (allCaps) { if (Character.isLetter(code) && capsLock) { code = Character.toLowerCase(code); } else if (Character.isLetter(code) && !capsLock) { code = Character.toUpperCase(code); } } else { if (Character.isLetter(code) && caps) { code = Character.toUpperCase(code); } } String character = String.valueOf(code); ic.commitText(character, 1); } if (printedDifferent) { ic.deleteSurroundingText(1, 0); } if (printedDot) { ic.deleteSurroundingText(1, 0); if (autoCapitalize) { caps = true; keyboard.setShifted(caps); kv.invalidateAllKeys(); printChar = false; } } if (doubleUp == 2) { capsChange(); } else { changeCaps(); } }
From source file:edu.usc.cssl.tacit.classify.naivebayes.services.Vectors2Classify.java
private static ClassifierTrainer getTrainer(String arg) { // parse something like Maxent,gaussianPriorVariance=10,numIterations=20 // first, split the argument at commas. java.lang.String fields[] = arg.split(","); // Massage constructor name, so that MaxEnt, MaxEntTrainer, new // MaxEntTrainer() // all call new MaxEntTrainer() java.lang.String constructorName = fields[0]; Object trainer;/*from w w w . j av a 2s.com*/ if (constructorName.indexOf('(') != -1) // if contains (), pass it // though trainer = createTrainer(arg); else { if (constructorName.endsWith("Trainer")) { trainer = createTrainer("new " + constructorName + "()"); // add // parens // if // they // forgot } else { trainer = createTrainer("new " + constructorName + "Trainer()"); // make // trainer // name // from // classifier // name } } // find methods associated with the class we just built Method methods[] = trainer.getClass().getMethods(); // find setters corresponding to parameter names. for (int i = 1; i < fields.length; i++) { java.lang.String nameValuePair[] = fields[i].split("="); java.lang.String parameterName = nameValuePair[0]; java.lang.String parameterValue = nameValuePair[1]; // todo: check // for val // present! java.lang.Object parameterValueObject; try { parameterValueObject = interpreter.eval(parameterValue); } catch (bsh.EvalError e) { throw new IllegalArgumentException( "Java interpreter eval error on parameter " + parameterName + "\n" + e); } boolean foundSetter = false; for (int j = 0; j < methods.length; j++) { // System.out.println("method " + j + " name is " + // methods[j].getName()); // System.out.println("set" + // Character.toUpperCase(parameterName.charAt(0)) + // parameterName.substring(1)); if (("set" + Character.toUpperCase(parameterName.charAt(0)) + parameterName.substring(1)) .equals(methods[j].getName()) && methods[j].getParameterTypes().length == 1) { // System.out.println("Matched method " + // methods[j].getName()); // Class[] ptypes = methods[j].getParameterTypes(); // System.out.println("Parameter types:"); // for (int k=0; k<ptypes.length; k++){ // System.out.println("class " + k + " = " + // ptypes[k].getName()); // } try { java.lang.Object[] parameterList = new java.lang.Object[] { parameterValueObject }; // System.out.println("Argument types:"); // for (int k=0; k<parameterList.length; k++){ // System.out.println("class " + k + " = " + // parameterList[k].getClass().getName()); // } methods[j].invoke(trainer, parameterList); } catch (IllegalAccessException e) { System.out.println("IllegalAccessException " + e); throw new IllegalArgumentException("Java access error calling setter\n" + e); } catch (InvocationTargetException e) { System.out.println("IllegalTargetException " + e); throw new IllegalArgumentException("Java target error calling setter\n" + e); } foundSetter = true; break; } } if (!foundSetter) { System.out.println("Parameter " + parameterName + " not found on trainer " + constructorName); System.out.println("Available parameters for " + constructorName); for (int j = 0; j < methods.length; j++) { if (methods[j].getName().startsWith("set") && methods[j].getParameterTypes().length == 1) { System.out.println(Character.toLowerCase(methods[j].getName().charAt(3)) + methods[j].getName().substring(4)); } } throw new IllegalArgumentException("no setter found for parameter " + parameterName); } } assert (trainer instanceof ClassifierTrainer); return ((ClassifierTrainer) trainer); }
From source file:mil.army.usace.data.dataquery.rdbms.RdbmsDataQuery.java
public String dbToClassName(String dbName) throws ClassNotFoundException { String className = ""; for (int i = 0; i < dbName.length(); i++) { if (i == 0) className += Character.toUpperCase(dbName.charAt(i)); else {/* w w w. j a v a 2 s .co m*/ char c = dbName.charAt(i); if (c == '_') { i++; className += Character.toUpperCase(dbName.charAt(i)); } else { className += Character.toLowerCase(c); } } } return className; }
From source file:com.gohighedu.platform.framework.utils.common.StringUtils.java
public static String lowercaseFirstLetter(String data) { char firstLetter = Character.toLowerCase(data.substring(0, 1).charAt(0)); String restLetters = data.substring(1); return firstLetter + restLetters; }
From source file:edu.umd.cfar.lamp.viper.util.StringHelp.java
/** * Decodes a string encoded with {@link #encodeAsAnAcceptableFileName(String)}, * which is to say it decodes any URL encoded string. * @param s an URL encoded string//from w w w. j ava 2 s .c o m * @return the decoded string */ public static String unescapeAnAcceptableFileName(String s) { StringBuffer sbuf = new StringBuffer(); int l = s.length(); int ch = -1; int b, sumb = 0; for (int i = 0, more = -1; i < l; i++) { /* Get next byte b from URL segment s */ switch (ch = s.charAt(i)) { case '%': ch = s.charAt(++i); int hb = (Character.isDigit((char) ch) ? ch - '0' : 10 + Character.toLowerCase((char) ch) - 'a') & 0xF; ch = s.charAt(++i); int lb = (Character.isDigit((char) ch) ? ch - '0' : 10 + Character.toLowerCase((char) ch) - 'a') & 0xF; b = (hb << 4) | lb; break; case '+': b = ' '; break; default: b = ch; } /* Decode byte b as UTF-8, sumb collects incomplete chars */ if ((b & 0xc0) == 0x80) { // 10xxxxxx (continuation byte) sumb = (sumb << 6) | (b & 0x3f); // Add 6 bits to sumb if (--more == 0) sbuf.append((char) sumb); // Add char to sbuf } else if ((b & 0x80) == 0x00) { // 0xxxxxxx (yields 7 bits) sbuf.append((char) b); // Store in sbuf } else if ((b & 0xe0) == 0xc0) { // 110xxxxx (yields 5 bits) sumb = b & 0x1f; more = 1; // Expect 1 more byte } else if ((b & 0xf0) == 0xe0) { // 1110xxxx (yields 4 bits) sumb = b & 0x0f; more = 2; // Expect 2 more bytes } else if ((b & 0xf8) == 0xf0) { // 11110xxx (yields 3 bits) sumb = b & 0x07; more = 3; // Expect 3 more bytes } else if ((b & 0xfc) == 0xf8) { // 111110xx (yields 2 bits) sumb = b & 0x03; more = 4; // Expect 4 more bytes } else /*if ((b & 0xfe) == 0xfc)*/ { // 1111110x (yields 1 bit) sumb = b & 0x01; more = 5; // Expect 5 more bytes } /* We don't test if the UTF-8 encoding is well-formed */ } return sbuf.toString(); }