@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); } } }
/** * This method generates a header that can be used for writing beans of the * type provided back to a file. * <p>The ordering of the headers is determined by the * {@link com.opencsv.bean.FieldMap} in use.</p> * <p>This method should be called first by all overriding classes to make * certain {@link #headerIndex} is properly initialized.</p> */ // The rest of the Javadoc is inherited @Override public String[] generateHeader(T bean) throws CsvRequiredFieldEmptyException { if(type == null) { throw new IllegalStateException(ResourceBundle .getBundle(ICSVParser.DEFAULT_BUNDLE_NAME, errorLocale) .getString("type.before.header")); } // Always take what's been given or previously determined first. if(headerIndex.isEmpty()) { String[] header = getFieldMap().generateHeader(bean); headerIndex.initializeHeaderIndex(header); return header; } // Otherwise, put headers in the right places. return headerIndex.getHeaderIndex(); }