value = value.replace('\u00a0', ' ');
changed = true;
}
ParsePosition pp = new ParsePosition(0);
Number num = (Number)fmt.parseObject(value, pp);
// The following determines whether the percent/currency symbol was left off.
int typeIdx = _getType(pattern, type);
if (num == null && (typeIdx == _CURRENCY_TYPE || typeIdx == _PERCENT_TYPE))
{
// For parsing 'value' as a Number when the percent/currency symbol is left off.
NumberFormat nfmt = NumberFormat.getNumberInstance(locale);
DecimalFormat ndf = (DecimalFormat)nfmt;
ndf.setParseBigDecimal(true); // TODO What does this do?
DecimalFormatSymbols ndfs = null;
if (changed)
{
ndfs = ndf.getDecimalFormatSymbols();
ndfs.setGroupingSeparator(' ');
ndf.setDecimalFormatSymbols(ndfs);
}
// Assume the percent/currency symbol was left off, in which case we should
// be able to parse 'value' as a Number.
// An error occured, so the index of pp should still be 0.
num = (Number)nfmt.parseObject(value, pp);
if (typeIdx == _PERCENT_TYPE && num != null)
num = num.doubleValue() / 100.0;
}
// Change it back, since we could have been handed a cached reference. This
// may not be thread-safe, but it probably doesn't have to be.
if (changed)
{
dfs.setGroupingSeparator('\u00a0');
df.setDecimalFormatSymbols(dfs);
}
if (pp.getIndex() != value.length())
{
// According to the comments in
// trinidad-api\src\main\xrts\org\apache\myfaces\trinidad\resource\MessageBundle.xrts,
// the substitution parameters are supposed to be:
// {0} the label that identifies the component