/** * Attempts to instantiate the class of the custom converter specified. * * @param converter The class for a custom converter * @return The custom converter * @throws CsvBadConverterException If the class cannot be instantiated */ protected BeanField<T> instantiateCustomConverter(Class<? extends AbstractBeanField> converter) throws CsvBadConverterException { try { BeanField<T> c = converter.newInstance(); c.setErrorLocale(errorLocale); return c; } catch (IllegalAccessException | InstantiationException oldEx) { CsvBadConverterException newEx = new CsvBadConverterException(converter, String.format(ResourceBundle.getBundle(ICSVParser.DEFAULT_BUNDLE_NAME, errorLocale).getString("custom.converter.invalid"), converter.getCanonicalName())); newEx.initCause(oldEx); throw newEx; } }
@Override public void setErrorLocale(Locale errorLocale) { this.errorLocale = ObjectUtils.defaultIfNull(errorLocale, Locale.getDefault()); // It's very possible that setType() was called first, which creates all // of the BeanFields, so we need to go back through the list and correct // them all. if(getFieldMap() != null) { getFieldMap().setErrorLocale(this.errorLocale); for(BeanField<T> f : getFieldMap().values()) { f.setErrorLocale(this.errorLocale); } } }