< prev index next >
src/java.base/share/classes/java/text/DecimalFormat.java
Print this page
rev 51919 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: dfuchs, alanb
*** 1070,1084 ****
fastPathData.fractionalScaleFactor = (isCurrencyFormat)
? 100.0d : 1000.0d;
// Records the need for adding prefix or suffix
fastPathData.positiveAffixesRequired
! = (positivePrefix.length() != 0)
! || (positiveSuffix.length() != 0);
fastPathData.negativeAffixesRequired
! = (negativePrefix.length() != 0)
! || (negativeSuffix.length() != 0);
// Creates a cached char container for result, with max possible size.
int maxNbIntegralDigits = 10;
int maxNbGroups = 3;
int containerSize
--- 1070,1082 ----
fastPathData.fractionalScaleFactor = (isCurrencyFormat)
? 100.0d : 1000.0d;
// Records the need for adding prefix or suffix
fastPathData.positiveAffixesRequired
! = !positivePrefix.isEmpty() || !positiveSuffix.isEmpty();
fastPathData.negativeAffixesRequired
! = !negativePrefix.isEmpty() || !negativeSuffix.isEmpty();
// Creates a cached char container for result, with max possible size.
int maxNbIntegralDigits = 10;
int maxNbGroups = 3;
int containerSize
*** 1988,1998 ****
FieldDelegate delegate,
FieldPosition[] positions,
Format.Field signAttribute) {
int start = result.length();
! if (string.length() > 0) {
result.append(string);
for (int counter = 0, max = positions.length; counter < max;
counter++) {
FieldPosition fp = positions[counter];
Format.Field attribute = fp.getFieldAttribute();
--- 1986,1996 ----
FieldDelegate delegate,
FieldPosition[] positions,
Format.Field signAttribute) {
int start = result.length();
! if (!string.isEmpty()) {
result.append(string);
for (int counter = 0, max = positions.length; counter < max;
counter++) {
FieldPosition fp = positions[counter];
Format.Field attribute = fp.getFieldAttribute();
*** 2943,2953 ****
++i;
string = symbols.getInternationalCurrencySymbol();
} else {
string = symbols.getCurrencySymbol();
}
! if (string.length() > 0) {
if (positions == null) {
positions = new ArrayList<>(2);
}
FieldPosition fp = new FieldPosition(Field.CURRENCY);
fp.setBeginIndex(stringIndex);
--- 2941,2951 ----
++i;
string = symbols.getInternationalCurrencySymbol();
} else {
string = symbols.getCurrencySymbol();
}
! if (!string.isEmpty()) {
if (positions == null) {
positions = new ArrayList<>(2);
}
FieldPosition fp = new FieldPosition(Field.CURRENCY);
fp.setBeginIndex(stringIndex);
*** 3514,3524 ****
negSuffixPattern = suffix.toString();
gotNegative = true;
}
}
! if (pattern.length() == 0) {
posPrefixPattern = posSuffixPattern = "";
setMinimumIntegerDigits(0);
setMaximumIntegerDigits(MAXIMUM_INTEGER_DIGITS);
setMinimumFractionDigits(0);
setMaximumFractionDigits(MAXIMUM_FRACTION_DIGITS);
--- 3512,3522 ----
negSuffixPattern = suffix.toString();
gotNegative = true;
}
}
! if (pattern.isEmpty()) {
posPrefixPattern = posSuffixPattern = "";
setMinimumIntegerDigits(0);
setMaximumIntegerDigits(MAXIMUM_INTEGER_DIGITS);
setMinimumFractionDigits(0);
setMaximumFractionDigits(MAXIMUM_FRACTION_DIGITS);
< prev index next >