private final int scanFix (String pattern, int index, StringBuffer buf,
String patChars, DecimalFormatSymbols syms,
boolean is_suffix)
- throws ParseException
{
int len = pattern.length();
buf.setLength(0);
else if (is_suffix && c == syms.getPercent())
{
if (multiplierSet)
- throw new ParseException ("multiplier already set", index);
+ throw new IllegalArgumentException ("multiplier already set " +
+ "- index: " + index);
multiplierSet = true;
multiplier = 100;
buf.append(c);
else if (is_suffix && c == syms.getPerMill())
{
if (multiplierSet)
- throw new ParseException ("multiplier already set", index);
+ throw new IllegalArgumentException ("multiplier already set " +
+ "- index: " + index);
multiplierSet = true;
multiplier = 1000;
buf.append(c);
private final int scanFormat (String pattern, int index,
String patChars, DecimalFormatSymbols syms,
boolean is_positive)
- throws ParseException
{
int max = pattern.length();
if (c == syms.getDigit())
{
if (zeroCount > 0)
- throw new ParseException ("digit mark following zero", index);
+ throw new IllegalArgumentException ("digit mark following " +
+ "zero - index: " + index);
++countSinceGroup;
}
else if (c == syms.getZeroDigit())
if (c == syms.getZeroDigit())
{
if (hashCount > 0)
- throw new ParseException ("zero mark following digit",
- index);
+ throw new IllegalArgumentException ("zero mark " +
+ "following digit - index: " + index);
++zeroCount;
}
else if (c == syms.getDigit())
else if (c != syms.getExponential()
&& c != syms.getPatternSeparator()
&& patChars.indexOf(c) != -1)
- throw new ParseException ("unexpected special character",
- index);
+ throw new IllegalArgumentException ("unexpected special " +
+ "character - index: " + index);
else
break;
{
if (zeroCount > 0)
throw new
- ParseException ("digit mark following zero in exponent",
- index);
+ IllegalArgumentException ("digit mark following zero " +
+ "in exponent - index: " +
+ index);
}
else if (patChars.indexOf(c) != -1)
- throw new ParseException ("unexpected special character",
- index);
+ throw new IllegalArgumentException ("unexpected special " +
+ "character - index: " +
+ index);
else
break;
private final void applyPatternWithSymbols (String pattern,
DecimalFormatSymbols syms)
- throws ParseException
{
// Initialize to the state the parser expects.
negativePrefix = "";
else
{
if (pattern.charAt(index) != syms.getPatternSeparator())
- throw new ParseException ("separator character expected", index);
+ throw new IllegalArgumentException ("separator character " +
+ "expected - index: " + index);
index = scanFix (pattern, index + 1, buf, patChars, syms, false);
negativePrefix = buf.toString();
negativeSuffix = buf.toString();
if (index != pattern.length())
- throw new ParseException ("end of pattern expected", index);
+ throw new IllegalArgumentException ("end of pattern expected " +
+ "- index: " + index);
}
}
- public void applyLocalizedPattern (String pattern) throws ParseException
+ public void applyLocalizedPattern (String pattern)
{
+ // JCL p. 638 claims this throws a ParseException but p. 629
+ // contradicts this. Empirical tests with patterns of "0,###.0"
+ // and "#.#.#" corroborate the p. 629 statement that an
+ // IllegalArgumentException is thrown.
applyPatternWithSymbols (pattern, symbols);
}
- public void applyPattern (String pattern) throws ParseException
+ public void applyPattern (String pattern)
{
+ // JCL p. 638 claims this throws a ParseException but p. 629
+ // contradicts this. Empirical tests with patterns of "0,###.0"
+ // and "#.#.#" corroborate the p. 629 statement that an
+ // IllegalArgumentException is thrown.
applyPatternWithSymbols (pattern, nonLocalizedSymbols);
}
public DecimalFormat (String pattern, DecimalFormatSymbols symbols)
{
this.symbols = symbols;
- // The docs imply that the constructor turns a ParseException
- // into an IllegalArgumentException.
- try
- {
- applyPattern (pattern);
- }
- catch (ParseException x)
- {
- throw new IllegalArgumentException (x.getMessage());
- }
+ applyPattern (pattern);
}
private final boolean equals (String s1, String s2)