in trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/CoreFormat.js [947:1120]
function _decimalParse(
numberString,
message,
standardKey,
maxPrecision,
maxScale,
maxValue,
minValue,
label,
parsefloat,
ignoreLocaleSymbols
)
{
// The following are from the javadoc for TrNumberConverter
// If the specified String is null, return a null. Otherwise, trim leading and trailing whitespace before proceeding.
// If the specified String - after trimming - has a zero length, return null.
if (numberString == null)
return null;
numberString = TrFormatUtils.trim(numberString);
if (numberString.length == 0)
return null
var facesMessage = null;
// Get LocaleSymbols (from Locale.js)
var symbols = getLocaleSymbols();
if (symbols && (ignoreLocaleSymbols != true))
{
// We don't want leading or trailing grouping separators
var grouping = symbols.getGroupingSeparator();
if ((numberString.indexOf(grouping) == 0) ||
(numberString.lastIndexOf(grouping) == (numberString.length - 1)))
{
facesMessage = _createFacesMessage( standardKey+".CONVERT",
label,
numberString);
throw new TrConverterException(facesMessage);
}
if (grouping == "\xa0"){
var normalSpace = new RegExp("\\ " , "g");
numberString = numberString.replace(normalSpace, "\xa0");
}
// Remove the thousands separator - which Javascript doesn't want to see
//is this a i18n bug?...
//see TRINIDAD-2
var thousands = new RegExp("\\" + grouping, "g");
numberString = numberString.replace(thousands, "");
// Then change the decimal separator into a period, the only
// decimal separator allowed by JS
var decimal = new RegExp("\\" + symbols.getDecimalSeparator(), "g");
numberString = numberString.replace(decimal, ".");
// JIRA TRINIDAD-2219: When the string is a negative bidi number, e.g. "1-", the
//(numberString*numberString) and (numberString / numberString) return NaN
// and is unable to parse it so in Bidi, we check if the number is of the format "X-"
// and convert it to "-X" which Javascript can understands. .
var isLTR = document.documentElement["dir"].toUpperCase() == "LTR";
if(!isLTR)
{
var numberStringLength = numberString.length ;
if(numberString.lastIndexOf("-") == (numberStringLength - 1))
{
numberString = "-" + numberString.substring(0, numberStringLength - 1);
}
}//end of isLTR check
}
// OK; it's non-empty. Now, disallow exponential
// notation, and then use some JS magic to exclude
// non-numbers
if ((numberString.indexOf('e') < 0) &&
(numberString.indexOf('E') < 0) &&
(((numberString * numberString) == 0) ||
((numberString / numberString) == 1)))
{
var result = null;
var floater = false;
if (parsefloat != null)
{
// Why trim leading zeroes? parseFloat behaves the same way as the server NumberConverter,
// but parseInt interprets octal, and thus we need to trim leading zeroes.
// Note the following:
// parseInt interprets octal and hex:
// alert(parseInt("0xA")); // returns 10
// alert(parseInt("008")); // returns 0, as it stops parsing octal at the first invalid character, 8
// parseFloat interprets neither octal nor hex:
// alert(parseFloat("0xA")); // returns 0, as it stops parsing decimal at the first invalid character, x
// alert(parseFloat("008")); // returns 8
numberString = TrNumberFormat.trimLeadingZeroes(numberString);
result = parsefloat ? parseFloat(numberString) : parseInt(numberString);
}
else
{
result = parseInt(numberString);
if (Math.abs(result) < Math.abs(parseFloat(numberString)))
{
//a non-floating converter was the caller;
floater = true;
}
}
if (!floater && !isNaN(result))
{
var integerDigits = numberString.length;
var fractionDigits = 0;
var sepIndex = numberString.lastIndexOf('.');
if (sepIndex != -1)
{
integerDigits = sepIndex;
fractionDigits = parseInt(numberString.length - parseInt(sepIndex + 1));
}
var messageKey;
var rangeLimit;
//not true for float/double converter
if ((maxValue != null) &&
(result > maxValue))
{
messageKey = standardKey+".MAXIMUM";
rangeLimit = maxValue;
}
else if ((minValue != null) &&
(result < minValue))
{
messageKey = standardKey+".MINIMUM";
rangeLimit = minValue;
}
if (messageKey)
{
facesMessage = _createFacesMessage(messageKey,
label,
numberString,
""+rangeLimit);
throw new TrConverterException(facesMessage);
}
return result;
}
}
var usedKey = null;
var custom = false;
if(standardKey.indexOf("NumberConverter")==-1)
{
usedKey = standardKey+".CONVERT";
}
else
{
usedKey = standardKey+".CONVERT_NUMBER";
if(message && message["number"])
{
facesMessage = _createCustomFacesMessage(TrMessageFactory.getSummaryString(usedKey),
message["number"],
label,
numberString);
custom = true;
}
}
if(!custom)
{
facesMessage = _createFacesMessage( usedKey,
label,
numberString);
}
throw new TrConverterException(facesMessage);
}