summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMario Torre <neugens@limasoftware.net>2006-11-29 16:51:13 +0000
committerMario Torre <neugens@limasoftware.net>2006-11-29 16:51:13 +0000
commitbdbe9b9a423fa7c1ddabe4cf6dae0b07d181250d (patch)
treedc52d5d326b160e5599882eedb702b298880e2d7
parent5cd42793966e2ab10dab52ac101eced8294dbf32 (diff)
downloadclasspath-bdbe9b9a423fa7c1ddabe4cf6dae0b07d181250d.tar.gz
2006-11-29 Mario Torre <neugens@limasoftware.net>
* java/text/NumberFormat.java (getCurrencyInstance): Replaced dollar sign with the default international currency sign \u00A4. * java/text/DecimalFormat.java (scanFix): Fix to use the localized symbol table for string formatting. (formatInternal): likewise. (scanNegativePattern): likewise. (applyPattern): likewise. * java/text/DecimalFormatSymbols.java (clone): Revert to old version as Locale is immutable and does not need clone.
-rw-r--r--ChangeLog12
-rw-r--r--java/text/DecimalFormat.java76
-rw-r--r--java/text/DecimalFormatSymbols.java4
-rw-r--r--java/text/NumberFormat.java2
4 files changed, 54 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index f04ecd4b3..ca0507673 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-11-29 Mario Torre <neugens@limasoftware.net>
+
+ * java/text/NumberFormat.java (getCurrencyInstance): Replaced dollar sign
+ with the default international currency sign \u00A4.
+ * java/text/DecimalFormat.java (scanFix): Fix to use the localized symbol
+ table for string formatting.
+ (formatInternal): likewise.
+ (scanNegativePattern): likewise.
+ (applyPattern): likewise.
+ * java/text/DecimalFormatSymbols.java (clone): Revert to old version as
+ Locale is immutable and does not need clone.
+
2006-11-29 Francis Kung <fkung@redhat.com>
* gnu/java/awt/peer/gtk/CairoGraphics2D.java
diff --git a/java/text/DecimalFormat.java b/java/text/DecimalFormat.java
index cbccb4ca3..3b67a50da 100644
--- a/java/text/DecimalFormat.java
+++ b/java/text/DecimalFormat.java
@@ -228,7 +228,7 @@ public class DecimalFormat extends NumberFormat
}
/**
- * Apply the given localized patern to the current DecimalFormat object.
+ * Apply the given localized pattern to the current DecimalFormat object.
*
* @param pattern The localized pattern to apply.
* @throws IllegalArgumentException if the given pattern is invalid.
@@ -1209,25 +1209,25 @@ public class DecimalFormat extends NumberFormat
* @param pattern The pattern string to parse.
* @return The position in the pattern string where parsing ended.
*/
- private int scanFix(String pattern, DecimalFormatSymbols symbols,
+ private int scanFix(String pattern, DecimalFormatSymbols sourceSymbols,
int start, boolean prefix)
{
StringBuffer buffer = new StringBuffer();
// the number portion is always delimited by one of those
// characters
- char decimalSeparator = symbols.getDecimalSeparator();
- char patternSeparator = symbols.getPatternSeparator();
- char groupingSeparator = symbols.getGroupingSeparator();
- char digit = symbols.getDigit();
- char zero = symbols.getZeroDigit();
- char minus = symbols.getMinusSign();
+ char decimalSeparator = sourceSymbols.getDecimalSeparator();
+ char patternSeparator = sourceSymbols.getPatternSeparator();
+ char groupingSeparator = sourceSymbols.getGroupingSeparator();
+ char digit = sourceSymbols.getDigit();
+ char zero = sourceSymbols.getZeroDigit();
+ char minus = sourceSymbols.getMinusSign();
// other special characters, cached here to avoid method calls later
- char percent = symbols.getPercent();
- char permille = symbols.getPerMill();
+ char percent = sourceSymbols.getPercent();
+ char permille = sourceSymbols.getPerMill();
- String currencySymbol = symbols.getCurrencySymbol();
+ String currencySymbol = this.symbols.getCurrencySymbol();
boolean quote = false;
@@ -1280,12 +1280,12 @@ public class DecimalFormat extends NumberFormat
if (ch == '\u00A4')
{
// CURRENCY
- currencySymbol = symbols.getCurrencySymbol();
+ currencySymbol = this.symbols.getCurrencySymbol();
// if \u00A4 is doubled, we use the international currency symbol
if (i < len && pattern.charAt(i + 1) == '\u00A4')
{
- currencySymbol = symbols.getInternationalCurrencySymbol();
+ currencySymbol = this.symbols.getInternationalCurrencySymbol();
i++;
}
@@ -1296,13 +1296,13 @@ public class DecimalFormat extends NumberFormat
{
// PERCENT
this.multiplier = 100;
- buffer.append(ch);
+ buffer.append(this.symbols.getPercent());
}
else if (ch == permille)
{
// PERMILLE
this.multiplier = 1000;
- buffer.append(ch);
+ buffer.append(this.symbols.getPerMill());
}
else if (ch == '\'')
{
@@ -1582,25 +1582,26 @@ public class DecimalFormat extends NumberFormat
* @param pattern The pattern string to parse.
* @param start The starting parse position in the string.
*/
- private void scanNegativePattern(String pattern, DecimalFormatSymbols symbols,
+ private void scanNegativePattern(String pattern,
+ DecimalFormatSymbols sourceSymbols,
int start)
{
StringBuffer buffer = new StringBuffer();
// the number portion is always delimited by one of those
// characters
- char decimalSeparator = symbols.getDecimalSeparator();
- char patternSeparator = symbols.getPatternSeparator();
- char groupingSeparator = symbols.getGroupingSeparator();
- char digit = symbols.getDigit();
- char zero = symbols.getZeroDigit();
- char minus = symbols.getMinusSign();
+ char decimalSeparator = sourceSymbols.getDecimalSeparator();
+ char patternSeparator = sourceSymbols.getPatternSeparator();
+ char groupingSeparator = sourceSymbols.getGroupingSeparator();
+ char digit = sourceSymbols.getDigit();
+ char zero = sourceSymbols.getZeroDigit();
+ char minus = sourceSymbols.getMinusSign();
// other special charcaters, cached here to avoid method calls later
- char percent = symbols.getPercent();
- char permille = symbols.getPerMill();
+ char percent = sourceSymbols.getPercent();
+ char permille = sourceSymbols.getPerMill();
- String CURRENCY_SYMBOL = symbols.getCurrencySymbol();
+ String CURRENCY_SYMBOL = this.symbols.getCurrencySymbol();
String currencySymbol = CURRENCY_SYMBOL;
boolean quote = false;
@@ -1638,7 +1639,7 @@ public class DecimalFormat extends NumberFormat
}
else if (ch == minus)
{
- buffer.append(ch);
+ buffer.append(this.symbols.getMinusSign());
}
else if (quote && ch != '\'')
{
@@ -1652,7 +1653,7 @@ public class DecimalFormat extends NumberFormat
// if \u00A4 is doubled, we use the international currency symbol
if ((i + 1) < len && pattern.charAt(i + 1) == '\u00A4')
{
- currencySymbol = symbols.getInternationalCurrencySymbol();
+ currencySymbol = this.symbols.getInternationalCurrencySymbol();
i = i + 2;
}
@@ -1667,13 +1668,13 @@ public class DecimalFormat extends NumberFormat
{
// PERCENT
this.negativePatternMultiplier = 100;
- buffer.append(ch);
+ buffer.append(this.symbols.getPercent());
}
else if (ch == permille)
{
// PERMILLE
this.negativePatternMultiplier = 1000;
- buffer.append(ch);
+ buffer.append(this.symbols.getPerMill());
}
else if (ch == '\'')
{
@@ -1727,7 +1728,7 @@ public class DecimalFormat extends NumberFormat
*/
private void formatInternal(BigDecimal number, boolean isLong,
StringBuffer dest, FieldPosition fieldPos)
- {
+ {
// The specs says that fieldPos should not be null, and that we
// should throw a NPE, but it seems that in few classes that
// reference this one, fieldPos is set to null.
@@ -1735,7 +1736,7 @@ public class DecimalFormat extends NumberFormat
// I think the best here is to check for fieldPos and build one if it is
// null. If it cause harms or regressions, just remove this line and
// fix the classes in the point of call, insted.
- if (fieldPos == null) fieldPos = new FieldPosition(0);
+ if (fieldPos == null) fieldPos = new FieldPosition(0);
int _multiplier = this.multiplier;
@@ -1895,7 +1896,8 @@ public class DecimalFormat extends NumberFormat
if (this.decimalSeparatorAlwaysShown ||
((!isLong || this.useExponentialNotation)
&& this.showDecimalSeparator &&
- this.maximumFractionDigits > 0))
+ this.maximumFractionDigits > 0) ||
+ this.minimumFractionDigits > 0)
{
attributeStart = dest.length();
@@ -1910,7 +1912,8 @@ public class DecimalFormat extends NumberFormat
// now handle the fraction portion of the number
if ((!isLong || this.useExponentialNotation)
- && this.maximumFractionDigits > 0)
+ && this.maximumFractionDigits > 0
+ || this.minimumFractionDigits > 0)
{
attributeStart = dest.length();
beginIndexFract = attributeStart;
@@ -1936,8 +1939,8 @@ public class DecimalFormat extends NumberFormat
if (fracts[i] != '0')
allZeros = false;
}
-
- if (!allZeros || minimumFractionDigits > 0)
+
+ if (!allZeros || (minimumFractionDigits > 0))
{
appendDigit(fractPart, dest, false);
endIndexFract = dest.length();
@@ -1949,6 +1952,7 @@ public class DecimalFormat extends NumberFormat
}
else
{
+ System.out.println("ayeeeee!");
endIndexFract = dest.length();
addAttribute(Field.FRACTION, attributeStart, endIndexFract);
}
@@ -2009,7 +2013,7 @@ public class DecimalFormat extends NumberFormat
{
fieldPos.setBeginIndex(beginIndexFract);
fieldPos.setEndIndex(endIndexFract);
- }
+ }
}
/**
diff --git a/java/text/DecimalFormatSymbols.java b/java/text/DecimalFormatSymbols.java
index 6b92d9c38..e4a14a7e3 100644
--- a/java/text/DecimalFormatSymbols.java
+++ b/java/text/DecimalFormatSymbols.java
@@ -69,9 +69,7 @@ public final class DecimalFormatSymbols implements Cloneable, Serializable
{
try
{
- DecimalFormatSymbols c = (DecimalFormatSymbols) super.clone();
- c.locale = (Locale) locale.clone ();
- return c;
+ return super.clone();
}
catch(CloneNotSupportedException e)
{
diff --git a/java/text/NumberFormat.java b/java/text/NumberFormat.java
index 48aab5965..1fd71bf04 100644
--- a/java/text/NumberFormat.java
+++ b/java/text/NumberFormat.java
@@ -351,7 +351,7 @@ public abstract class NumberFormat extends Format implements Cloneable
{
NumberFormat format;
- format = computeInstance (loc, "currencyFormat", "$#,##0.00;($#,##0.00)");
+ format = computeInstance (loc, "currencyFormat", "\u00A4#,##0.00;(\u00A4#,##0.00)");
format.setMaximumFractionDigits(format.getCurrency().getDefaultFractionDigits());
return format;
}