ICU-7978 Add getDigitsLocal that returns reference to the digits directly

X-SVN-Rev: 28765
This commit is contained in:
John Emmons 2010-10-06 15:50:16 +00:00
parent 2d61714acc
commit 0b250fd02a
2 changed files with 19 additions and 2 deletions

View File

@ -1206,7 +1206,7 @@ public class DecimalFormat extends NumberFormat {
// }
int i;
char [] digits = symbols.getDigits();
char [] digits = symbols.getDigitsLocal();
char grouping = currencySignCount > 0 ? symbols.getMonetaryGroupingSeparator() :
symbols.getGroupingSeparator();
@ -2118,7 +2118,7 @@ public class DecimalFormat extends NumberFormat {
// DigitList, and adjust the exponent as needed.
digits.decimalAt = digits.count = 0;
char [] digitSymbols = symbols.getDigits();
char [] digitSymbols = symbols.getDigitsLocal();
char decimal = currencySignCount > 0 ? symbols.getMonetaryDecimalSeparator() : symbols
.getDecimalSeparator();
char grouping = symbols.getGroupingSeparator();

View File

@ -184,6 +184,23 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
return digitArray;
}
}
/**
* Returns the array of characters used as digits, in order from 0 through 9
* Package private method - don't need to defensively copy.
* @return The array
*/
char[] getDigitsLocal() {
if ( digits != null ) {
return digits;
} else {
char [] digitArray = new char[10];
for ( int i = 0 ; i < 10 ; i++ ) {
digitArray[i] = (char) (zeroDigit + i);
}
return digitArray;
}
}
/**
* Sets the character used for zero.