1 |
/* DecimalFormat.java -- Formats and parses numbers |
/* DecimalFormat.java -- Formats and parses numbers |
2 |
Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc. |
Copyright (C) 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
62 |
{ |
{ |
63 |
// This is a helper for applyPatternWithSymbols. It reads a prefix |
// This is a helper for applyPatternWithSymbols. It reads a prefix |
64 |
// or a suffix. It can cause some side-effects. |
// or a suffix. It can cause some side-effects. |
65 |
private final int scanFix (String pattern, int index, FormatBuffer buf, |
private int scanFix (String pattern, int index, FormatBuffer buf, |
66 |
String patChars, DecimalFormatSymbols syms, |
String patChars, DecimalFormatSymbols syms, |
67 |
boolean is_suffix) |
boolean is_suffix) |
68 |
{ |
{ |
69 |
int len = pattern.length(); |
int len = pattern.length(); |
70 |
boolean quoteStarted = false; |
boolean quoteStarted = false; |
140 |
} |
} |
141 |
|
|
142 |
// A helper which reads a number format. |
// A helper which reads a number format. |
143 |
private final int scanFormat (String pattern, int index, |
private int scanFormat (String pattern, int index, String patChars, |
144 |
String patChars, DecimalFormatSymbols syms, |
DecimalFormatSymbols syms, boolean is_positive) |
|
boolean is_positive) |
|
145 |
{ |
{ |
146 |
int max = pattern.length(); |
int max = pattern.length(); |
147 |
|
|
293 |
|
|
294 |
// This helper function creates a string consisting of all the |
// This helper function creates a string consisting of all the |
295 |
// characters which can appear in a pattern and must be quoted. |
// characters which can appear in a pattern and must be quoted. |
296 |
private final String patternChars (DecimalFormatSymbols syms) |
private String patternChars (DecimalFormatSymbols syms) |
297 |
{ |
{ |
298 |
StringBuffer buf = new StringBuffer (); |
StringBuffer buf = new StringBuffer (); |
299 |
buf.append(syms.getDecimalSeparator()); |
buf.append(syms.getDecimalSeparator()); |
312 |
return buf.toString(); |
return buf.toString(); |
313 |
} |
} |
314 |
|
|
315 |
private final void applyPatternWithSymbols (String pattern, |
private void applyPatternWithSymbols(String pattern, DecimalFormatSymbols syms) |
|
DecimalFormatSymbols syms) |
|
316 |
{ |
{ |
317 |
// Initialize to the state the parser expects. |
// Initialize to the state the parser expects. |
318 |
negativePrefix = ""; |
negativePrefix = ""; |
423 |
applyPattern (pattern); |
applyPattern (pattern); |
424 |
} |
} |
425 |
|
|
426 |
private final boolean equals (String s1, String s2) |
private boolean equals(String s1, String s2) |
427 |
{ |
{ |
428 |
if (s1 == null || s2 == null) |
if (s1 == null || s2 == null) |
429 |
return s1 == s2; |
return s1 == s2; |
1147 |
positiveSuffix = newValue; |
positiveSuffix = newValue; |
1148 |
} |
} |
1149 |
|
|
1150 |
private final void quoteFix (StringBuffer buf, String text, String patChars) |
private void quoteFix(StringBuffer buf, String text, String patChars) |
1151 |
{ |
{ |
1152 |
int len = text.length(); |
int len = text.length(); |
1153 |
for (int index = 0; index < len; ++index) |
for (int index = 0; index < len; ++index) |
1164 |
} |
} |
1165 |
} |
} |
1166 |
|
|
1167 |
private final String computePattern (DecimalFormatSymbols syms) |
private String computePattern(DecimalFormatSymbols syms) |
1168 |
{ |
{ |
1169 |
StringBuffer mainPattern = new StringBuffer (); |
StringBuffer mainPattern = new StringBuffer (); |
1170 |
// We have to at least emit a zero for the minimum number of |
// We have to at least emit a zero for the minimum number of |