Source:
public Map<String, Object> getAllComponentsForLocale(String appId, String locale) throws Exception { Map<String, Object> resultMap = new TreeMap<String, Object>(); Resource csvResource = resourceLoader.getResource("classpath:META-INF/locale/" + appId + ".csv"); if (!csvResource.exists()) { throw new Exception("CSV locale resource for " + appId + " does not exist."); } Reader reader = new FileReader(csvResource.getFile()); CSVReader csvReader = new CSVReader(reader, ';', '"', '\\'); try { int columnIndexOfLocale = detectColumnIndexOfLocale(locale, csvReader); List<String> nextLine; while ((nextLine = Arrays.asList(ArrayUtils.nullToEmpty(csvReader.readNext()))).isEmpty() == false) { String component = nextLine.get(0); String field = nextLine.get(1); String localeValue = nextLine.get(columnIndexOfLocale); Object value = localeValue; if (component.isEmpty()) { throw new Exception("Missing component entry in CSV line " + csvReader.getLinesRead()); } if (field.isEmpty()) { throw new Exception("Missing field entry in CSV line " + csvReader.getLinesRead()); } Object componentEntry; if (resultMap.containsKey(component)) { componentEntry = resultMap.get(component); } else { componentEntry = new TreeMap<String, Object>(); } if (field.contains("[]")) { if(Pattern.matches(".+(\\[])$", field) && StringUtils.countMatches(field, "[]") == 1) { field = field.replace("[]", StringUtils.EMPTY); value = localeValue.isEmpty() ? ArrayUtils.EMPTY_STRING_ARRAY : localeValue.split(","); } else { throw new Exception("Invalid field description '" + field + "': '[]' may only occure once at the end, but not before"); } } StructureUtils.putValueIntoMapOfMaps((Map<String, Object>) componentEntry, field, value); resultMap.put(component, componentEntry); } } catch (Exception e) { throw e; } finally { reader.close(); csvReader.close(); } return resultMap; }

Target:
public Map<String, Object> getAllComponentsForLocale(String appId, String locale) throws Exception { Map<String, Object> resultMap = new TreeMap<String, Object>(); Resource csvResource = resourceLoader.getResource("classpath:META-INF/locale/" + appId + ".csv"); if (!csvResource.exists()) { throw new Exception("CSV locale resource for " + appId + " does not exist."); } Reader reader = new FileReader(csvResource.getFile()); CSVReader csvReader = new CSVReader(reader, ';', '"', '\\'); try { int columnIndexOfLocale = detectColumnIndexOfLocale(locale, csvReader); List<String> nextLine; boolean nextLineIsNotEmpty = true; while (nextLineIsNotEmpty) { final String[] nextLineArray = ArrayUtils.nullToEmpty(csvReader.readNext()); nextLine = Arrays.asList(nextLineArray); nextLineIsNotEmpty = nextLine.isEmpty() == false; if(nextLineIsNotEmpty) { String component = nextLine.get(0); String field = nextLine.get(1); String localeValue = nextLine.get(columnIndexOfLocale); Object value = localeValue; if (component.isEmpty()) { throw new Exception("Missing component entry in CSV line " + csvReader.getLinesRead()); } if (field.isEmpty()) { throw new Exception("Missing field entry in CSV line " + csvReader.getLinesRead()); } Object componentEntry; if (resultMap.containsKey(component)) { componentEntry = resultMap.get(component); } else { componentEntry = new TreeMap<String, Object>(); } if (field.contains("[]")) { if(Pattern.matches(".+(\\[])$", field) && StringUtils.countMatches(field, "[]") == 1) { field = field.replace("[]", StringUtils.EMPTY); value = localeValue.isEmpty() ? ArrayUtils.EMPTY_STRING_ARRAY : localeValue.split(","); } else { throw new Exception("Invalid field description '" + field + "': '[]' may only occure once at the end, but not before"); } } StructureUtils.putValueIntoMapOfMaps((Map<String, Object>) componentEntry, field, value); resultMap.put(component, componentEntry); } } } catch (Exception e) { throw e; } finally { reader.close(); csvReader.close(); } return resultMap; }