scan的意思 JAVA,java的scan是干吗用的

Java codepublic String toUpperCase(Locale locale) {

if (locale == null) {

throw new NullPointerException();

}

int firstLower;

/* Now check if there are any characters that need to be changed. */

scan: {

for (firstLower = 0 ; firstLower < count; ) {

int c = (int)value[offset+firstLower];

int srcCount;

if ((c >= Character.MIN_HIGH_SURROGATE) &&

(c <= Character.MAX_HIGH_SURROGATE)) {

c = codePointAt(firstLower);

srcCount = Character.charCount(c);

} else {

srcCount = 1;

}

int upperCaseChar = Character.toUpperCaseEx(c);

if ((upperCaseChar == Character.ERROR) ||

(c != upperCaseChar)) {

break scan;

}

firstLower += srcCount;

}

return this;

}

char[] result = new char[count]; /* may grow */

int resultOffset = 0; /* result may grow, so i+resultOffset

* is the write location in result */

/* Just copy the first few upperCase characters. */

System.arraycopy(value, offset, result, 0, firstLower);

String lang = locale.getLanguage();

boolean localeDependent =

(lang == "tr" || lang == "az" || lang == "lt");

char[] upperCharArray;

int upperChar;

int srcChar;

int srcCount;

for (int i = firstLower; i < count; i += srcCount) {

srcChar = (int)value[offset+i];

if ((char)srcChar >= Character.MIN_HIGH_SURROGATE &&

(char)srcChar <= Character.MAX_HIGH_SURROGATE) {

srcChar = codePointAt(i);

srcCount = Character.charCount(srcChar);

} else {

srcCount = 1;

}

if (localeDependent) {

upperChar = ConditionalSpecialCasing.toUpperCaseEx(this, i, locale);

} else {

upperChar = Character.toUpperCaseEx(srcChar);

}

if ((upperChar == Character.ERROR) ||

(upperChar >= Character.MIN_SUPPLEMENTARY_CODE_POINT)) {

if (upperChar == Character.ERROR) {

if (localeDependent) {

upperCharArray =

ConditionalSpecialCasing.toUpperCaseCharArray(this, i, locale);

} else {

upperCharArray = Character.toUpperCaseCharArray(srcChar);

}

} else if (srcCount == 2) {

resultOffset += Character.toChars(upperChar, result, i + resultOffset) - srcCount;

continue;

} else {

upperCharArray = Character.toChars(upperChar);

}

/* Grow result if needed */

int mapLen = upperCharArray.length;

if (mapLen > srcCount) {

char[] result2 = new char[result.length + mapLen - srcCount];

System.arraycopy(result, 0, result2, 0,

i + resultOffset);

result = result2;

}

for (int x=0; x

result[i+resultOffset+x] = upperCharArray[x];

}

resultOffset += (mapLen - srcCount);

} else {

result[i+resultOffset] = (char)upperChar;

}

}

return new String(0, count+resultOffset, result);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值