Skip to content

Commit 15033c1

Browse files
committed
Polish Javadoc for NumberUtils
1 parent c8d604b commit 15033c1

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

spring-core/src/main/java/org/springframework/util/NumberUtils.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
/**
2929
* Miscellaneous utility methods for number conversion and parsing.
30-
* Mainly for internal use within the framework; consider Apache's
31-
* Commons Lang for a more comprehensive suite of string utilities.
30+
* <p>Mainly for internal use within the framework; consider Apache's
31+
* Commons Lang for a more comprehensive suite of number utilities.
3232
*
3333
* @author Juergen Hoeller
3434
* @author Rob Harrop
@@ -144,25 +144,26 @@ else if (BigDecimal.class == targetClass) {
144144
}
145145
else {
146146
throw new IllegalArgumentException("Could not convert number [" + number + "] of type [" +
147-
number.getClass().getName() + "] to unknown target class [" + targetClass.getName() + "]");
147+
number.getClass().getName() + "] to unsupported target class [" + targetClass.getName() + "]");
148148
}
149149
}
150150

151151
/**
152-
* Raise an overflow exception for the given number and target class.
152+
* Raise an <em>overflow</em> exception for the given number and target class.
153153
* @param number the number we tried to convert
154154
* @param targetClass the target class we tried to convert to
155+
* @throws IllegalArgumentException
155156
*/
156157
private static void raiseOverflowException(Number number, Class<?> targetClass) {
157158
throw new IllegalArgumentException("Could not convert number [" + number + "] of type [" +
158159
number.getClass().getName() + "] to target class [" + targetClass.getName() + "]: overflow");
159160
}
160161

161162
/**
162-
* Parse the given text into a number instance of the given target class,
163-
* using the corresponding {@code decode} / {@code valueOf} methods.
163+
* Parse the given {@code text} into a {@link Number} instance of the given
164+
* target class, using the corresponding {@code decode} / {@code valueOf} method.
164165
* <p>Trims the input {@code String} before attempting to parse the number.
165-
* Supports numbers in hex format (with leading "0x", "0X" or "#") as well.
166+
* <p>Supports numbers in hex format (with leading "0x", "0X", or "#") as well.
166167
* @param text the text to convert
167168
* @param targetClass the target class to parse into
168169
* @return the parsed number
@@ -214,13 +215,13 @@ else if (BigDecimal.class == targetClass || Number.class == targetClass) {
214215
}
215216

216217
/**
217-
* Parse the given text into a number instance of the given target class,
218-
* using the given NumberFormat. Trims the input {@code String}
219-
* before attempting to parse the number.
218+
* Parse the given {@code text} into a {@link Number} instance of the
219+
* given target class, using the supplied {@link NumberFormat}.
220+
* <p>Trims the input {@code String} before attempting to parse the number.
220221
* @param text the text to convert
221222
* @param targetClass the target class to parse into
222-
* @param numberFormat the NumberFormat to use for parsing (if {@code null},
223-
* this method falls back to {@code parseNumber(String, Class)})
223+
* @param numberFormat the {@code NumberFormat} to use for parsing (if
224+
* {@code null}, this method falls back to {@link #parseNumber(String, Class)})
224225
* @return the parsed number
225226
* @throws IllegalArgumentException if the target class is not supported
226227
* (i.e. not a standard Number subclass as included in the JDK)
@@ -260,17 +261,18 @@ public static <T extends Number> T parseNumber(String text, Class<T> targetClass
260261
}
261262

262263
/**
263-
* Determine whether the given value String indicates a hex number, i.e. needs to be
264-
* passed into {@code Integer.decode} instead of {@code Integer.valueOf} (etc).
264+
* Determine whether the given {@code value} String indicates a hex number,
265+
* i.e. needs to be passed into {@code Integer.decode} instead of
266+
* {@code Integer.valueOf}, etc.
265267
*/
266268
private static boolean isHexNumber(String value) {
267269
int index = (value.startsWith("-") ? 1 : 0);
268270
return (value.startsWith("0x", index) || value.startsWith("0X", index) || value.startsWith("#", index));
269271
}
270272

271273
/**
272-
* Decode a {@link java.math.BigInteger} from a {@link String} value.
273-
* Supports decimal, hex and octal notation.
274+
* Decode a {@link java.math.BigInteger} from the supplied {@link String} value.
275+
* <p>Supports decimal, hex, and octal notation.
274276
* @see BigInteger#BigInteger(String, int)
275277
*/
276278
private static BigInteger decodeBigInteger(String value) {

0 commit comments

Comments
 (0)