List of usage examples for java.lang Character toTitleCase
public static int toTitleCase(int codePoint)
From source file:haven.Utils.java
public static String titlecase(String str) { return (Character.toTitleCase(str.charAt(0)) + str.substring(1)); }
From source file:org.opentestsystem.delivery.testreg.domain.Student.java
@JsonProperty public void setGender(final String inGender) { if (isNotEmpty(inGender)) { this.gender = Character.toTitleCase(inGender.charAt(0)) + inGender.substring(1).toLowerCase(); } else {//from ww w. j av a 2 s . c o m this.gender = inGender; } }
From source file:tufts.vue.RichTextBox.java
public void keyPressed(KeyEvent e) { if (DEBUG.KEYS) out(e.toString());/*from w ww . ja v a2 s . c o m*/ //System.out.println("TextBox: " + e); //if (VueUtil.isAbortKey(e)) // check for ESCAPE for CTRL-Z or OPTION-Z if on mac if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { e.consume(); // System.out.println(mUnchangedText); //setText(mUnchangedText); revert = true; getParent().remove(this); // will trigger a save (via focusLost) return; // setSize(mUnchangedSize); // todo: won't be good enough if we ever resize the actual node as we type } else if (isFinishEditKeyPress(e)) { keyWasPressed = true; e.consume(); getParent().remove(this); // will trigger a save (via focusLost) VUE.getFormattingPanel().getTextPropsPane().getFontEditorPanel().updateFormatControlsTB(this); } else if (e.getKeyCode() == KeyEvent.VK_U && e.isMetaDown()) { e.consume(); String t = getText(); if (e.isShiftDown()) setText(t.toUpperCase()); // upper whole string else setText(Character.toTitleCase(t.charAt(0)) + t.substring(1)); // upper first char } else keyWasPressed = true; // Dimension d = preAddDimension; // d.height = this.getPreferredSize().height; // setSize(getPreferredSize()); // action keys will be ignored if we consume this here! // (e.g., "enter" does nothing) //e.consume(); }
From source file:com.blocks.framework.utils.date.StringUtil.java
/** * org.apache.commons.lang3.StringUtils?Thread.currentThread().getContextClassLoader() jni ??: . * StringUtils.capitalize(null) = null * StringUtils.capitalize("") = ""// w w w . j a va 2s . c o m * StringUtils.capitalize("cat") = "Cat" * StringUtils.capitalize("cAt") = "CAt" * </pre> */ public static String capitalize(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return str; } return new StringBuilder(strLen).append(Character.toTitleCase(str.charAt(0))).append(str.substring(1)) .toString(); }
From source file:com.rockagen.commons.util.CommUtil.java
/** * Return camel style string//from w w w . ja va 2s. c o m * <pre>"find_at" to "findAt"</pre> * * @param snake snake String * @return camel String */ public static String snake2camel(String snake) { if (snake == null) return ""; String[] words = snake.split("_"); if (words.length < 1) { return snake; } StringBuilder buf = new StringBuilder(); buf.append(words[0]); for (int i = 1; i < words.length; i++) { String tmp = words[i]; buf.append(Character.toTitleCase(tmp.charAt(0))); if (tmp.length() > 1) { buf.append(tmp.substring(1)); } } return buf.toString(); }
From source file:mekhq.Utilities.java
/** @return the input string with all words capitalized */ public static String capitalize(String str) { if ((null == str) || str.isEmpty()) { return str; }/*from w ww . jav a2 s . co m*/ final char[] buffer = str.toCharArray(); boolean capitalizeNext = true; for (int i = 0; i < buffer.length; ++i) { final char ch = buffer[i]; if (Character.isWhitespace(ch)) { capitalizeNext = true; } else if (capitalizeNext) { buffer[i] = Character.toTitleCase(ch); capitalizeNext = false; } } return new String(buffer); }
From source file:org.apache.commons.lang3.StringUtils.java
/** * <p>Capitalizes a String changing the first letter to title case as * per {@link Character#toTitleCase(char)}. No other letters are changed.</p> * * <p>For a word based algorithm, see {@link org.apache.commons.lang3.text.WordUtils#capitalize(String)}. * A {@code null} input String returns {@code null}.</p> * * <pre>/*from w ww . j av a 2 s . c om*/ * StringUtils.capitalize(null) = null * StringUtils.capitalize("") = "" * StringUtils.capitalize("cat") = "Cat" * StringUtils.capitalize("cAt") = "CAt" * </pre> * * @param str the String to capitalize, may be null * @return the capitalized String, {@code null} if null String input * @see org.apache.commons.lang3.text.WordUtils#capitalize(String) * @see #uncapitalize(String) * @since 2.0 */ public static String capitalize(String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return str; } return new StringBuilder(strLen).append(Character.toTitleCase(str.charAt(0))).append(str.substring(1)) .toString(); }
From source file:com.rdm.common.util.StringUtils.java
/** * <p>Capitalizes a String changing the first letter to title case as * per {@link Character#toTitleCase(char)}. No other letters are changed.</p> * * <p>For a word based algorithm, see {@link com.rdm.common.util.text.WordUtils#capitalize(String)}. * A {@code null} input String returns {@code null}.</p> * * <pre>//from w w w . j a v a 2 s . com * StringUtils.capitalize(null) = null * StringUtils.capitalize("") = "" * StringUtils.capitalize("cat") = "Cat" * StringUtils.capitalize("cAt") = "CAt" * </pre> * * @param str the String to capitalize, may be null * @return the capitalized String, {@code null} if null String input * @see com.rdm.common.util.text.WordUtils#capitalize(String) * @see #uncapitalize(String) * @since 2.0 */ public static String capitalize(final String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return str; } char firstChar = str.charAt(0); if (Character.isTitleCase(firstChar)) { // already capitalized return str; } return new StringBuilder(strLen).append(Character.toTitleCase(firstChar)).append(str.substring(1)) .toString(); }
From source file:com.clark.func.Functions.java
/** * <p>/*from w ww . j a v a2s.c om*/ * Capitalizes a String changing the first letter to title case as per * {@link Character#toTitleCase(char)}. No other letters are changed. * </p> * * <p> * For a word based algorithm, see * {@link org.apache.commons.lang3.text.WordUtils#capitalize(String)}. A * <code>null</code> input String returns <code>null</code>. * </p> * * <pre> * capitalize(null) = null * capitalize("") = "" * capitalize("cat") = "Cat" * capitalize("cAt") = "CAt" * </pre> * * @param cs * the String to capitalize, may be null * @return the capitalized String, <code>null</code> if null String input * @see org.apache.commons.lang3.text.WordUtils#capitalize(String) * @see #uncapitalize(CharSequence) * @since 2.0 * @since 3.0 Changed signature from capitalize(String) to * capitalize(CharSequence) */ public static String capitalize(CharSequence cs) { if (cs == null) { return null; } int strLen; if ((strLen = cs.length()) == 0) { return cs.toString(); } return new StringBuilder(strLen).append(Character.toTitleCase(cs.charAt(0))).append(subSequence(cs, 1)) .toString(); }
From source file:bfile.util.StringUtils.java
/** * <p>Capitalizes a String changing the first character to title case as * per {@link Character#toTitleCase(int)}. No other characters are changed.</p> * * <p>For a word based algorithm, see {@link org.apache.commons.lang3.text.WordUtils#capitalize(String)}. * A {@code null} input String returns {@code null}.</p> * * <pre>/*from ww w. ja v a 2 s . c om*/ * StringUtils.capitalize(null) = null * StringUtils.capitalize("") = "" * StringUtils.capitalize("cat") = "Cat" * StringUtils.capitalize("cAt") = "CAt" * StringUtils.capitalize("'cat'") = "'cat'" * </pre> * * @param str the String to capitalize, may be null * @return the capitalized String, {@code null} if null String input * @see org.apache.commons.lang3.text.WordUtils#capitalize(String) * @see #uncapitalize(String) * @since 2.0 */ public static String capitalize(final String str) { int strLen; if (str == null || (strLen = str.length()) == 0) { return str; } final int firstCodepoint = str.codePointAt(0); final int newCodePoint = Character.toTitleCase(firstCodepoint); if (firstCodepoint == newCodePoint) { // already capitalized return str; } int newCodePoints[] = new int[strLen]; // cannot be longer than the char array int outOffset = 0; newCodePoints[outOffset++] = newCodePoint; // copy the first codepoint for (int inOffset = Character.charCount(firstCodepoint); inOffset < strLen;) { final int codepoint = str.codePointAt(inOffset); newCodePoints[outOffset++] = codepoint; // copy the remaining ones inOffset += Character.charCount(codepoint); } return new String(newCodePoints, 0, outOffset); }