This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-beanutils.git
The following commit(s) were added to refs/heads/master by this push:
new 12506654 Javadoc
12506654 is described below
commit 12506654c9eace477fd6f0ae8ebfa39b619c9662
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Jul 2 19:46:47 2026 +0000
Javadoc
---
.../converters/BigDecimalLocaleConverter.java | 14 ++++-----
.../converters/BigIntegerLocaleConverter.java | 15 ++++------
.../locale/converters/ByteLocaleConverter.java | 11 ++++---
.../locale/converters/DateLocaleConverter.java | 34 +++++++---------------
.../locale/converters/DecimalLocaleConverter.java | 18 +++++-------
.../locale/converters/DoubleLocaleConverter.java | 11 ++++---
.../locale/converters/FloatLocaleConverter.java | 11 ++++---
.../locale/converters/IntegerLocaleConverter.java | 11 ++++---
.../locale/converters/LongLocaleConverter.java | 14 ++++-----
.../locale/converters/ShortLocaleConverter.java | 15 ++++------
.../locale/converters/StringLocaleConverter.java | 25 +++++++---------
11 files changed, 67 insertions(+), 112 deletions(-)
diff --git
a/src/main/java/org/apache/commons/beanutils2/locale/converters/BigDecimalLocaleConverter.java
b/src/main/java/org/apache/commons/beanutils2/locale/converters/BigDecimalLocaleConverter.java
index a54ece4d..31956fca 100644
---
a/src/main/java/org/apache/commons/beanutils2/locale/converters/BigDecimalLocaleConverter.java
+++
b/src/main/java/org/apache/commons/beanutils2/locale/converters/BigDecimalLocaleConverter.java
@@ -46,7 +46,6 @@ public class BigDecimalLocaleConverter extends
DecimalLocaleConverter<BigDecimal
public BigDecimalLocaleConverter get() {
return new BigDecimalLocaleConverter(defaultValue, locale,
pattern, useDefault || defaultValue != null, localizedPattern);
}
-
}
/**
@@ -66,21 +65,19 @@ public class BigDecimalLocaleConverter extends
DecimalLocaleConverter<BigDecimal
/**
* Parses the specified locale-sensitive input object into an output
object of BigDecimal type.
*
- * @param value The input object to be converted
- * @param pattern The pattern is used for the conversion
- * @return The converted value
- * @throws ConversionException if conversion cannot be performed
successfully
- * @throws ParseException if an error occurs parsing a String to a
Number
+ * @param value The input object to be converted.
+ * @param pattern The pattern is used for the conversion.
+ * @return The converted value.
+ * @throws ConversionException if conversion cannot be performed
successfully.
+ * @throws ParseException if an error occurs parsing a String to a
Number.
* @since 1.8.0
*/
@Override
protected BigDecimal parse(final Object value, final String pattern)
throws ParseException {
final Number result = super.parse(value, pattern);
-
if (result == null || result instanceof BigDecimal) {
return (BigDecimal) result;
}
-
try {
return new BigDecimal(result.toString());
} catch (final NumberFormatException ex) {
@@ -92,5 +89,4 @@ public class BigDecimalLocaleConverter extends
DecimalLocaleConverter<BigDecimal
protected boolean isParseBigDecimal() {
return true;
}
-
}
diff --git
a/src/main/java/org/apache/commons/beanutils2/locale/converters/BigIntegerLocaleConverter.java
b/src/main/java/org/apache/commons/beanutils2/locale/converters/BigIntegerLocaleConverter.java
index ded930f7..41dc4a47 100644
---
a/src/main/java/org/apache/commons/beanutils2/locale/converters/BigIntegerLocaleConverter.java
+++
b/src/main/java/org/apache/commons/beanutils2/locale/converters/BigIntegerLocaleConverter.java
@@ -47,7 +47,6 @@ public class BigIntegerLocaleConverter extends
DecimalLocaleConverter<BigInteger
public BigIntegerLocaleConverter get() {
return new BigIntegerLocaleConverter(defaultValue, locale,
pattern, useDefault || defaultValue != null, localizedPattern);
}
-
}
/**
@@ -67,25 +66,22 @@ public class BigIntegerLocaleConverter extends
DecimalLocaleConverter<BigInteger
/**
* Parses the specified locale-sensitive input object into an output
object of BigInteger type.
*
- * @param value The input object to be converted
- * @param pattern The pattern is used for the conversion
- * @return The converted value
- * @throws ConversionException if conversion cannot be performed
successfully
- * @throws ParseException if an error occurs parsing a String to a
Number
+ * @param value The input object to be converted.
+ * @param pattern The pattern is used for the conversion.
+ * @return The converted value.
+ * @throws ConversionException if conversion cannot be performed
successfully.
+ * @throws ParseException if an error occurs parsing a String to a
Number.
* @since 1.8.0
*/
@Override
protected BigInteger parse(final Object value, final String pattern)
throws ParseException {
final Number result = super.parse(value, pattern);
-
if (result == null || result instanceof BigInteger) {
return (BigInteger) result;
}
-
if (result instanceof BigDecimal) {
return ((BigDecimal) result).toBigInteger();
}
-
return BigInteger.valueOf(result.longValue());
}
@@ -93,5 +89,4 @@ public class BigIntegerLocaleConverter extends
DecimalLocaleConverter<BigInteger
protected boolean isParseBigDecimal() {
return true;
}
-
}
diff --git
a/src/main/java/org/apache/commons/beanutils2/locale/converters/ByteLocaleConverter.java
b/src/main/java/org/apache/commons/beanutils2/locale/converters/ByteLocaleConverter.java
index a9b58579..9119629f 100644
---
a/src/main/java/org/apache/commons/beanutils2/locale/converters/ByteLocaleConverter.java
+++
b/src/main/java/org/apache/commons/beanutils2/locale/converters/ByteLocaleConverter.java
@@ -44,7 +44,6 @@ public class ByteLocaleConverter extends
DecimalLocaleConverter<Byte> {
public ByteLocaleConverter get() {
return new ByteLocaleConverter(defaultValue, locale, pattern,
useDefault || defaultValue != null, localizedPattern);
}
-
}
/**
@@ -63,11 +62,11 @@ public class ByteLocaleConverter extends
DecimalLocaleConverter<Byte> {
/**
* Parses the specified locale-sensitive input object into an output
object of the specified type. This method will return values of type Byte.
*
- * @param value The input object to be converted
- * @param pattern The pattern is used for the conversion
- * @return The converted value
- * @throws ConversionException if conversion cannot be performed
successfully
- * @throws ParseException if an error occurs parsing a String to a
Number
+ * @param value The input object to be converted.
+ * @param pattern The pattern is used for the conversion.
+ * @return The converted value.
+ * @throws ConversionException if conversion cannot be performed
successfully.
+ * @throws ParseException if an error occurs parsing a String to a
Number.
*/
@Override
protected Byte parse(final Object value, final String pattern) throws
ParseException {
diff --git
a/src/main/java/org/apache/commons/beanutils2/locale/converters/DateLocaleConverter.java
b/src/main/java/org/apache/commons/beanutils2/locale/converters/DateLocaleConverter.java
index 4cfdbfd0..7cf1a5ff 100644
---
a/src/main/java/org/apache/commons/beanutils2/locale/converters/DateLocaleConverter.java
+++
b/src/main/java/org/apache/commons/beanutils2/locale/converters/DateLocaleConverter.java
@@ -76,7 +76,7 @@ public class DateLocaleConverter<D extends Date> extends
BaseLocaleConverter<D>
/**
* Tests whether date formatting is lenient.
*
- * @return true if the {@code DateFormat} used for formatting is
lenient
+ * @return true if the {@code DateFormat} used for formatting is
lenient.
* @see java.text.DateFormat#isLenient()
*/
public boolean isLenient() {
@@ -93,7 +93,6 @@ public class DateLocaleConverter<D extends Date> extends
BaseLocaleConverter<D>
this.lenient = lenient;
return asThis();
}
-
}
/**
@@ -146,27 +145,23 @@ public class DateLocaleConverter<D extends Date> extends
BaseLocaleConverter<D>
/**
* Converts a pattern from a localized format to the default format.
*
- * @param locale The locale
- * @param localizedPattern The pattern in 'local' symbol format
- * @return pattern in 'default' symbol format
+ * @param locale The locale.
+ * @param localizedPattern The pattern in 'local' symbol format.
+ * @return pattern in 'default' symbol format.
*/
private String convertLocalizedPattern(final String localizedPattern,
final Locale locale) {
if (localizedPattern == null) {
return null;
}
-
// Note that this is a little obtuse.
// However, it is the best way that anyone can come up with
// that works with some 1.4 series JVM.
-
// Get the symbols for the localized pattern
final DateFormatSymbols localizedSymbols = new
DateFormatSymbols(locale);
final String localChars = localizedSymbols.getLocalPatternChars();
-
if (DEFAULT_PATTERN_CHARS.equals(localChars)) {
return localizedPattern;
}
-
// Convert the localized pattern to default
String convertedPattern = null;
try {
@@ -185,7 +180,6 @@ public class DateLocaleConverter<D extends Date> extends
BaseLocaleConverter<D>
private String convertPattern(final String pattern, final String
fromChars, final String toChars) {
final StringBuilder converted = new StringBuilder();
boolean quoted = false;
-
for (int i = 0; i < pattern.length(); ++i) {
char thisChar = pattern.charAt(i);
if (quoted) {
@@ -203,18 +197,16 @@ public class DateLocaleConverter<D extends Date> extends
BaseLocaleConverter<D>
}
converted.append(thisChar);
}
-
if (quoted) {
throw new IllegalArgumentException("Unfinished quote in pattern");
}
-
return converted.toString();
}
/**
* Tests whether date formatting is lenient.
*
- * @return true if the {@code DateFormat} used for formatting is lenient
+ * @return true if the {@code DateFormat} used for formatting is lenient.
* @see java.text.DateFormat#isLenient()
*/
public boolean isLenient() {
@@ -224,11 +216,11 @@ public class DateLocaleConverter<D extends Date> extends
BaseLocaleConverter<D>
/**
* Convert the specified locale-sensitive input object into an output
object of the specified type.
*
- * @param value The input object to be converted
- * @param pattern The pattern is used for the conversion
- * @return the converted Date value
- * @throws ConversionException if conversion cannot be performed
successfully
- * @throws ParseException if an error occurs parsing
+ * @param value The input object to be converted.
+ * @param pattern The pattern is used for the conversion.
+ * @return the converted Date value.
+ * @throws ConversionException if conversion cannot be performed
successfully.
+ * @throws ParseException if an error occurs parsing.
*/
@Override
protected D parse(final Object value, String pattern) throws
ParseException {
@@ -236,20 +228,16 @@ public class DateLocaleConverter<D extends Date> extends
BaseLocaleConverter<D>
if (value instanceof Date) {
return (D) value;
}
-
// Handle Calendar
if (value instanceof Calendar) {
return (D) ((Calendar) value).getTime();
}
-
if (localizedPattern) {
pattern = convertLocalizedPattern(pattern, locale);
}
-
// Create Formatter - use default if pattern is null
final DateFormat formatter = pattern == null ?
DateFormat.getDateInstance(DateFormat.SHORT, locale) : new
SimpleDateFormat(pattern, locale);
formatter.setLenient(isLenient);
-
// Parse the Date
final ParsePosition pos = new ParsePosition(0);
final String strValue = value.toString();
@@ -260,8 +248,6 @@ public class DateLocaleConverter<D extends Date> extends
BaseLocaleConverter<D>
if (pos.getIndex() < strValue.length()) {
throw ConversionException.format("Date '%s' contains unparsed
characters from position = %s", value, pos.getIndex());
}
-
return (D) parsedValue;
}
-
}
diff --git
a/src/main/java/org/apache/commons/beanutils2/locale/converters/DecimalLocaleConverter.java
b/src/main/java/org/apache/commons/beanutils2/locale/converters/DecimalLocaleConverter.java
index 31834c0c..bdce9a89 100644
---
a/src/main/java/org/apache/commons/beanutils2/locale/converters/DecimalLocaleConverter.java
+++
b/src/main/java/org/apache/commons/beanutils2/locale/converters/DecimalLocaleConverter.java
@@ -66,7 +66,6 @@ public class DecimalLocaleConverter<T extends Number> extends
BaseLocaleConverte
public DecimalLocaleConverter<?> get() {
return new DecimalLocaleConverter<>(defaultValue, locale, pattern,
useDefault || defaultValue != null, localizedPattern);
}
-
}
/** All logging goes through this logger */
@@ -99,8 +98,8 @@ public class DecimalLocaleConverter<T extends Number> extends
BaseLocaleConverte
/**
* Tests whether the underlying {@link DecimalFormat} should parse into a
{@link java.math.BigDecimal} so that magnitude and precision are preserved.
- * Subclasses that build {@link java.math.BigInteger} or {@link
java.math.BigDecimal} values override this to return {@code true}; the narrowing
- * converters keep the default {@code Long} / {@code Double} result.
+ * Subclasses that build {@link java.math.BigInteger} or {@link
java.math.BigDecimal} values override this to return {@code true}; the
narrowing converters
+ * keep the default {@code Long} / {@code Double} result.
*
* @return {@code true} to parse into a {@link java.math.BigDecimal},
{@code false} otherwise.
*/
@@ -111,25 +110,23 @@ public class DecimalLocaleConverter<T extends Number>
extends BaseLocaleConverte
/**
* Converts the specified locale-sensitive input object into an output
object of the specified type.
*
- * @param value The input object to be converted
- * @param pattern The pattern is used for the conversion
- * @return The converted value
- * @throws ConversionException if conversion cannot be performed
successfully
- * @throws ParseException if an error occurs parsing a String to a
Number
+ * @param value The input object to be converted.
+ * @param pattern The pattern is used for the conversion.
+ * @return The converted value.
+ * @throws ConversionException if conversion cannot be performed
successfully.
+ * @throws ParseException if an error occurs parsing a String to a
Number.
*/
@Override
protected T parse(final Object value, final String pattern) throws
ParseException {
if (value instanceof Number) {
return (T) value;
}
-
// Note that despite the ambiguous "getInstance" name, and despite the
// fact that objects returned from this method have the same toString
// representation, each call to getInstance actually returns a new
// object.
final DecimalFormat formatter = (DecimalFormat)
NumberFormat.getInstance(locale);
formatter.setParseBigDecimal(isParseBigDecimal());
-
// if some constructors default pattern to null, it makes only sense
// to handle null pattern gracefully
if (pattern != null) {
@@ -141,7 +138,6 @@ public class DecimalLocaleConverter<T extends Number>
extends BaseLocaleConverte
} else {
LOG.debug("No pattern provided, using default.");
}
-
final String strValue = (String) value;
final ParsePosition pos = new ParsePosition(0);
final Number parsed = formatter.parse(strValue, pos);
diff --git
a/src/main/java/org/apache/commons/beanutils2/locale/converters/DoubleLocaleConverter.java
b/src/main/java/org/apache/commons/beanutils2/locale/converters/DoubleLocaleConverter.java
index 14686de1..4276c600 100644
---
a/src/main/java/org/apache/commons/beanutils2/locale/converters/DoubleLocaleConverter.java
+++
b/src/main/java/org/apache/commons/beanutils2/locale/converters/DoubleLocaleConverter.java
@@ -44,7 +44,6 @@ public class DoubleLocaleConverter extends
DecimalLocaleConverter<Double> {
public DoubleLocaleConverter get() {
return new DoubleLocaleConverter(defaultValue, locale, pattern,
useDefault || defaultValue != null, localizedPattern);
}
-
}
/**
@@ -63,11 +62,11 @@ public class DoubleLocaleConverter extends
DecimalLocaleConverter<Double> {
/**
* Parses the specified locale-sensitive input object into an output
object of the specified type. This method will return Double type.
*
- * @param value The input object to be converted
- * @param pattern The pattern is used for the conversion
- * @return The converted value
- * @throws ConversionException if conversion cannot be performed
successfully
- * @throws ParseException if an error occurs parsing a String to a
Number
+ * @param value The input object to be converted.
+ * @param pattern The pattern is used for the conversion.
+ * @return The converted value.
+ * @throws ConversionException if conversion cannot be performed
successfully.
+ * @throws ParseException if an error occurs parsing a String to a
Number.
*/
@Override
protected Double parse(final Object value, final String pattern) throws
ParseException {
diff --git
a/src/main/java/org/apache/commons/beanutils2/locale/converters/FloatLocaleConverter.java
b/src/main/java/org/apache/commons/beanutils2/locale/converters/FloatLocaleConverter.java
index 09d07553..2d34be2c 100644
---
a/src/main/java/org/apache/commons/beanutils2/locale/converters/FloatLocaleConverter.java
+++
b/src/main/java/org/apache/commons/beanutils2/locale/converters/FloatLocaleConverter.java
@@ -45,7 +45,6 @@ public class FloatLocaleConverter extends
DecimalLocaleConverter<Float> {
public FloatLocaleConverter get() {
return new FloatLocaleConverter(defaultValue, locale, pattern,
useDefault || defaultValue != null, localizedPattern);
}
-
}
/**
@@ -65,11 +64,11 @@ public class FloatLocaleConverter extends
DecimalLocaleConverter<Float> {
* Parses the specified locale-sensitive input object into an output
object of the specified type. This method will return Float value or throw
exception if
* value cannot be stored in the Float.
*
- * @param value The input object to be converted
- * @param pattern The pattern is used for the conversion
- * @return The converted value
- * @throws ConversionException if conversion cannot be performed
successfully
- * @throws ParseException if an error occurs parsing a String to a
Number
+ * @param value The input object to be converted.
+ * @param pattern The pattern is used for the conversion.
+ * @return The converted value.
+ * @throws ConversionException if conversion cannot be performed
successfully.
+ * @throws ParseException if an error occurs parsing a String to a
Number.
*/
@Override
protected Float parse(final Object value, final String pattern) throws
ParseException {
diff --git
a/src/main/java/org/apache/commons/beanutils2/locale/converters/IntegerLocaleConverter.java
b/src/main/java/org/apache/commons/beanutils2/locale/converters/IntegerLocaleConverter.java
index e88729a3..e805e492 100644
---
a/src/main/java/org/apache/commons/beanutils2/locale/converters/IntegerLocaleConverter.java
+++
b/src/main/java/org/apache/commons/beanutils2/locale/converters/IntegerLocaleConverter.java
@@ -44,7 +44,6 @@ public class IntegerLocaleConverter extends
DecimalLocaleConverter<Integer> {
public IntegerLocaleConverter get() {
return new IntegerLocaleConverter(defaultValue, locale, pattern,
useDefault || defaultValue != null, localizedPattern);
}
-
}
/**
@@ -63,11 +62,11 @@ public class IntegerLocaleConverter extends
DecimalLocaleConverter<Integer> {
/**
* Parses the specified locale-sensitive input object into an output
object of the specified type. This method will return Integer type.
*
- * @param value The input object to be converted
- * @param pattern The pattern is used for the conversion
- * @return The converted value
- * @throws ConversionException if conversion cannot be performed
successfully
- * @throws ParseException if an error occurs parsing a String to a
Number
+ * @param value The input object to be converted.
+ * @param pattern The pattern is used for the conversion.
+ * @return The converted value.
+ * @throws ConversionException if conversion cannot be performed
successfully.
+ * @throws ParseException if an error occurs parsing a String to a
Number.
*/
@Override
protected Integer parse(final Object value, final String pattern) throws
ParseException {
diff --git
a/src/main/java/org/apache/commons/beanutils2/locale/converters/LongLocaleConverter.java
b/src/main/java/org/apache/commons/beanutils2/locale/converters/LongLocaleConverter.java
index 855a5aff..0fe51987 100644
---
a/src/main/java/org/apache/commons/beanutils2/locale/converters/LongLocaleConverter.java
+++
b/src/main/java/org/apache/commons/beanutils2/locale/converters/LongLocaleConverter.java
@@ -44,7 +44,6 @@ public class LongLocaleConverter extends
DecimalLocaleConverter<Long> {
public LongLocaleConverter get() {
return new LongLocaleConverter(defaultValue, locale, pattern,
useDefault || defaultValue != null, localizedPattern);
}
-
}
/**
@@ -63,26 +62,23 @@ public class LongLocaleConverter extends
DecimalLocaleConverter<Long> {
/**
* Parses the specified locale-sensitive input object into an output
object of the specified type. This method will return a Long type.
*
- * @param value The input object to be converted
- * @param pattern The pattern is used for the conversion
- * @return The converted value
- * @throws ConversionException if conversion cannot be performed
successfully
- * @throws ParseException if an error occurs parsing a String to a
Number
+ * @param value The input object to be converted.
+ * @param pattern The pattern is used for the conversion.
+ * @return The converted value.
+ * @throws ConversionException if conversion cannot be performed
successfully.
+ * @throws ParseException if an error occurs parsing a String to a
Number.
* @since 1.8.0
*/
@Override
protected Long parse(final Object value, final String pattern) throws
ParseException {
final Number result = super.parse(value, pattern);
-
if (result == null || result instanceof Long) {
return (Long) result;
}
-
final double doubleValue = result.doubleValue();
if (doubleValue < Long.MIN_VALUE || doubleValue > Long.MAX_VALUE) {
throw new ConversionException("Supplied number is not of type
Long: " + result);
}
-
return Long.valueOf(result.longValue());
}
}
diff --git
a/src/main/java/org/apache/commons/beanutils2/locale/converters/ShortLocaleConverter.java
b/src/main/java/org/apache/commons/beanutils2/locale/converters/ShortLocaleConverter.java
index 40cbcba9..570190cc 100644
---
a/src/main/java/org/apache/commons/beanutils2/locale/converters/ShortLocaleConverter.java
+++
b/src/main/java/org/apache/commons/beanutils2/locale/converters/ShortLocaleConverter.java
@@ -49,7 +49,6 @@ public class ShortLocaleConverter extends
DecimalLocaleConverter<Short> {
public ShortLocaleConverter get() {
return new ShortLocaleConverter(defaultValue, locale, pattern,
useDefault || defaultValue != null, localizedPattern);
}
-
}
/**
@@ -68,28 +67,24 @@ public class ShortLocaleConverter extends
DecimalLocaleConverter<Short> {
/**
* Parses the specified locale-sensitive input object into an output
object of the specified type. This method will return values of type Short.
*
- * @param value The input object to be converted
- * @param pattern The pattern is used for the conversion
- * @return The converted value
- * @throws ConversionException if conversion cannot be performed
successfully
- * @throws ParseException if an error occurs parsing a String to a
Number
+ * @param value The input object to be converted.
+ * @param pattern The pattern is used for the conversion.
+ * @return The converted value.
+ * @throws ConversionException if conversion cannot be performed
successfully.
+ * @throws ParseException if an error occurs parsing a String to a
Number.
* @since 1.8.0
*/
@Override
protected Short parse(final Object value, final String pattern) throws
ParseException {
final Object result = super.parse(value, pattern);
-
if (result == null || result instanceof Short) {
return (Short) result;
}
-
final Number parsed = (Number) result;
if (parsed.longValue() != parsed.shortValue()) {
throw new ConversionException("Supplied number is not of type
Short: " + parsed.longValue());
}
-
// now returns property Short
return Short.valueOf(parsed.shortValue());
}
-
}
diff --git
a/src/main/java/org/apache/commons/beanutils2/locale/converters/StringLocaleConverter.java
b/src/main/java/org/apache/commons/beanutils2/locale/converters/StringLocaleConverter.java
index edd10539..a84fc85c 100644
---
a/src/main/java/org/apache/commons/beanutils2/locale/converters/StringLocaleConverter.java
+++
b/src/main/java/org/apache/commons/beanutils2/locale/converters/StringLocaleConverter.java
@@ -63,7 +63,6 @@ public class StringLocaleConverter extends
BaseLocaleConverter<String> {
public StringLocaleConverter get() {
return new StringLocaleConverter(defaultValue, locale, pattern,
useDefault || defaultValue != null, localizedPattern);
}
-
}
/** All logging goes through this logger */
@@ -85,15 +84,14 @@ public class StringLocaleConverter extends
BaseLocaleConverter<String> {
/**
* Gets an instance of DecimalFormat.
*
- * @param locale The locale
- * @param pattern The pattern is used for the conversion
- * @return The format for the locale and pattern
- * @throws ConversionException if conversion cannot be performed
successfully
- * @throws IllegalArgumentException if an error occurs parsing a String to
a Number
+ * @param locale The locale.
+ * @param pattern The pattern is used for the conversion.
+ * @return The format for the locale and pattern.
+ * @throws ConversionException if conversion cannot be performed
successfully.
+ * @throws IllegalArgumentException if an error occurs parsing a String to
a Number.
*/
private DecimalFormat getDecimalFormat(final Locale locale, final String
pattern) {
final DecimalFormat numberFormat = (DecimalFormat)
NumberFormat.getInstance(locale);
-
// if some constructors default pattern to null, it makes only sense
to handle null pattern gracefully
if (pattern != null) {
if (localizedPattern) {
@@ -104,23 +102,21 @@ public class StringLocaleConverter extends
BaseLocaleConverter<String> {
} else {
LOG.debug("No pattern provided, using default.");
}
-
return numberFormat;
}
/**
* Parses the specified locale-sensitive input object into an output
object of the specified type.
*
- * @param value The input object to be converted
- * @param pattern The pattern is used for the conversion
- * @return The converted value
- * @throws ConversionException if conversion cannot be performed
successfully
- * @throws ParseException if an error occurs
+ * @param value The input object to be converted.
+ * @param pattern The pattern is used for the conversion.
+ * @return The converted value.
+ * @throws ConversionException if conversion cannot be performed
successfully.
+ * @throws ParseException if an error occurs.
*/
@Override
protected String parse(final Object value, final String pattern) throws
ParseException {
String result = null;
-
if (value instanceof BigInteger || value instanceof BigDecimal) {
result = getDecimalFormat(locale, pattern).format(value);
} else if (value instanceof Integer || value instanceof Long || value
instanceof Byte || value instanceof Short) {
@@ -132,7 +128,6 @@ public class StringLocaleConverter extends
BaseLocaleConverter<String> {
} else {
result = value.toString();
}
-
return result;
}
}