本文整理了Java中java.lang.Character.toUpperCase()
方法的一些代码示例,展示了Character.toUpperCase()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Character.toUpperCase()
方法的具体详情如下:
包路径:java.lang.Character
类名称:Character
方法名:toUpperCase
[英]Returns the upper case equivalent for the specified character if the character is a lower case letter. Otherwise, the specified character is returned unchanged.
[中]如果指定字符是小写字母,则返回该字符的大写等效值。否则,指定的字符将原封不动地返回。
代码示例来源:origin: netty/netty
@Override
public boolean equals(char a, char b) {
//For motivation, why we need two checks, see comment in String#regionMatches
return Character.toUpperCase(a) == Character.toUpperCase(b) ||
Character.toLowerCase(a) == Character.toLowerCase(b);
}
}
代码示例来源:origin: libgdx/libgdx
/** @param other May be null. */
public boolean equalsIgnoreCase (StringBuilder other) {
if (this == other) return true;
if (other == null) return false;
int length = this.length;
if (length != other.length) return false;
char[] chars = this.chars, chars2 = other.chars;
for (int i = 0; i < length; i++) {
char c = chars[i];
char upper = Character.toUpperCase(chars2[i]);
if (c != upper && c != Character.toLowerCase(upper)) return false;
}
return true;
}
代码示例来源:origin: libgdx/libgdx
/** @param other May be null. */
public boolean equalsIgnoreCase (StringBuilder other) {
if (this == other) return true;
if (other == null) return false;
int length = this.length;
if (length != other.length) return false;
char[] chars = this.chars, chars2 = other.chars;
for (int i = 0; i < length; i++) {
char c = chars[i];
char upper = Character.toUpperCase(chars2[i]);
if (c != upper && c != Character.toLowerCase(upper)) return false;
}
return true;
}
代码示例来源:origin: redisson/redisson
@Override
public boolean equals(char a, char b) {
//For motivation, why we need two checks, see comment in String#regionMatches
return Character.toUpperCase(a) == Character.toUpperCase(b) ||
Character.toLowerCase(a) == Character.toLowerCase(b);
}
}
代码示例来源:origin: apache/incubator-dubbo
public static String generateGetMethodName(String fieldName) {
return new StringBuffer(16)
.append("get")
.append(Character.toUpperCase(fieldName.charAt(0)))
.append(fieldName.substring(1))
.toString();
}
代码示例来源:origin: apache/incubator-dubbo
public static String generateSetMethodName(String fieldName) {
return new StringBuilder(16)
.append("set")
.append(Character.toUpperCase(fieldName.charAt(0)))
.append(fieldName.substring(1))
.toString();
}
代码示例来源:origin: apache/incubator-dubbo
public static String generateGetMethodName(String fieldName) {
return new StringBuffer(16)
.append("get")
.append(Character.toUpperCase(fieldName.charAt(0)))
.append(fieldName.substring(1))
.toString();
}
代码示例来源:origin: apache/incubator-dubbo
public static String generateSetMethodName(String fieldName) {
return new StringBuilder(16)
.append("set")
.append(Character.toUpperCase(fieldName.charAt(0)))
.append(fieldName.substring(1))
.toString();
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Converts "abc" to "Abc".
*/
public static String capitalize(String s) {
if(s==null || s.length()==0) return s;
return Character.toUpperCase(s.charAt(0))+s.substring(1);
}
代码示例来源:origin: libgdx/libgdx
/** @param other May be null. */
public boolean equalsIgnoreCase (String other) {
if (other == null) return false;
int length = this.length;
if (length != other.length()) return false;
char[] chars = this.chars;
for (int i = 0; i < length; i++) {
char c = chars[i];
char upper = Character.toUpperCase(other.charAt(i));
if (c != upper && c != Character.toLowerCase(upper)) return false;
}
return true;
}
}
代码示例来源:origin: libgdx/libgdx
/** @param other May be null. */
public boolean equalsIgnoreCase (String other) {
if (other == null) return false;
int length = this.length;
if (length != other.length()) return false;
char[] chars = this.chars;
for (int i = 0; i < length; i++) {
char c = chars[i];
char upper = Character.toUpperCase(other.charAt(i));
if (c != upper && c != Character.toLowerCase(upper)) return false;
}
return true;
}
}
代码示例来源:origin: google/guava
@Override
protected char[] escape(int cp) {
return ('a' <= cp && cp <= 'z') ? new char[] {Character.toUpperCase((char) cp)} : null;
}
// Inefficient implementation that defines all letters as escapable.
代码示例来源:origin: greenrobot/greenDAO
public static String capFirst(String string) {
return Character.toUpperCase(string.charAt(0)) + (string.length() > 1 ? string.substring(1) : "");
}
代码示例来源:origin: iBotPeaches/Apktool
private String toUpper(char[] character) {
StringBuilder sb = new StringBuilder();
for (char ch: character) {
sb.append(Character.toUpperCase(ch));
}
return sb.toString();
}
代码示例来源:origin: spring-projects/spring-framework
private static String changeFirstCharacterCase(String str, boolean capitalize) {
if (!hasLength(str)) {
return str;
}
char baseChar = str.charAt(0);
char updatedChar;
if (capitalize) {
updatedChar = Character.toUpperCase(baseChar);
}
else {
updatedChar = Character.toLowerCase(baseChar);
}
if (baseChar == updatedChar) {
return str;
}
char[] chars = str.toCharArray();
chars[0] = updatedChar;
return new String(chars, 0, chars.length);
}
代码示例来源:origin: log4j/log4j
public static String capitalize(String name) {
if (Character.isLowerCase(name.charAt(0))) {
if (name.length() == 1 || Character.isLowerCase(name.charAt(1))) {
StringBuffer newname = new StringBuffer(name);
newname.setCharAt(0, Character.toUpperCase(name.charAt(0)));
return newname.toString();
}
}
return name;
}
代码示例来源:origin: shuzheng/zheng
/**
* 首字母转大写
* @param s
* @return
*/
public static String toUpperCaseFirstOne(String s) {
if (StringUtils.isBlank(s)) {
return s;
}
if (Character.isUpperCase(s.charAt(0))) {
return s;
} else {
return (new StringBuffer()).append(Character.toUpperCase(s.charAt(0))).append(s.substring(1)).toString();
}
}
代码示例来源:origin: prestodb/presto
@Override
public int LA(int i)
{
int result = stream.LA(i);
switch (result) {
case 0:
case IntStream.EOF:
return result;
default:
return Character.toUpperCase(result);
}
}
代码示例来源:origin: jenkinsci/jenkins
/**
* Generates random salt.
*/
private String generateSalt() {
StringBuilder buf = new StringBuilder();
SecureRandom sr = new SecureRandom();
for( int i=0; i<6; i++ ) {// log2(52^6)=34.20... so, this is about 32bit strong.
boolean upper = sr.nextBoolean();
char ch = (char)(sr.nextInt(26) + 'a');
if(upper) ch=Character.toUpperCase(ch);
buf.append(ch);
}
return buf.toString();
}
};
代码示例来源:origin: redisson/redisson
/**
* An element matcher that matches any setter for the given property. When given an empty string, any setter named {@code set}
* is matched despite that such a setter is not fulfilling the Java bean naming conventions.
*
* @param property The property to match a setter for.
* @param <T> The type of the matched object.
* @return A matcher that matches any setter method for the supplied property.
*/
public static <T extends MethodDescription> ElementMatcher.Junction<T> isSetter(String property) {
return isSetter().and(property.length() == 0
? named("set")
: named("set" + Character.toUpperCase(property.charAt(0)) + property.substring(1)));
}
内容来源于网络,如有侵权,请联系作者删除!