Statements unnecessarily nested within else clauses.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1461559 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2013-03-27 13:04:25 +00:00
parent ef2c5e441e
commit ad43a49dab
1 changed files with 42 additions and 45 deletions

View File

@ -555,53 +555,50 @@ public class NumberUtils {
default :
throw new NumberFormatException(str + " is not a valid number.");
}
} else {
//User doesn't have a preference on the return type, so let's start
//small and go from there...
if (expPos > -1 && expPos < str.length() - 1) {
exp = str.substring(expPos + 1, str.length());
} else {
exp = null;
}
if (dec == null && exp == null) {
//Must be an int,long,bigint
try {
return createInteger(str);
} catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
try {
return createLong(str);
} catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
return createBigInteger(str);
} else {
//Must be a float,double,BigDec
final boolean allZeros = isAllZeros(mant) && isAllZeros(exp);
try {
final Float f = createFloat(str);
if (!(f.isInfinite() || (f.floatValue() == 0.0F && !allZeros))) {
return f;
}
} catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
try {
final Double d = createDouble(str);
if (!(d.isInfinite() || (d.doubleValue() == 0.0D && !allZeros))) {
return d;
}
} catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
return createBigDecimal(str);
}
}
//User doesn't have a preference on the return type, so let's start
//small and go from there...
if (expPos > -1 && expPos < str.length() - 1) {
exp = str.substring(expPos + 1, str.length());
} else {
exp = null;
}
if (dec == null && exp == null) {
//Must be an int,long,bigint
try {
return createInteger(str);
} catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
try {
return createLong(str);
} catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
return createBigInteger(str);
}
//Must be a float,double,BigDec
final boolean allZeros = isAllZeros(mant) && isAllZeros(exp);
try {
final Float f = createFloat(str);
if (!(f.isInfinite() || (f.floatValue() == 0.0F && !allZeros))) {
return f;
}
} catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
try {
final Double d = createDouble(str);
if (!(d.isInfinite() || (d.doubleValue() == 0.0D && !allZeros))) {
return d;
}
} catch (final NumberFormatException nfe) { // NOPMD
// ignore the bad number
}
return createBigDecimal(str);
}
/**