- * Using this method to copy string arrays means that changes to the src array do not modify the dst array. - *
- */ - private static String[] copyStrings(final String[] src) { - final String[] dst = new String[src.length]; - for (int i = 0; i < src.length; ++i) { - dst[i] = toLowerCase(src[i]); - } - return dst; - } - /** * The set of strings that are known to map to Boolean.TRUE. */ @@ -67,6 +56,11 @@ private static String[] copyStrings(final String[] src) { */ private String[] falseStrings = { "false", "no", "n", "off", "0" }; + /** + * The locale to use for string comparisons. + */ + private Locale locale = Locale.ROOT; + /** * Constructs a {@link org.apache.commons.beanutils2.Converter} that will throw a {@link org.apache.commons.beanutils2.ConversionException} if a conversion * error occurs, that is, if the string value being converted is not one of the known true strings, nor one of the known false strings. @@ -97,8 +91,8 @@ public BooleanConverter(final Boolean defaultValue) { * @since 1.8.0 */ public BooleanConverter(final String[] trueStrings, final String[] falseStrings) { - this.trueStrings = copyStrings(trueStrings); - this.falseStrings = copyStrings(falseStrings); + this.trueStrings = trueStrings.clone(); + this.falseStrings = falseStrings.clone(); } /** @@ -115,8 +109,26 @@ public BooleanConverter(final String[] trueStrings, final String[] falseStrings) */ public BooleanConverter(final String[] trueStrings, final String[] falseStrings, final Boolean defaultValue) { super(defaultValue); - this.trueStrings = copyStrings(trueStrings); - this.falseStrings = copyStrings(falseStrings); + this.trueStrings = trueStrings.clone(); + this.falseStrings = falseStrings.clone(); + } + + /** + * Get the locale used for string comparisons. + * + * @return The locale used for string comparisons. + */ + public Locale getLocale() { + return locale; + } + + /** + * Set the locale used for string comparisons. + * + * @param locale The locale used for string comparisons. + */ + public void setLocale(Locale locale) { + this.locale = locale; } /** @@ -136,20 +148,18 @@ public BooleanConverter(final String[] trueStrings, final String[] falseStrings, @Override protected