if (picture==null || picture.length()==0) {
return "" + number;
}
int pictureLength = StringValue.getStringLength(picture);
FastStringBuffer sb = new FastStringBuffer(FastStringBuffer.TINY);
int formchar = picture.charAt(0);
if (UTF16CharacterSet.isHighSurrogate(formchar)) {
formchar = UTF16CharacterSet.combinePair((char)formchar, picture.charAt(1));
}
switch(formchar) {
case '0':
case '1':
sb.append(toRadical(number, westernDigits, pictureLength, groupSize, groupSeparator));
if (ordinal != null && ordinal.length() > 0) {
sb.append(ordinalSuffix(ordinal, number));
}
break;
case 'A':
if (number==0) {
return "0";
}
return toAlphaSequence(number, latinUpper);
case 'a':
if (number==0) {
return "0";
}
return toAlphaSequence(number, latinLower);
case 'w':
case 'W':
int wordCase;
if (picture.equals("W")) {
wordCase = UPPER_CASE;
} else if (picture.equals("w")) {
wordCase = LOWER_CASE;
} else {
// includes cases like "ww" or "Wz". The action here is conformant, but it's not clear what's best
wordCase = TITLE_CASE;
}
if (ordinal != null && ordinal.length() > 0) {
return toOrdinalWords(ordinal, number, wordCase);
} else {
return toWords(number, wordCase);
}
case 'i':
if (number==0) {
return "0";
}
if (letterValue==null || letterValue.length() == 0 ||
letterValue.equals("traditional")) {
return toRoman(number);
} else {
alphaDefault(number, 'i', sb);
}
break;
case 'I':
if (number==0) {
return "0";
}
if (letterValue==null || letterValue.length() == 0 ||
letterValue.equals("traditional")) {
return toRoman(number).toUpperCase();
} else {
alphaDefault(number, 'I', sb);
}
break;
case '\u2460':
// circled digits
if (number == 0 || number > 20) {
return "" + number;
}
return "" + (char)(0x2460 + number);
case '\u2474':
// parenthesized digits
if (number == 0 || number > 20) {
return "" + number;
}
return "" + (char)(0x2474 + number);
case '\u2488':
// digit full stop
if (number == 0 || number > 20) {
return "" + number;
}
return "" + (char)(0x2488 + number);
case '\u0391':
if (number==0) {
return "0";
}
return toAlphaSequence(number, greekUpper);
case '\u03b1':
if (number==0) {
return "0";
}
return toAlphaSequence(number, greekLower);
case '\u0410':
if (number==0) {
return "0";
}
return toAlphaSequence(number, cyrillicUpper);
case '\u0430':
if (number==0) {
return "0";
}
return toAlphaSequence(number, cyrillicLower);
case '\u05d0':
if (number==0) {
return "0";
}
return toAlphaSequence(number, hebrew);
case '\u3042':
if (number==0) {
return "0";
}
return toAlphaSequence(number, hiraganaA);
case '\u30a2':
if (number==0) {
return "0";
}
return toAlphaSequence(number, katakanaA);
case '\u3044':
if (number==0) {
return "0";
}
return toAlphaSequence(number, hiraganaI);
case '\u30a4':
if (number==0) {
return "0";
}
return toAlphaSequence(number, katakanaI);
case '\u4e00':
if (number==0) {
return "0";
}
return toRadical(number, kanjiDigits, pictureLength, groupSize, groupSeparator);
default:
int digitValue = Alphanumeric.getDigitValue(formchar);
if (digitValue >= 0) {
int zero = formchar - digitValue;
int[] digits = new int[10];
for (int z=0; z<=9; z++) {
digits[z] = zero+z;
}
return toRadical(number, digits, pictureLength, groupSize, groupSeparator);
} else {
if (number==0) return "0";
if (formchar < '\u1100') {
alphaDefault(number, (char)formchar, sb);
} else {
// fallback to western numbering
return
toRadical(number, westernDigits, pictureLength, groupSize, groupSeparator);
}
break;
}
}
return sb.toString();
}