本文整理了Java中java.lang.Character.toTitleCase()
方法的一些代码示例,展示了Character.toTitleCase()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Character.toTitleCase()
方法的具体详情如下:
包路径:java.lang.Character
类名称:Character
方法名:toTitleCase
[英]Returns the title case equivalent for the specified character if it exists. Otherwise, the specified character is returned unchanged.
[中]
代码示例来源:origin: org.codehaus.plexus/plexus-utils
public static String capitalizeFirstLetter( String data )
{
char firstLetter = Character.toTitleCase( data.substring( 0, 1 ).charAt( 0 ) );
String restLetters = data.substring( 1 );
return firstLetter + restLetters;
}
代码示例来源:origin: facebook/stetho
private static String capitalize(String str) {
if (str == null || str.length() == 0 || Character.isTitleCase(str.charAt(0))) {
return str;
}
StringBuilder buffer = new StringBuilder(str);
buffer.setCharAt(0, Character.toTitleCase(buffer.charAt(0)));
return buffer.toString();
}
代码示例来源:origin: ltsopensource/light-task-scheduler
private static String capitalize(String str) {
return String.valueOf(Character.toTitleCase(str.charAt(0))) + str.substring(1);
}
代码示例来源:origin: ltsopensource/light-task-scheduler
private static String capitalize(String str) {
return String.valueOf(Character.toTitleCase(str.charAt(0))) + str.substring(1);
}
代码示例来源:origin: stackoverflow.com
public static String toTitleCase(String input) {
StringBuilder titleCase = new StringBuilder();
boolean nextTitleCase = true;
for (char c : input.toCharArray()) {
if (Character.isSpaceChar(c)) {
nextTitleCase = true;
} else if (nextTitleCase) {
c = Character.toTitleCase(c);
nextTitleCase = false;
}
titleCase.append(c);
}
return titleCase.toString();
}
代码示例来源:origin: org.apache.commons/commons-lang3
final int newCodePoint = Character.toTitleCase(firstCodepoint);
if (firstCodepoint == newCodePoint) {
代码示例来源:origin: Activiti/Activiti
/**
* Returns the setter-method for the given field name or null if no setter exists.
*/
public static Method getSetter(String fieldName, Class<?> clazz, Class<?> fieldType) {
String setterName = "set" + Character.toTitleCase(fieldName.charAt(0)) + fieldName.substring(1, fieldName.length());
try {
// Using getMethods(), getMethod(...) expects exact parameter type
// matching and ignores inheritance-tree.
Method[] methods = clazz.getMethods();
for (Method method : methods) {
if (method.getName().equals(setterName)) {
Class<?>[] paramTypes = method.getParameterTypes();
if (paramTypes != null && paramTypes.length == 1 && paramTypes[0].isAssignableFrom(fieldType)) {
return method;
}
}
}
return null;
} catch (SecurityException e) {
throw new ActivitiException("Not allowed to access method " + setterName + " on class " + clazz.getCanonicalName());
}
}
代码示例来源:origin: thymeleaf/thymeleaf
/**
* <p>
* Convert the first letter of target to uppercase (title-case, in fact).
* </p>
*
* @param target the String to be capitalized. If non-String object, toString()
* will be called.
* @return String the result of capitalizing the target.
* @since 1.1.2
*/
public static String capitalize(final Object target) {
if (target == null) {
return null;
}
final StringBuilder result = new StringBuilder(target.toString());
if (result.length() > 0) {
result.setCharAt(0, Character.toTitleCase(result.charAt(0)));
}
return result.toString();
}
代码示例来源:origin: org.apache.commons/commons-lang3
capitalizeNext = true;
} else if (capitalizeNext) {
buffer[i] = Character.toTitleCase(ch);
capitalizeNext = false;
代码示例来源:origin: org.codehaus.plexus/plexus-utils
/**
* <p>
* Capitalise a String.
* </p>
* <p>
* That is, convert the first character into title-case. <code>null</code> is returned as <code>null</code>.
* </p>
*
* @param str the String to capitalise
* @return capitalised String
*/
public static String capitalise( String str )
{
if ( str == null )
{
return null;
}
else if ( str.length() == 0 )
{
return "";
}
else
{
return new StringBuilder( str.length() ).append( Character.toTitleCase( str.charAt( 0 ) ) ).append( str, 1,
str.length() ).toString();
}
}
代码示例来源:origin: baomidou/mybatis-plus
/**
* 拼接字符串第二个字符串第一个字母大写
*/
public static String concatCapitalize(String concatStr, final String str) {
if (isEmpty(concatStr)) {
concatStr = EMPTY;
}
if (str == null || str.length() == 0) {
return str;
}
final char firstChar = str.charAt(0);
if (Character.isTitleCase(firstChar)) {
// already capitalized
return str;
}
return concatStr + Character.toTitleCase(firstChar) + str.substring(1);
}
代码示例来源:origin: org.apache.commons/commons-lang3
} else if (Character.isLowerCase(ch)) {
if (whitespace) {
buffer[i] = Character.toTitleCase(ch);
whitespace = false;
} else {
代码示例来源:origin: org.apache.poi/poi
private static String capitalizeAndTrim(final String str) {
if (str == null || str.length() == 0) {
return str;
}
StringBuilder sb = new StringBuilder(str.length());
boolean capitalizeNext = true;
for (char ch : str.toCharArray()) {
if (!Character.isLetterOrDigit(ch)) {
capitalizeNext = true;
continue;
}
if (capitalizeNext) {
if (!Character.isLetter(ch)) {
sb.append('_');
} else {
ch = Character.toTitleCase(ch);
}
capitalizeNext = false;
}
sb.append(ch);
}
return sb.toString();
}
代码示例来源:origin: commons-lang/commons-lang
capitalizeNext = true;
} else if (capitalizeNext) {
buffer.append(Character.toTitleCase(ch));
capitalizeNext = false;
} else {
代码示例来源:origin: commons-lang/commons-lang
} else if (Character.isLowerCase(ch)) {
if (whitespace) {
tmp = Character.toTitleCase(ch);
} else {
tmp = Character.toUpperCase(ch);
代码示例来源:origin: org.codehaus.plexus/plexus-utils
buffer.append( Character.toTitleCase( ch ) );
space = false;
代码示例来源:origin: stanfordnlp/CoreNLP
private void setTrueCaseText(CoreLabel l) {
String trueCase = l.getString(CoreAnnotations.TrueCaseAnnotation.class);
String text = l.word();
String trueCaseText = text;
switch (trueCase) {
case "UPPER":
trueCaseText = text.toUpperCase();
break;
case "LOWER":
trueCaseText = text.toLowerCase();
break;
case "INIT_UPPER":
trueCaseText = Character.toTitleCase(text.charAt(0)) + text.substring(1).toLowerCase();
break;
case "O":
// The model predicted mixed case, so lookup the map:
String lower = text.toLowerCase();
if (mixedCaseMap.containsKey(lower)) {
trueCaseText = mixedCaseMap.get(lower);
}
// else leave it as it was?
break;
}
// System.err.println(text + " was classified as " + trueCase + " and so became " + trueCaseText);
l.set(CoreAnnotations.TrueCaseTextAnnotation.class, trueCaseText);
if (overwriteText) {
l.set(CoreAnnotations.TextAnnotation.class, trueCaseText);
l.set(CoreAnnotations.ValueAnnotation.class, trueCaseText);
}
}
代码示例来源:origin: thymeleaf/thymeleaf
buffer[idx] = Character.toTitleCase(buffer[idx]);
idx++;
idx = findNextWord(buffer, idx, delimiterChars);
代码示例来源:origin: commons-lang/commons-lang
/**
* <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 WordUtils#capitalize(String)}.
* A <code>null</code> input String returns <code>null</code>.</p>
*
* <pre>
* 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</code> if null String input
* @see 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 StrBuilder(strLen)
.append(Character.toTitleCase(str.charAt(0)))
.append(str.substring(1))
.toString();
}
代码示例来源:origin: jphp-group/jphp
@FastMethod
@Signature(@Arg("char"))
public static Memory title(Environment env, Memory... args) {
return StringMemory.valueOf(Character.toTitleCase(chr(args[0])));
}
内容来源于网络,如有侵权,请联系作者删除!