|
27 | 27 |
|
28 | 28 | /** |
29 | 29 | * 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. |
32 | 32 | * |
33 | 33 | * @author Juergen Hoeller |
34 | 34 | * @author Rob Harrop |
@@ -144,25 +144,26 @@ else if (BigDecimal.class == targetClass) { |
144 | 144 | } |
145 | 145 | else { |
146 | 146 | 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() + "]"); |
148 | 148 | } |
149 | 149 | } |
150 | 150 |
|
151 | 151 | /** |
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. |
153 | 153 | * @param number the number we tried to convert |
154 | 154 | * @param targetClass the target class we tried to convert to |
| 155 | + * @throws IllegalArgumentException |
155 | 156 | */ |
156 | 157 | private static void raiseOverflowException(Number number, Class<?> targetClass) { |
157 | 158 | throw new IllegalArgumentException("Could not convert number [" + number + "] of type [" + |
158 | 159 | number.getClass().getName() + "] to target class [" + targetClass.getName() + "]: overflow"); |
159 | 160 | } |
160 | 161 |
|
161 | 162 | /** |
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. |
164 | 165 | * <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. |
166 | 167 | * @param text the text to convert |
167 | 168 | * @param targetClass the target class to parse into |
168 | 169 | * @return the parsed number |
@@ -214,13 +215,13 @@ else if (BigDecimal.class == targetClass || Number.class == targetClass) { |
214 | 215 | } |
215 | 216 |
|
216 | 217 | /** |
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. |
220 | 221 | * @param text the text to convert |
221 | 222 | * @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)}) |
224 | 225 | * @return the parsed number |
225 | 226 | * @throws IllegalArgumentException if the target class is not supported |
226 | 227 | * (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 |
260 | 261 | } |
261 | 262 |
|
262 | 263 | /** |
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. |
265 | 267 | */ |
266 | 268 | private static boolean isHexNumber(String value) { |
267 | 269 | int index = (value.startsWith("-") ? 1 : 0); |
268 | 270 | return (value.startsWith("0x", index) || value.startsWith("0X", index) || value.startsWith("#", index)); |
269 | 271 | } |
270 | 272 |
|
271 | 273 | /** |
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. |
274 | 276 | * @see BigInteger#BigInteger(String, int) |
275 | 277 | */ |
276 | 278 | private static BigInteger decodeBigInteger(String value) { |
|
0 commit comments